[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[elpa] externals/cape 25591ef5a2: Add cape-capf-prefix-length (Fix #33)
From: |
ELPA Syncer |
Subject: |
[elpa] externals/cape 25591ef5a2: Add cape-capf-prefix-length (Fix #33) |
Date: |
Sun, 27 Mar 2022 14:57:17 -0400 (EDT) |
branch: externals/cape
commit 25591ef5a2bd0acefb2ca82a610c24909ae7a2ba
Author: Daniel Mendler <mail@daniel-mendler.de>
Commit: Daniel Mendler <mail@daniel-mendler.de>
Add cape-capf-prefix-length (Fix #33)
---
README.org | 1 +
cape.el | 16 ++++++++++++++--
2 files changed, 15 insertions(+), 2 deletions(-)
diff --git a/README.org b/README.org
index 6c50dd12c9..15383d74d9 100644
--- a/README.org
+++ b/README.org
@@ -222,6 +222,7 @@ achieve a similarly refreshing strategy.
- ~cape-wrap-case-fold~, ~cape-capf-case-fold~: Create a Capf which is case
insensitive.
- ~cape-wrap-properties~, ~cape-capf-properties~: Add completion properties to
a Capf.
- ~cape-wrap-predicate~, ~cape-capf-predicate~: Add candidate predicate to a
Capf.
+- ~cape-wrap-prefix-length~, ~cape-capf-prefix-length~: Enforce a minimal
prefix length.
* Contributions
diff --git a/cape.el b/cape.el
index a016b62774..29465800a7 100644
--- a/cape.el
+++ b/cape.el
@@ -74,8 +74,8 @@ If t, check all other buffers (subject to dabbrev ignore
rules).
Any other non-nil value only checks some other buffers, as per
`dabbrev-select-buffers-function'."
:type '(choice (const :tag "off" nil)
- (const :tag "some" 'some)
- (other :tag "all" t)))
+ (const :tag "some" 'some)
+ (other :tag "all" t)))
(defcustom cape-file-directory-must-exist t
"The parent directory must exist for file completion."
@@ -1066,6 +1066,17 @@ If DONT-FOLD is non-nil return a case sensitive table
instead."
(`(,beg ,end ,table . ,plist)
`(,beg ,end ,(cape--noninterruptible-table table) ,@plist))))
+;;;###autoload
+(defun cape-wrap-prefix-length (capf length)
+ "Call CAPF and ensure that prefix length is greater or equal than LENGTH.
+If the prefix is long enough, enforce auto completion."
+ (pcase (funcall capf)
+ (`(,beg ,end ,table . ,plist)
+ (when (>= (- end beg) length)
+ `(,beg ,end ,table
+ :company-prefix-length t
+ ,@plist)))))
+
;;;###autoload
(defun cape-wrap-purify (capf)
"Call CAPF and ensure that it does not modify the buffer."
@@ -1102,6 +1113,7 @@ If DONT-FOLD is non-nil return a case sensitive table
instead."
(cape--capf-wrapper properties)
(cape--capf-wrapper buster)
(cape--capf-wrapper purify)
+(cape--capf-wrapper prefix-length)
(provide 'cape)
;;; cape.el ends here
[Prev in Thread] |
Current Thread |
[Next in Thread] |
- [elpa] externals/cape 25591ef5a2: Add cape-capf-prefix-length (Fix #33),
ELPA Syncer <=