From: Richard M. Stallman Date: Fri, 25 Jan 2008 22:51:18 +0000 (+0000) Subject: (add-hook): Implement `permanent-local-hook' property. X-Git-Tag: emacs-pretest-23.0.90~8408 X-Git-Url: http://git.eshelyaron.com/gitweb/?a=commitdiff_plain;h=3531046188b20307bb5097cd5d41012ba87bb3af;p=emacs.git (add-hook): Implement `permanent-local-hook' property. --- 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.