[Top][All Lists]
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
Maybe remove-hook should remove all trace of localness?
From: |
Marshall, Simon |
Subject: |
Maybe remove-hook should remove all trace of localness? |
Date: |
Mon, 8 Apr 2002 14:24:52 +0100 |
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
- Maybe remove-hook should remove all trace of localness?,
Marshall, Simon <=