summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorDaniel Mendler <mail@daniel-mendler.de>2021-11-27 11:37:34 +0100
committerDaniel Mendler <mail@daniel-mendler.de>2021-11-27 11:37:34 +0100
commit3c44bff1f6afb9b16e4e5e6c16affe0ca97c0d6b (patch)
tree0c978c3312ef8476e935ae41d407fedf81b2977c
parent9e4651649b5d47d5f74615e1dc8cc0b676e5ff38 (diff)
Minor refactoring
-rw-r--r--cape.el28
1 files changed, 16 insertions, 12 deletions
diff --git a/cape.el b/cape.el
index f1e0404..792306c 100644
--- a/cape.el
+++ b/cape.el
@@ -320,6 +320,18 @@
(completion-in-region beg end table (plist-get extra :predicate))))
(_ (user-error "%s: No completions" capf))))
+(defun cape--noninterruptible-table (table)
+ "Create non-interruptible completion TABLE."
+ (lambda (str pred action)
+ (let (throw-on-input)
+ (complete-with-action action table str pred))))
+
+(defun cape--silent-table (table)
+ "Create a new completion TABLE which is silent (no messages, no errors)."
+ (lambda (str pred action)
+ (cape--silent
+ (complete-with-action action table str pred))))
+
(cl-defun cape--table-with-properties (table &key category (sort t) &allow-other-keys)
"Create completion TABLE with properties.
CATEGORY is the optional completion category.
@@ -836,27 +848,19 @@ The PREDICATE is passed the candidate symbol or string."
;;;###autoload
(defun cape-silent-capf (capf)
- "Return a new CAPF which is silent (no messages, no errors)."
+ "Create a new CAPF which is silent (no messages, no errors)."
(lambda ()
(pcase (cape--silent (funcall capf))
(`(,beg ,end ,table . ,plist)
- `(,beg ,end
- ,(lambda (str pred action)
- (cape--silent
- (complete-with-action action table str pred)))
- ,@plist)))))
+ `(,beg ,end ,(cape--silent-table table) ,@plist)))))
;;;###autoload
(defun cape-noninterruptible-capf (capf)
- "Return a new CAPF which is non-interruptible silent by input."
+ "Create a new CAPF which is non-interruptible silent by input."
(lambda ()
(pcase (let (throw-on-input) (funcall capf))
(`(,beg ,end ,table . ,plist)
- `(,beg ,end
- ,(lambda (str pred action)
- (let (throw-on-input)
- (complete-with-action action table str pred)))
- ,@plist)))))
+ `(,beg ,end ,(cape--noninterruptible-table table) ,@plist)))))
;;;###autoload
(defun cape-interactive-capf (capf)