[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[elpa] externals/consult 369592fe2f: Execute delayed mode hooks during p
From: |
ELPA Syncer |
Subject: |
[elpa] externals/consult 369592fe2f: Execute delayed mode hooks during preview |
Date: |
Wed, 8 May 2024 12:57:47 -0400 (EDT) |
branch: externals/consult
commit 369592fe2f160c1b54f91266104992fc25bc5e14
Author: Daniel Mendler <mail@daniel-mendler.de>
Commit: Daniel Mendler <mail@daniel-mendler.de>
Execute delayed mode hooks during preview
See the variable consult-preview-allowed-hooks.
---
CHANGELOG.org | 2 ++
README.org | 16 ++++++++++------
consult.el | 10 +++++++++-
3 files changed, 21 insertions(+), 7 deletions(-)
diff --git a/CHANGELOG.org b/CHANGELOG.org
index 78e949e519..a3d10d3ee1 100644
--- a/CHANGELOG.org
+++ b/CHANGELOG.org
@@ -6,6 +6,8 @@
- ~consult-grep~ (and similar): Preserve files which are already open literally
and do not reopen them in normal mode.
+- ~consult-preview-allowed-hooks~: Run delayed mode hooks listed in this
variable
+ during preview.
* Version 1.5 (2024-04-19)
diff --git a/README.org b/README.org
index 692ba78ae9..f9fdb0257b 100644
--- a/README.org
+++ b/README.org
@@ -475,13 +475,17 @@ action on the current candidate in comparison to a
manually triggered preview.
The main difference is that the files opened by manual preview are closed again
after the completion session. During preview some functionality is disabled to
improve the performance, see for example the customization variables
-=consult-preview-variables= and =consult-preview-allowed-hooks=. Only the hooks
-listed in =consult-preview-allowed-hooks= are executed when a file is opened
-(=find-file-hook=). In order to enable additional font locking during preview,
add
-the corresponding hooks to the allow list. The following code demonstrates this
-for [[https://github.com/minad/org-modern][org-modern]] and
[[https://github.com/tarsius/hl-todo][hl-todo]].
+=consult-preview-variables= and =consult-preview-allowed-hooks=. Only mode
hooks
+(e.g. =prog-mode-hook=) and find file hooks (=find-file-hook=) listed in
+=consult-preview-allowed-hooks= are executed. In order to enable additional
font
+locking during preview, add the corresponding hooks to the allow list. The
+following code demonstrates this for
[[https://github.com/minad/org-modern][org-modern]] and
[[https://github.com/tarsius/hl-todo][hl-todo]].
#+begin_src emacs-lisp
+;; mode hook examples
+(add-to-list 'consult-preview-allowed-hooks 'hl-todo-mode)
+(add-to-list 'consult-preview-allowed-hooks 'elide-head-mode)
+;; find-file-hook examples
(add-to-list 'consult-preview-allowed-hooks
'global-org-modern-mode-check-buffers)
(add-to-list 'consult-preview-allowed-hooks 'global-hl-todo-mode-check-buffers)
#+end_src
@@ -919,7 +923,7 @@ an overview of all Consult variables and functions with
their descriptions.
| consult-narrow-key | Narrowing prefix key during completion
|
| consult-point-placement | Placement of the point when jumping to
matches |
| consult-preview-key | Keys which triggers preview
|
-| consult-preview-allowed-hooks | List of =find-file= hooks to enable
during preview |
+| consult-preview-allowed-hooks | List of hooks to enable during preview
|
| consult-preview-excluded-files | Regexps matched against file names during
preview |
| consult-preview-max-count | Maximum number of files to keep open
during preview |
| consult-preview-partial-size | Files larger than this size are previewed
partially |
diff --git a/consult.el b/consult.el
index ff24e7cc9c..c3bed2b337 100644
--- a/consult.el
+++ b/consult.el
@@ -342,7 +342,9 @@ chunk from the beginning of the file is previewed."
(defcustom consult-preview-allowed-hooks
'(global-font-lock-mode-check-buffers
save-place-find-file-hook)
- "List of `find-file' hooks, which should be executed during file preview."
+ "List of hooks, which should be executed during file preview.
+This variable applies to both `find-file-hook' and mode hooks,
+e.g., `prog-mode-hook'."
:type '(repeat symbol))
(defcustom consult-preview-variables
@@ -1313,6 +1315,12 @@ ORIG is the original function, HOOKS the arguments."
(when (bound-and-true-p so-long-detected-p)
(error "No preview of file `%s' with long lines"
(file-name-nondirectory name)))
+ ;; Run delayed hooks listed in `consult-preview-allowed-hooks'.
+ (dolist (hook (reverse delayed-mode-hooks))
+ (run-hook-wrapped hook (lambda (fun)
+ (when (memq fun
consult-preview-allowed-hooks)
+ (funcall fun))
+ nil)))
(setq success (current-buffer)))
(unless success
(kill-buffer buffer))))))
[Prev in Thread] |
Current Thread |
[Next in Thread] |
- [elpa] externals/consult 369592fe2f: Execute delayed mode hooks during preview,
ELPA Syncer <=