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

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

[elpa] externals/cape d3d9d926ac 082/146: Add cape-interactive-capf


From: ELPA Syncer
Subject: [elpa] externals/cape d3d9d926ac 082/146: Add cape-interactive-capf
Date: Sun, 9 Jan 2022 20:57:44 -0500 (EST)

branch: externals/cape
commit d3d9d926ac7e860bd5e919f924abcd76f3fca790
Author: Daniel Mendler <mail@daniel-mendler.de>
Commit: Daniel Mendler <mail@daniel-mendler.de>

    Add cape-interactive-capf
---
 README.org |  1 +
 cape.el    | 25 ++++++++++++++++---------
 2 files changed, 17 insertions(+), 9 deletions(-)

diff --git a/README.org b/README.org
index ea7a624e04..44ca3b1770 100644
--- a/README.org
+++ b/README.org
@@ -125,4 +125,5 @@ achieve a similarly refreshing strategy.
 ** Other Capf transformers
 
 - ~cape-silent-capf~: Wrap a chatty Capf and silence it.
+- ~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 23140e2122..f63e6c66b4 100644
--- a/cape.el
+++ b/cape.el
@@ -316,7 +316,7 @@
   "Return bounds of THING."
   (or (bounds-of-thing-at-point thing) (cons (point) (point))))
 
-(defun cape--complete (capf)
+(defun cape--interactive (capf)
   "Complete with CAPF."
   (pcase (funcall capf)
     (`(,beg ,end ,table . ,extra)
@@ -380,7 +380,7 @@ If INTERACTIVE is nil the function acts like a capf."
   (interactive (list t))
   (if interactive
       (let (cape-file-directory-must-exist)
-        (cape--complete #'cape-file))
+        (cape--interactive #'cape-file))
     (let* ((bounds (cape--bounds 'filename))
            (file (buffer-substring (car bounds) (cdr bounds))))
       (when (or (not cape-file-directory-must-exist)
@@ -422,7 +422,7 @@ If INTERACTIVE is nil the function acts like a capf."
 If INTERACTIVE is nil the function acts like a capf."
   (interactive (list t))
   (if interactive
-      (cape--complete #'cape-symbol)
+      (cape--interactive #'cape-symbol)
     (let ((bounds (cape--bounds 'symbol)))
       `(,(car bounds) ,(cdr bounds)
         ,(cape--table-with-properties obarray :category 'symbol)
@@ -447,7 +447,7 @@ If INTERACTIVE is nil the function acts like a capf."
   (interactive (list t))
   (if interactive
       (let ((cape-dabbrev-min-length 0))
-        (cape--complete #'cape-dabbrev))
+        (cape--interactive #'cape-dabbrev))
     (require 'dabbrev)
     (cape--dabbrev-reset)
     (let ((abbrev (ignore-errors (dabbrev--abbrev-at-point))) beg end)
@@ -498,7 +498,7 @@ If INTERACTIVE is nil the function acts like a capf."
 If INTERACTIVE is nil the function acts like a capf."
   (interactive (list t))
   (if interactive
-      (cape--complete #'cape-ispell)
+      (cape--interactive #'cape-ispell)
     (let ((bounds (cape--bounds 'word)))
       `(,(car bounds) ,(cdr bounds)
         ,(cape--table-with-properties
@@ -527,7 +527,7 @@ If INTERACTIVE is nil the function acts like a capf."
 If INTERACTIVE is nil the function acts like a capf."
   (interactive (list t))
   (if interactive
-      (cape--complete #'cape-dict)
+      (cape--interactive #'cape-dict)
     (let ((bounds (cape--bounds 'word)))
       `(,(car bounds) ,(cdr bounds)
         ,(cape--table-with-properties (cape--dict-words) :category 'cape-dict)
@@ -559,7 +559,7 @@ If INTERACTIVE is nil the function acts like a capf."
 If INTERACTIVE is nil the function acts like a capf."
   (interactive (list t))
   (if interactive
-      (cape--complete #'cape-abbrev)
+      (cape--interactive #'cape-abbrev)
     (when-let (abbrevs (cape--abbrev-list))
       (let ((bounds (cape--bounds 'symbol)))
         `(,(car bounds) ,(cdr bounds)
@@ -582,7 +582,7 @@ If INTERACTIVE is nil the function acts like a capf."
 If INTERACTIVE is nil the function acts like a capf."
   (interactive (list t))
   (if interactive
-      (cape--complete #'cape-keyword)
+      (cape--interactive #'cape-keyword)
     (when-let (keywords (cape--keyword-list))
       (let ((bounds (cape--bounds 'symbol)))
         `(,(car bounds) ,(cdr bounds)
@@ -745,7 +745,7 @@ VALID is the input comparator, see `cape--input-valid-p'."
 If INTERACTIVE is nil the function acts like a capf."
   (interactive (list t))
   (if interactive
-      (cape--complete #'cape-line)
+      (cape--interactive #'cape-line)
     `(,(line-beginning-position) ,(point)
       ,(cape--table-with-properties (cape--line-list) :sort nil)
       ,@cape--line-properties)))
@@ -771,5 +771,12 @@ and the various :company-* extensions."
                  (cape--silent (complete-with-action action table str pred)))
               ,@plist)))))
 
+;;;###autoload
+(defun cape-interactive-capf (capf)
+  "Create interactive completion function from CAPF."
+  (lambda (&optional interactive)
+    (interactive (list t))
+    (if interactive (cape--interactive capf) (funcall capf))))
+
 (provide 'cape)
 ;;; cape.el ends here



reply via email to

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