diff options
| author | Richard M. Stallman | 2008-01-25 22:51:18 +0000 |
|---|---|---|
| committer | Richard M. Stallman | 2008-01-25 22:51:18 +0000 |
| commit | 3531046188b20307bb5097cd5d41012ba87bb3af (patch) | |
| tree | 1c1798a7992acabd19fd78caa51d1e6a2bd7bca3 | |
| parent | 8f696e65587ebacf9a0bb812938ab1fc94e921bb (diff) | |
| download | emacs-3531046188b20307bb5097cd5d41012ba87bb3af.tar.gz emacs-3531046188b20307bb5097cd5d41012ba87bb3af.zip | |
(add-hook): Implement `permanent-local-hook' property.
| -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." | |||
| 1103 | (append hook-value (list function)) | 1103 | (append hook-value (list function)) |
| 1104 | (cons function hook-value)))) | 1104 | (cons function hook-value)))) |
| 1105 | ;; Set the actual variable | 1105 | ;; Set the actual variable |
| 1106 | (if local (set hook hook-value) (set-default hook hook-value)))) | 1106 | (if local |
| 1107 | (progn | ||
| 1108 | ;; If HOOK isn't a permanent local, | ||
| 1109 | ;; but FUNCTION wants to survive a change of modes, | ||
| 1110 | ;; mark HOOK as partially permanent. | ||
| 1111 | (and (symbolp function) | ||
| 1112 | (get function 'permanent-local-hook) | ||
| 1113 | (not (get hook 'permanent-local)) | ||
| 1114 | (put hook 'permanent-local 'permanent-local-hook)) | ||
| 1115 | (set hook hook-value)) | ||
| 1116 | (set-default hook hook-value)))) | ||
| 1107 | 1117 | ||
| 1108 | (defun remove-hook (hook function &optional local) | 1118 | (defun remove-hook (hook function &optional local) |
| 1109 | "Remove from the value of HOOK the function FUNCTION. | 1119 | "Remove from the value of HOOK the function FUNCTION. |