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

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

[elpa] externals/vertico 2f7c63b: Add completion-predicate to the Vertic


From: ELPA Syncer
Subject: [elpa] externals/vertico 2f7c63b: Add completion-predicate to the Vertico commands (Fix #84)
Date: Wed, 14 Jul 2021 14:57:20 -0400 (EDT)

branch: externals/vertico
commit 2f7c63bb811bcea05b21119d9bf060c62b848a0a
Author: Daniel Mendler <mail@daniel-mendler.de>
Commit: Daniel Mendler <mail@daniel-mendler.de>

    Add completion-predicate to the Vertico commands (Fix #84)
---
 README.org                      |  5 +++++
 extensions/vertico-directory.el |  5 +++++
 extensions/vertico-quick.el     |  4 ++++
 vertico.el                      | 10 ++++++++++
 4 files changed, 24 insertions(+)

diff --git a/README.org b/README.org
index 555dcda..5cf405f 100644
--- a/README.org
+++ b/README.org
@@ -97,6 +97,11 @@
             '(read-only t cursor-intangible t face minibuffer-prompt))
       (add-hook 'minibuffer-setup-hook #'cursor-intangible-mode)
 
+      ;; Emacs 28: Hide commands in M-x which do not work in the current mode.
+      ;; Vertico commands are hidden in normal buffers.
+      ;; (setq read-extended-command-predicate
+      ;;       #'command-completion-default-include-p)
+
       ;; Enable recursive minibuffers
       (setq enable-recursive-minibuffers t))
   #+end_src
diff --git a/extensions/vertico-directory.el b/extensions/vertico-directory.el
index 283297e..bad6a91 100644
--- a/extensions/vertico-directory.el
+++ b/extensions/vertico-directory.el
@@ -100,5 +100,10 @@
                  (eq ?/ (char-before (- (point) 2)))))
     (delete-region (overlay-start rfn-eshadow-overlay) (overlay-end 
rfn-eshadow-overlay))))
 
+;; Emacs 28: Do not show Vertico commands in M-X
+(dolist (sym '(vertico-directory-up vertico-directory-enter
+               vertico-directory-delete-char vertico-directory-delete-word))
+  (put sym 'completion-predicate #'vertico--command-p))
+
 (provide 'vertico-directory)
 ;;; vertico-directory.el ends here
diff --git a/extensions/vertico-quick.el b/extensions/vertico-quick.el
index 9c48f08..97ae7fc 100644
--- a/extensions/vertico-quick.el
+++ b/extensions/vertico-quick.el
@@ -131,5 +131,9 @@
   (when (vertico-quick-jump)
     (vertico-insert)))
 
+;; Emacs 28: Do not show Vertico commands in M-X
+(dolist (sym '(vertico-quick-jump  vertico-quick-exit vertico-quick-insert))
+  (put sym 'completion-predicate #'vertico--command-p))
+
 (provide 'vertico-quick)
 ;;; vertico-quick.el ends here
diff --git a/vertico.el b/vertico.el
index 23df7bc..7464f9e 100644
--- a/vertico.el
+++ b/vertico.el
@@ -739,5 +739,15 @@ When the prefix argument is 0, the group order is reset."
     (advice-remove #'completing-read-default #'vertico--advice)
     (advice-remove #'completing-read-multiple #'vertico--advice)))
 
+;; Emacs 28: Do not show Vertico commands in M-X
+(dolist (sym '(vertico-next vertico-next-group vertico-previous 
vertico-previous-group
+               vertico-scroll-down vertico-scroll-up vertico-exit 
vertico-insert
+               vertico-exit-input vertico-save vertico-first vertico-last))
+  (put sym 'completion-predicate #'vertico--command-p))
+
+(defun vertico--command-p (_sym buffer)
+  "Return non-nil if Vertico is active in BUFFER."
+  (buffer-local-value 'vertico--input buffer))
+
 (provide 'vertico)
 ;;; vertico.el ends here



reply via email to

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