]> git.eshelyaron.com Git - emacs.git/commitdiff
* lisp/files.el (minibuffer-with-setup-hook): Fix bug#46326
authorStefan Monnier <monnier@iro.umontreal.ca>
Fri, 23 Apr 2021 21:17:40 +0000 (17:17 -0400)
committerStefan Monnier <monnier@iro.umontreal.ca>
Fri, 23 Apr 2021 21:21:29 +0000 (17:21 -0400)
lisp/files.el
lisp/subr.el

index 7440c11a21d61e9bf290e768a5e270837fad2b77..ee16abfd44849ec2bcfecdcaf7aea334b4cebda4 100644 (file)
@@ -1648,13 +1648,14 @@ rather than FUN itself, to `minibuffer-setup-hook'."
     (when (eq (car-safe fun) :append)
       (setq append '(t) fun (cadr fun)))
     `(let ((,funsym ,fun)
-           ,hook)
-       (setq ,hook
-             (lambda ()
-               ;; Clear out this hook so it does not interfere
-               ;; with any recursive minibuffer usage.
-               (remove-hook 'minibuffer-setup-hook ,hook)
-               (funcall ,funsym)))
+           ;; Use a symbol to make sure `add-hook' doesn't waste time
+           ;; in `equal'ity testing (bug#46326).
+           (,hook (make-symbol "minibuffer-setup")))
+       (fset ,hook (lambda ()
+                     ;; Clear out this hook so it does not interfere
+                     ;; with any recursive minibuffer usage.
+                     (remove-hook 'minibuffer-setup-hook ,hook)
+                     (funcall ,funsym)))
        (unwind-protect
            (progn
              (add-hook 'minibuffer-setup-hook ,hook ,@append)
index d9fb404c80dec7cb13a0d7e6166a3a20d05196b2..6589faf2398c218e5b67215386600c58211e0df2 100644 (file)
@@ -1918,7 +1918,8 @@ one will be removed."
        (when (setq old-fun (car (member function hook-value)))
          (setq hook-value (remq old-fun hook-value))))
       (when old-fun
-        ;; Remove auxiliary depth info to avoid leaks.
+        ;; Remove auxiliary depth info to avoid leaks (bug#46414)
+        ;; and to avoid the list growing too long.
         (put hook 'hook--depth-alist
              (delq (assq old-fun (get hook 'hook--depth-alist))
                    (get hook 'hook--depth-alist))))
@@ -5017,7 +5018,8 @@ See also `with-eval-after-load'."
                      (funcall func)
                    (let ((lfn load-file-name)
                          ;; Don't use letrec, because equal (in
-                         ;; add/remove-hook) would get trapped in a cycle.
+                         ;; add/remove-hook) would get trapped in a cycle
+                         ;; (bug#46326).
                          (fun (make-symbol "eval-after-load-helper")))
                      (fset fun (lambda (file)
                                  (when (equal file lfn)
@@ -5606,7 +5608,7 @@ to deactivate this transient map, regardless of KEEP-PRED."
             (remove-hook 'pre-command-hook clearfun)
             (when on-exit (funcall on-exit)))))
     ;; Don't use letrec, because equal (in add/remove-hook) would get trapped
-    ;; in a cycle.
+    ;; in a cycle. (bug#46326)
     (fset clearfun
           (lambda ()
             (with-demoted-errors "set-transient-map PCH: %S"