[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[elpa] externals/ivy-avy e005666 1/2: Support Emacs 28 read-extended-com
From: |
Basil L. Contovounesios |
Subject: |
[elpa] externals/ivy-avy e005666 1/2: Support Emacs 28 read-extended-command-predicate |
Date: |
Tue, 9 Mar 2021 13:46:06 -0500 (EST) |
branch: externals/ivy-avy
commit e005666df39ca767e6d5ab71b1a55d8c08395259
Author: Basil L. Contovounesios <contovob@tcd.ie>
Commit: Basil L. Contovounesios <contovob@tcd.ie>
Support Emacs 28 read-extended-command-predicate
* counsel.el (counsel--M-x-externs-predicate)
(counsel--M-x-make-predicate): New functions.
(counsel-M-x): Use them as :predicates.
---
counsel.el | 25 +++++++++++++++++++------
1 file changed, 19 insertions(+), 6 deletions(-)
diff --git a/counsel.el b/counsel.el
index b8cf043..fe48bac 100644
--- a/counsel.el
+++ b/counsel.el
@@ -881,6 +881,23 @@ packages are, in order of precedence, `amx' and `smex'."
(smex-update))
smex-ido-cache)))
+(defun counsel--M-x-externs-predicate (cand)
+ "Return non-nil if `counsel-M-x' should complete CAND.
+CAND is a string returned by `counsel--M-x-externs'."
+ (not (get (intern cand) 'no-counsel-M-x)))
+
+(defun counsel--M-x-make-predicate ()
+ "Return a predicate for `counsel-M-x' in the current buffer."
+ (defvar read-extended-command-predicate)
+ (let ((buf (current-buffer)))
+ (lambda (sym)
+ (and (commandp sym)
+ (not (get sym 'byte-obsolete-info))
+ (not (get sym 'no-counsel-M-x))
+ (or (not (bound-and-true-p read-extended-command-predicate))
+ (and (functionp read-extended-command-predicate)
+ (funcall read-extended-command-predicate sym buf)))))))
+
(defun counsel--M-x-prompt ()
"String for `M-x' plus the string representation of `current-prefix-arg'."
(concat (cond ((null current-prefix-arg)
@@ -926,12 +943,8 @@ when available, in that order of precedence."
(let ((externs (counsel--M-x-externs)))
(ivy-read (counsel--M-x-prompt) (or externs obarray)
:predicate (if externs
- (lambda (x)
- (not (get (intern x) 'no-counsel-M-x)))
- (lambda (sym)
- (and (commandp sym)
- (not (get sym 'byte-obsolete-info))
- (not (get sym 'no-counsel-M-x)))))
+ #'counsel--M-x-externs-predicate
+ (counsel--M-x-make-predicate))
:require-match t
:history 'counsel-M-x-history
:action #'counsel-M-x-action
[Prev in Thread] |
Current Thread |
[Next in Thread] |
- [elpa] externals/ivy-avy e005666 1/2: Support Emacs 28 read-extended-command-predicate,
Basil L. Contovounesios <=