diff options
| author | Stefan Monnier | 2022-02-22 22:52:40 -0500 |
|---|---|---|
| committer | Stefan Monnier | 2022-02-22 22:52:40 -0500 |
| commit | 8adc3672ac1b2fb90d142cfe2a1a74d36e33b41b (patch) | |
| tree | 3f1db12932d4380de4e9383ae87a8eb3e31003dd | |
| parent | 659eca9ed8df020a2f3edd84a82b3316820749c7 (diff) | |
| download | emacs-8adc3672ac1b2fb90d142cfe2a1a74d36e33b41b.tar.gz emacs-8adc3672ac1b2fb90d142cfe2a1a74d36e33b41b.zip | |
(add-hook): Fix regression
* lisp/subr.el (add-hook): When the hook has no local part yet, don't
set `local` to t, so we set the right part of the depth-sym.
(remove-hook): Don't modify the depth alist by side-effect since I'm
not completely sure it's safe.
| -rw-r--r-- | lisp/subr.el | 6 |
1 files changed, 4 insertions, 2 deletions
diff --git a/lisp/subr.el b/lisp/subr.el index 1b9b67b7054..eb9af0b36da 100644 --- a/lisp/subr.el +++ b/lisp/subr.el | |||
| @@ -1905,7 +1905,9 @@ performance impact when running `add-hook' and `remove-hook'." | |||
| 1905 | (set (make-local-variable hook) (list t))) | 1905 | (set (make-local-variable hook) (list t))) |
| 1906 | ;; Detect the case where make-local-variable was used on a hook | 1906 | ;; Detect the case where make-local-variable was used on a hook |
| 1907 | ;; and do what we used to do. | 1907 | ;; and do what we used to do. |
| 1908 | (unless (and (consp (symbol-value hook)) (memq t (symbol-value hook))) | 1908 | (when (and (local-variable-if-set-p hook) |
| 1909 | (not (and (consp (symbol-value hook)) | ||
| 1910 | (memq t (symbol-value hook))))) | ||
| 1909 | (setq local t))) | 1911 | (setq local t))) |
| 1910 | (let ((hook-value (if local (symbol-value hook) (default-value hook)))) | 1912 | (let ((hook-value (if local (symbol-value hook) (default-value hook)))) |
| 1911 | ;; If the hook value is a single function, turn it into a list. | 1913 | ;; If the hook value is a single function, turn it into a list. |
| @@ -2020,7 +2022,7 @@ one will be removed." | |||
| 2020 | (when di | 2022 | (when di |
| 2021 | (setf (if local (symbol-value depth-sym) | 2023 | (setf (if local (symbol-value depth-sym) |
| 2022 | (default-value depth-sym)) | 2024 | (default-value depth-sym)) |
| 2023 | (delq di depth-alist))))) | 2025 | (remq di depth-alist))))) |
| 2024 | ;; If the function is on the global hook, we need to shadow it locally | 2026 | ;; If the function is on the global hook, we need to shadow it locally |
| 2025 | ;;(when (and local (member function (default-value hook)) | 2027 | ;;(when (and local (member function (default-value hook)) |
| 2026 | ;; (not (member (cons 'not function) hook-value))) | 2028 | ;; (not (member (cons 'not function) hook-value))) |