* Re: custom-set-variables fails to set variable [not found] ` <200511110043.jAB0hhc17895@raven.dms.auburn.edu> @ 2005-11-12 3:38 ` Richard M. Stallman 2005-11-12 4:05 ` Luc Teirlinck 2005-11-12 4:41 ` Luc Teirlinck 0 siblings, 2 replies; 8+ messages in thread From: Richard M. Stallman @ 2005-11-12 3:38 UTC (permalink / raw) Cc: p.galbraith, wohler, emacs-devel 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? A more automatic solution could be: define-derived-mode could automatically produce an autoload definition of the defvar. That would solve the problem, right? It is not normal for update-file-autoloads to generate an autoload with no autoload cookie, but we could do that. ^ permalink raw reply [flat|nested] 8+ messages in thread
* Re: custom-set-variables fails to set variable 2005-11-12 3:38 ` custom-set-variables fails to set variable Richard M. Stallman @ 2005-11-12 4:05 ` Luc Teirlinck 2005-11-12 4:49 ` Luc Teirlinck 2005-11-12 21:19 ` Juri Linkov 2005-11-12 4:41 ` Luc Teirlinck 1 sibling, 2 replies; 8+ messages in thread From: Luc Teirlinck @ 2005-11-12 4:05 UTC (permalink / raw) Cc: p.galbraith, wohler, emacs-devel 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. ^ permalink raw reply [flat|nested] 8+ messages in thread
* Re: custom-set-variables fails to set variable 2005-11-12 4:05 ` Luc Teirlinck @ 2005-11-12 4:49 ` Luc Teirlinck 2005-11-12 21:19 ` Juri Linkov 1 sibling, 0 replies; 8+ messages in thread From: Luc Teirlinck @ 2005-11-12 4:49 UTC (permalink / raw) Cc: p.galbraith, emacs-devel, rms, wohler >From my earlier message: Unless I am confused, this also has the disadvantage that it is not going to work for uses of define-minor-mode in third party packages. I meant `define-derived-mode', not `define-minor-mode', obviously. Sincerely, Luc. ^ permalink raw reply [flat|nested] 8+ messages in thread
* Re: custom-set-variables fails to set variable 2005-11-12 4:05 ` Luc Teirlinck 2005-11-12 4:49 ` Luc Teirlinck @ 2005-11-12 21:19 ` Juri Linkov 1 sibling, 0 replies; 8+ messages in thread From: Juri Linkov @ 2005-11-12 21:19 UTC (permalink / raw) Cc: p.galbraith, emacs-devel, rms, wohler > 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. Please note also that even when `C-h v' works correctly on a hook variable (like it works now), an attempt to follow the link to the source code (i.e. typing RET on the file name link in the Help buffer) fails. That is because `find-function-search-for-symbol' tries to find a definition of the variable whose name contains the suffix "-hook", but it is defined in the macro without the suffix "-hook" (e.g. `mh-letter-mode-hook' is defined as `define-derived-mode mh-letter-mode'). It is possible to specify the name of the definition explicitly by setting the symbol's property `definition-name'. `define-global-minor-mode' already does this, so `define-derived-mode' could do the same. This means putting a line like (if (not (boundp ',map)) (put ',map 'definition-name ',child)) before every `defvar' in the body of `define-derived-mode'. Checking the boundness is necessary for the case when the variable is already defined before evaluating the body of `define-derived-mode'. There are four variables defvar'ed currently in `define-derived-mode': `-hook', `-map', `-syntax-table' and `-abbrev-table'. The condition above works for the first three variables, but not for `-abbrev-table' which requires special treatment for the case when an abbrev table is defined in ~/.abbrev_defs. -- Juri Linkov http://www.jurta.org/emacs/ ^ permalink raw reply [flat|nested] 8+ messages in thread
* Re: custom-set-variables fails to set variable 2005-11-12 3:38 ` custom-set-variables fails to set variable Richard M. Stallman 2005-11-12 4:05 ` Luc Teirlinck @ 2005-11-12 4:41 ` Luc Teirlinck 2005-11-12 21:21 ` Richard M. Stallman 1 sibling, 1 reply; 8+ messages in thread From: Luc Teirlinck @ 2005-11-12 4:41 UTC (permalink / raw) Cc: p.galbraith, wohler, emacs-devel Richard Stallman wrote: A more automatic solution could be: define-derived-mode could automatically produce an autoload definition of the defvar. That would solve the problem, right? It is not normal for update-file-autoloads to generate an autoload with no autoload cookie, but we could do that. Unless I am confused, this also has the disadvantage that it is not going to work for uses of define-minor-mode in third party packages. Sincerely, Luc. ^ permalink raw reply [flat|nested] 8+ messages in thread
* Re: custom-set-variables fails to set variable 2005-11-12 4:41 ` Luc Teirlinck @ 2005-11-12 21:21 ` Richard M. Stallman 2005-11-12 23:36 ` Luc Teirlinck 0 siblings, 1 reply; 8+ messages in thread From: Richard M. Stallman @ 2005-11-12 21:21 UTC (permalink / raw) Cc: p.galbraith, wohler, emacs-devel A more automatic solution could be: define-derived-mode could automatically produce an autoload definition of the defvar. That would solve the problem, right? It is not normal for update-file-autoloads to generate an autoload with no autoload cookie, but we could do that. Unless I am confused, this also has the disadvantage that it is not going to work for uses of define-derived-mode in third party packages. You are right. So that approach won't work. Meanwhile, another point occurs to me. Why is the defvar that comes from the define-derived-mode executed before the defcustom? Could that be solved by putting the defcustom earlier in the file? Another idea: replace the defvar with a put call that will put on a variable-documentation property. 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. We don't want the automatically generated doc string to override an explicit one, so perhaps the define-derived-mode should generate (unless (get VAR 'variable-documentation) (put VAR 'variable-documentation STRING)) ^ permalink raw reply [flat|nested] 8+ messages in thread
* Re: custom-set-variables fails to set variable 2005-11-12 21:21 ` Richard M. Stallman @ 2005-11-12 23:36 ` Luc Teirlinck 2005-11-14 4:55 ` Richard M. Stallman 0 siblings, 1 reply; 8+ messages in thread From: Luc Teirlinck @ 2005-11-12 23:36 UTC (permalink / raw) Cc: p.galbraith, wohler, emacs-devel Richard Stallman wrote: Meanwhile, another point occurs to me. Why is the defvar that comes from the define-derived-mode executed before the defcustom? Could that be solved by putting the defcustom earlier in the file? Yes, but with the current code, the defvar's docstring would overwrite the defcustom's. Also, I would rather not rely on all Elisp authors to be perfectly aware of this issue. We don't want the automatically generated doc string to override an explicit one, so perhaps the define-derived-mode should generate (unless (get VAR 'variable-documentation) (put VAR 'variable-documentation STRING)) I believe that this is a much more solid alternative. The patch below implements this. I can install if it looks OK. But remember that the original confusion which let to the defvar was not that outline-mode-hook had no docs. I believe that the OP was perfectly aware of the fact that outline-mode-hook was run at the end of outline-mode. What really confused him was the fact that outline-mode was unbound. So I propose to expand the docstring to explain that this is no problem. After my patch `C-h v paragraph-indent-text-mode-hook' results in: paragraph-indent-text-mode-hook is void as a variable. Documentation: Hook run when entering Parindent mode. No problems result if this hook is not bound. `add-hook' automatically binds it. (This is true for all hook variables.) Patch: ===File ~/derived-diff====================================== *** derived.el 06 Aug 2005 13:23:00 -0500 1.12 --- derived.el 12 Nov 2005 17:31:33 -0600 *************** *** 194,200 **** parent child docstring syntax abbrev)) `(progn ! (defvar ,hook nil ,(format "Hook run when entering %s mode." name)) (defvar ,map (make-sparse-keymap)) ,(if declare-syntax `(defvar ,syntax (make-syntax-table))) --- 194,205 ---- parent child docstring syntax abbrev)) `(progn ! (unless (get ',hook 'variable-documentation) ! (put ',hook 'variable-documentation ! ,(format "Hook run when entering %s mode. ! No problems result if this hook is not bound. ! `add-hook' automatically binds it. (This is true for all hook variables.)" ! name))) (defvar ,map (make-sparse-keymap)) ,(if declare-syntax `(defvar ,syntax (make-syntax-table))) ============================================================ ^ permalink raw reply [flat|nested] 8+ messages in thread
* Re: custom-set-variables fails to set variable 2005-11-12 23:36 ` Luc Teirlinck @ 2005-11-14 4:55 ` Richard M. Stallman 0 siblings, 0 replies; 8+ messages in thread From: Richard M. Stallman @ 2005-11-14 4:55 UTC (permalink / raw) Cc: p.galbraith, wohler, emacs-devel Please install your patch. ^ permalink raw reply [flat|nested] 8+ messages in thread
end of thread, other threads:[~2005-11-14 4:55 UTC | newest] Thread overview: 8+ messages (download: mbox.gz follow: Atom feed -- links below jump to the message on this page -- [not found] <11859.1131656026@olgas.newt.com> [not found] ` <87lkzwxduk.fsf@olgas.newt.com> [not found] ` <200511110043.jAB0hhc17895@raven.dms.auburn.edu> 2005-11-12 3:38 ` custom-set-variables fails to set variable Richard M. Stallman 2005-11-12 4:05 ` Luc Teirlinck 2005-11-12 4:49 ` Luc Teirlinck 2005-11-12 21:19 ` Juri Linkov 2005-11-12 4:41 ` Luc Teirlinck 2005-11-12 21:21 ` Richard M. Stallman 2005-11-12 23:36 ` Luc Teirlinck 2005-11-14 4:55 ` Richard M. Stallman
Code repositories for project(s) associated with this external index https://git.savannah.gnu.org/cgit/emacs.git https://git.savannah.gnu.org/cgit/emacs/org-mode.git This is an external index of several public inboxes, see mirroring instructions on how to clone and mirror all data and code used by this external index.