emacs-devel
[Top][All Lists]
Advanced

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

Re: custom-set-variables fails to set variable


From: Luc Teirlinck
Subject: Re: custom-set-variables fails to set variable
Date: Fri, 11 Nov 2005 22:05:29 -0600 (CST)

       Why does define-minor-mode need to defvar the mode hook?  There is no
       need to defvar hooks.  `add-hook' can perfectly handle unbound hook
       variables.  I propose that we revert this change in
       define-derived-mode.

   I agree, if we can't find a better solution.

   Another possible solution is to autoload the defcustoms
   for these particular variables.  Would that work?

Yes, but this is inevitably going to be forgotten for some defcustoms.

   A more automatic solution could be: define-derived-mode
   could automatically produce an autoload definition
   of the defvar.  That would solve the problem, right?

Yes, but both the manual and the automated solutions have the
potential for problems.  Somebody supplying a defcustom may want a
tailor-made docstring for the defcustom, mentioning typical uses for
the hook and the defvar's docstring could overwrite that.  In general,
it does not seem very good to have two competing different definitions
for a variable.  This solution might also unnecessarily bloat loaddefs.

Remember that all of this came about because the mode's docstring
contains:

    Entry to this mode calls the value of `lisp-mode-hook'
    if that value is non-nil.

And `C-h v' on lisp-mode-hook did not work.

Maybe we could just change that to:

    Entry to this mode calls the value of `lisp-mode-hook'
    if that value is bound and non-nil.  `add-hook' automatically
    binds a hook variable if it was previously unbound.

That would also help people understand why `C-h v foo-hook' does not
always work for hooks.  Many hooks that are not mode hooks have no
defvar.

Sincerely,

Luc.




reply via email to

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