Mercurial > emacs
changeset 87974:97c3cc0a167b
(add-hook): Implement `permanent-local-hook' property.
author | Richard M. Stallman <rms@gnu.org> |
---|---|
date | Fri, 25 Jan 2008 22:51:18 +0000 |
parents | b3422590d572 |
children | c4f53aa37d97 |
files | lisp/subr.el |
diffstat | 1 files changed, 11 insertions(+), 1 deletions(-) [+] |
line wrap: on
line diff
--- a/lisp/subr.el Fri Jan 25 22:50:33 2008 +0000 +++ b/lisp/subr.el Fri Jan 25 22:51:18 2008 +0000 @@ -1103,7 +1103,17 @@ (append hook-value (list function)) (cons function hook-value)))) ;; Set the actual variable - (if local (set hook hook-value) (set-default hook hook-value)))) + (if local + (progn + ;; If HOOK isn't a permanent local, + ;; but FUNCTION wants to survive a change of modes, + ;; mark HOOK as partially permanent. + (and (symbolp function) + (get function 'permanent-local-hook) + (not (get hook 'permanent-local)) + (put hook 'permanent-local 'permanent-local-hook)) + (set hook hook-value)) + (set-default hook hook-value)))) (defun remove-hook (hook function &optional local) "Remove from the value of HOOK the function FUNCTION.