[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[elpa] externals/consult d0261c0ecd 2/2: consult-preview: add-hook is br
From: |
ELPA Syncer |
Subject: |
[elpa] externals/consult d0261c0ecd 2/2: consult-preview: add-hook is broken on Emacs 28, don't use it |
Date: |
Tue, 22 Feb 2022 09:57:23 -0500 (EST) |
branch: externals/consult
commit d0261c0ecdf95ab543ad73d466c450bfedb8b1e7
Author: Daniel Mendler <mail@daniel-mendler.de>
Commit: Daniel Mendler <mail@daniel-mendler.de>
consult-preview: add-hook is broken on Emacs 28, don't use it
We have to make sure that the preview pch is called after the
completion UI pch.
---
consult.el | 25 +++++++++++++++++++------
1 file changed, 19 insertions(+), 6 deletions(-)
diff --git a/consult.el b/consult.el
index 9f788c2a42..c782ead2c9 100644
--- a/consult.el
+++ b/consult.el
@@ -1294,7 +1294,8 @@ and CANDIDATE."
(setq consult--preview-function
(let ((last-preview))
(lambda ()
- (with-selected-window (active-minibuffer-window)
+ (with-selected-window (or (active-minibuffer-window)
+ (selected-window))
(when-let (cand (funcall candidate))
(let ((input (minibuffer-contents-no-properties)))
(with-selected-window (or
(minibuffer-selected-window) (next-window))
@@ -1322,15 +1323,27 @@ and CANDIDATE."
(let ((post-command-sym (make-symbol
"consult--preview-post-command")))
(fset post-command-sym (lambda ()
(setq input
(minibuffer-contents-no-properties))
- ;; Defer running the preview function
until
- ;; after minibuffer UI candidate
computation
- (run-at-time 0 nil
consult--preview-function)))
- (add-hook 'post-command-hook post-command-sym nil 'local)))
+ (funcall consult--preview-function)))
+ ;; TODO Emacs 28 has a bug, where the hook--depth-alist is not
cleaned up properly
+ ;; Do not use the broken add-hook here.
+ ;;(add-hook 'post-command-hook post-command-sym 'append 'local)
+ (setq-local post-command-hook
+ (append
+ (remove t post-command-hook)
+ (list post-command-sym)
+ (and (memq t post-command-hook) '(t))))))
(lambda ()
;; symbol indirection because of bug#46407
(let ((post-command-sym (make-symbol
"consult--preview-post-command")))
(fset post-command-sym (lambda () (setq input
(minibuffer-contents-no-properties))))
- (add-hook 'post-command-hook post-command-sym nil 'local))))
+ ;; TODO Emacs 28 has a bug, where the hook--depth-alist is not
cleaned up properly
+ ;; Do not use the broken add-hook here.
+ ;;(add-hook 'post-command-hook post-command-sym 'append 'local)
+ (setq-local post-command-hook
+ (append
+ (remove t post-command-hook)
+ (list post-command-sym)
+ (and (memq t post-command-hook) '(t)))))))
(unwind-protect
(cons (setq selected (when-let (result (funcall fun))
(funcall transform input result)))