* Maybe remove-hook should remove all trace of localness?
@ 2002-04-08 13:24 Marshall, Simon
2002-04-09 12:08 ` Richard Stallman
0 siblings, 1 reply; 2+ messages in thread
From: Marshall, Simon @ 2002-04-08 13:24 UTC (permalink / raw)
I noticed a package that checks the value of a local hook to see if it
is nil, meaning empty.
Unfortunately that is wrong because, currently, a local hook is (t) if
it is empty.
Only a non-local hook is nil if it is empty.
To see this, try:
(let (gotcha)
(add-hook 'gotcha 'foo nil t)
(remove-hook 'gotcha 'foo t)
gotcha)
=> (t)
One solution is to fix the package, but perhaps a cleaner solution all
round would be to make remove-hook behave in a less surprising way? And
also behave consistently, in that an add-hook/remove-hook pair would
leave the hook in the same state when the add/remove is local, as it
currently does when the add/remove is non-local.
I think this would do it, though perhaps there should be a
kill-local-hook for completeness.
Is it better? I think so. Does it have nasty side-effects? Not sure.
diff -c /rvcarma/marshals/ftp/emacs-21.1.90/lisp/subr.el.\~1\~
/rvcarma/marshals/ftp/emacs-21.1.90/lisp/subr.el
*** /rvcarma/marshals/ftp/emacs-21.1.90/lisp/subr.el.~1~ Thu Aug
9 15:52:27 2001
--- /rvcarma/marshals/ftp/emacs-21.1.90/lisp/subr.el Mon Apr 8
14:11:28 2002
***************
*** 776,782 ****
;; (not (member (cons 'not function) hook-value)))
;; (push (cons 'not function) hook-value))
;; Set the actual variable
! (if local (set hook hook-value) (set-default hook hook-value))))
(defun add-to-list (list-var element &optional append)
"Add to the value of LIST-VAR the element ELEMENT if it isn't there
yet.
--- 776,786 ----
;; (not (member (cons 'not function) hook-value)))
;; (push (cons 'not function) hook-value))
;; Set the actual variable
! (if (not local)
! (set-default hook hook-value)
! (if (equal hook-value '(t))
! (kill-local-variable hook)
! (set hook hook-value)))))
(defun add-to-list (list-var element &optional append)
"Add to the value of LIST-VAR the element ELEMENT if it isn't there
yet.
Diff finished at Mon Apr 8 14:12:23
^ permalink raw reply [flat|nested] 2+ messages in thread
* Re: Maybe remove-hook should remove all trace of localness?
2002-04-08 13:24 Maybe remove-hook should remove all trace of localness? Marshall, Simon
@ 2002-04-09 12:08 ` Richard Stallman
0 siblings, 0 replies; 2+ messages in thread
From: Richard Stallman @ 2002-04-09 12:08 UTC (permalink / raw)
Cc: emacs-devel
I like your change. Now that there is no longer a need
to call add-local-hook, we don't need a kill-local-hook,
and removing the (t) when it is temporarily unnecessary
cannot do any harm.
I will install it.
^ permalink raw reply [flat|nested] 2+ messages in thread
end of thread, other threads:[~2002-04-09 12:08 UTC | newest]
Thread overview: 2+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2002-04-08 13:24 Maybe remove-hook should remove all trace of localness? Marshall, Simon
2002-04-09 12:08 ` Richard Stallman
Code repositories for project(s) associated with this public inbox
https://git.savannah.gnu.org/cgit/emacs.git
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).