[Top][All Lists]

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: obsolete comment in tool-bar.el

From: Stefan Monnier
Subject: Re: obsolete comment in tool-bar.el
Date: Fri, 15 Jul 2005 00:35:45 -0400
User-agent: Gnus/5.11 (Gnus v5.11) Emacs/22.0.50 (gnu/linux)

> I have the impression that the offending code in define-minor-mode:
> ;; If the mode is global, call the function according to the default.
>        ,(if globalp
>            `(if (and load-file-name (not (equal ,init-value ,mode)))
>                (eval-after-load load-file-name '(,mode (if ,mode 1 -1))))))))

> combined with custom-initialize-default, is an ugly kludge to get around
> a bug people sometimes make where they use functions or variables in a
> :set function that are defined in the same file, but _after_ the defcustom.

AFAIK, the motivation was also for some other cases where the user may
somehow setq the variable before loading the file.  IIRC this setq may
actually be done by Custom (at a time where it doesn't yet know that the var
have a :setter).

> That of course does not work and the obvious solution is to define
> those functions and variables before the defcustom.

But this is non-obvious, so it's ugly.  Also often those functions use the
variable, so to shut up the byte-compiler you need to pre-declare the
variable.  Miles complained loudly (in the form of comments, some of which
may still be in the current elisp code ;-) before I installed this
delayed-initialization trick.

> But I believe that define-minor-mode tries to hide this type of user
> bug and work around it by delaying the enabling of the minor mode
> function until after the file is loaded.

Which is the right thing to do.

> !         `(and load-file-name
> !               (eq (quote ,initialize)
> !                   (quote (:initialize 'custom-initialize-default)))
> !               (not (equal ,init-value ,mode))
> !               (eval-after-load load-file-name '(,mode (if ,mode 1 -1))))))))

IIUC the (eq (quote ,initialize)
> !                   (quote (:initialize 'custom-initialize-default)))

reply via email to

[Prev in Thread] Current Thread [Next in Thread]