# HG changeset patch # User Richard M. Stallman # Date 1201301478 0 # Node ID 97c3cc0a167bd69283612bf8a13587305588a830 # Parent b3422590d5726d55674bd067e0aafa4a69b78dc1 (add-hook): Implement `permanent-local-hook' property. diff -r b3422590d572 -r 97c3cc0a167b lisp/subr.el --- 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.