(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)
(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))))
(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)
(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"