From 3531046188b20307bb5097cd5d41012ba87bb3af Mon Sep 17 00:00:00 2001 From: "Richard M. Stallman" Date: Fri, 25 Jan 2008 22:51:18 +0000 Subject: [PATCH] (add-hook): Implement `permanent-local-hook' property. --- lisp/subr.el | 12 +++++++++++- 1 file changed, 11 insertions(+), 1 deletion(-) 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. -- 2.39.2