From: Stefan Monnier Date: Fri, 23 Apr 2021 21:17:40 +0000 (-0400) Subject: * lisp/files.el (minibuffer-with-setup-hook): Fix bug#46326 X-Git-Tag: emacs-28.0.90~2754 X-Git-Url: http://git.eshelyaron.com/gitweb/?a=commitdiff_plain;h=2868199564fd0319e0d324d075d6f91153931e51;p=emacs.git * lisp/files.el (minibuffer-with-setup-hook): Fix bug#46326 --- diff --git a/lisp/files.el b/lisp/files.el index 7440c11a21d..ee16abfd448 100644 --- a/lisp/files.el +++ b/lisp/files.el @@ -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) diff --git a/lisp/subr.el b/lisp/subr.el index d9fb404c80d..6589faf2398 100644 --- a/lisp/subr.el +++ b/lisp/subr.el @@ -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"