[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[elpa] externals/embark 8c6bbad: New function: completion table with giv
From: |
ELPA Syncer |
Subject: |
[elpa] externals/embark 8c6bbad: New function: completion table with given category and no sorting |
Date: |
Sat, 18 Dec 2021 21:57:20 -0500 (EST) |
branch: externals/embark
commit 8c6bbad170947ea993ba91864a854c97267e895c
Author: Omar Antolín <omar.antolin@gmail.com>
Commit: Omar Antolín <omar.antolin@gmail.com>
New function: completion table with given category and no sorting
This appeared twice in different spots.
I still kept the embark--read-from-history function because it factors
other common behavior: requiring a match and not recording history.
---
embark.el | 24 ++++++++++++------------
1 file changed, 12 insertions(+), 12 deletions(-)
diff --git a/embark.el b/embark.el
index b3acb94..1c1ccea 100644
--- a/embark.el
+++ b/embark.el
@@ -1221,6 +1221,16 @@ If NESTED is non-nil subkeymaps are not flattened."
collect (cons formatted item))))
(cons candidates def)))
+(defun embark--with-category (category candidates)
+ "Return completion table for CANDIDATES of CATEGORY with sorting disabled."
+ (lambda (string predicate action)
+ (if (eq action 'metadata)
+ `(metadata (display-sort-function . identity)
+ (cycle-sort-function . identity)
+ (category . ,category))
+ (complete-with-action
+ action candidates string predicate))))
+
(defun embark-completing-read-prompter (keymap update &optional no-default)
"Prompt via completion for a command bound in KEYMAP.
If NO-DEFAULT is t, no default value is passed to`completing-read'.
@@ -1270,12 +1280,7 @@ UPDATE function is passed to it."
(make-composed-keymap map (current-local-map)))))
(completing-read
"Command: "
- (lambda (string predicate action)
- (if (eq action 'metadata)
- `(metadata (category . embark-keybinding)
- (display-sort-function . identity)
- (cycle-sort-function . identity))
- (complete-with-action action candidates string predicate)))
+ (embark--with-category 'embark-keybinding candidates)
nil nil nil 'embark--prompter-history def)))))
(pcase (assoc choice candidates)
(`(,_formatted ,_name ,cmd ,key ,_desc)
@@ -3336,12 +3341,7 @@ When called with a prefix argument OTHER-WINDOW, open
dired in other window."
"Read with completion from list of history CANDIDATES of CATEGORY.
Sorting and history are disabled. PROMPT is the prompt message."
(completing-read prompt
- (lambda (string predicate action)
- (if (eq action 'metadata)
- `(metadata (display-sort-function . identity)
- (cycle-sort-function . identity)
- (category . ,category))
- (complete-with-action action candidates string
predicate)))
+ (embark--with-category category candidates)
nil t nil t))
(defun embark-kill-ring-remove (text)
[Prev in Thread] |
Current Thread |
[Next in Thread] |
- [elpa] externals/embark 8c6bbad: New function: completion table with given category and no sorting,
ELPA Syncer <=