emacs-elpa-diffs
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

[elpa] externals/consult 7a93f91 3/3: consult-completing-read-multiple:


From: ELPA Syncer
Subject: [elpa] externals/consult 7a93f91 3/3: consult-completing-read-multiple: Add consult--crm-setup-hook
Date: Wed, 7 Jul 2021 14:57:08 -0400 (EDT)

branch: externals/consult
commit 7a93f917052be66700036f30d485718e804c7563
Author: Daniel Mendler <mail@daniel-mendler.de>
Commit: Daniel Mendler <mail@daniel-mendler.de>

    consult-completing-read-multiple: Add consult--crm-setup-hook
    
    This allows the addition of custom completion UI specific keybindings.
---
 consult-selectrum.el | 13 +++++++++----
 consult.el           | 10 +++++++---
 2 files changed, 16 insertions(+), 7 deletions(-)

diff --git a/consult-selectrum.el b/consult-selectrum.el
index d47e07f..108391a 100644
--- a/consult-selectrum.el
+++ b/consult-selectrum.el
@@ -60,11 +60,10 @@ See `consult--completion-filter' for arguments PATTERN, 
CANDS, CATEGORY and HIGH
 (defun consult-selectrum--refresh (&optional reset)
   "Refresh completion UI, keep current candidate unless RESET is non-nil."
   (when selectrum-is-active
-    (if consult--narrow
-        (setq-local selectrum-default-value-format nil)
-      (kill-local-variable 'selectrum-default-value-format))
+    (when consult--narrow
+      (setq-local selectrum-default-value-format nil))
     (when reset
-      (setq selectrum--history-hash nil))
+      (setq-local selectrum--history-hash nil))
     (selectrum-exhibit (not reset))))
 
 (defun consult-selectrum--split-wrap (orig split)
@@ -84,8 +83,14 @@ SPLIT is the splitter function."
     (setq-local selectrum-highlight-candidates-function
                (consult-selectrum--split-wrap 
selectrum-highlight-candidates-function split))))
 
+(defun consult-selectrum--crm-setup ()
+  "Setup crm for Selectrum."
+  (when selectrum-is-active
+    (setq-local selectrum-default-value-format nil)))
+
 (add-hook 'consult--completion-candidate-hook #'consult-selectrum--candidate)
 (add-hook 'consult--completion-refresh-hook #'consult-selectrum--refresh)
+(add-hook 'consult--crm-setup-hook #'consult-selectrum--crm-setup)
 (advice-add #'consult--completion-filter :around 
#'consult-selectrum--filter-adv)
 (advice-add #'consult--split-setup :around 
#'consult-selectrum--split-setup-adv)
 
diff --git a/consult.el b/consult.el
index 0bb63f1..de9d391 100644
--- a/consult.el
+++ b/consult.el
@@ -441,6 +441,9 @@ should not be considered as stable as the public API.")
 (defvar consult--cache nil
   "Cached data populated by `consult--define-cache'.")
 
+(defvar consult--crm-setup-hook nil
+  "Hook executed in `consult-completing-read-multiple' minibuffer.")
+
 (defvar consult--completion-candidate-hook
   (list #'consult--default-completion-mb-candidate
         #'consult--default-completion-list-candidate)
@@ -2227,8 +2230,8 @@ See `completing-read-multiple' for the documentation of 
the arguments."
                            (when selected
                              (format " (%s selected): " (length selected)))))))
          (command)
-         (hook (make-symbol "consult--crm-hook"))
-         (wrapper (make-symbol "consult--crm-wrapper")))
+         (hook (make-symbol "consult--crm-post-command-hook"))
+         (wrapper (make-symbol "consult--crm-command-wrapper")))
     (fset wrapper
           (lambda ()
             (interactive)
@@ -2254,7 +2257,8 @@ See `completing-read-multiple' for the documentation of 
the arguments."
            (when-let (pos (string-match-p "\\(?: (default[^)]+)\\)?: \\'" 
prompt))
              (setq overlay (make-overlay (+ (point-min) pos) (+ (point-min) 
(length prompt))))
              (funcall update-overlay))
-           (add-hook 'pre-command-hook hook nil 'local)))
+           (add-hook 'pre-command-hook hook nil 'local)
+           (run-hooks 'consult--crm-setup-hook)))
       (funcall select-item
                (completing-read
                 prompt



reply via email to

[Prev in Thread] Current Thread [Next in Thread]