diff options
author | Richard M. Stallman <rms@gnu.org> | 2008-01-25 22:51:18 +0000 |
---|---|---|
committer | Richard M. Stallman <rms@gnu.org> | 2008-01-25 22:51:18 +0000 |
commit | 3531046188b20307bb5097cd5d41012ba87bb3af (patch) | |
tree | 1c1798a7992acabd19fd78caa51d1e6a2bd7bca3 /lisp/subr.el | |
parent | 8f696e65587ebacf9a0bb812938ab1fc94e921bb (diff) | |
download | emacs-3531046188b20307bb5097cd5d41012ba87bb3af.tar.gz emacs-3531046188b20307bb5097cd5d41012ba87bb3af.tar.bz2 emacs-3531046188b20307bb5097cd5d41012ba87bb3af.zip |
(add-hook): Implement `permanent-local-hook' property.
Diffstat (limited to 'lisp/subr.el')
-rw-r--r-- | lisp/subr.el | 12 |
1 files changed, 11 insertions, 1 deletions
diff --git a/lisp/subr.el b/lisp/subr.el index ca479de2687..5a7f88f76dd 100644 --- a/lisp/subr.el +++ b/lisp/subr.el @@ -1103,7 +1103,17 @@ function, it is changed to a list of functions." (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. |