branch: externals/cape
commit eff4f34841d47f5322727992956e59cab39d8a56
Author: Daniel Mendler <[email protected]>
Commit: Daniel Mendler <[email protected]>
Add cape-noninterruptible-capf
---
README.org | 1 +
cape.el | 11 +++++++++++
2 files changed, 12 insertions(+)
diff --git a/README.org b/README.org
index 44ca3b1770..99c129b8e1 100644
--- a/README.org
+++ b/README.org
@@ -125,5 +125,6 @@ achieve a similarly refreshing strategy.
** Other Capf transformers
- ~cape-silent-capf~: Wrap a chatty Capf and silence it.
+- ~cape-noninterruptible-capf~: Protect a Capf which does not like to be
interrupted.
- ~cape-interactive-capf~: Create a Capf which can be called interactively.
- ~cape-capf-with-properties~: Add completion properties to a Capf.
diff --git a/cape.el b/cape.el
index 9db9945b67..d38e29c6f9 100644
--- a/cape.el
+++ b/cape.el
@@ -776,6 +776,17 @@ completion :category symbol can be specified."
(cape--silent (complete-with-action action table str pred)))
,@plist)))))
+;;;###autoload
+(defun cape-noninterruptible-capf (capf)
+ "Return 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)))))
+
;;;###autoload
(defun cape-interactive-capf (capf)
"Create interactive completion function from CAPF."