summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorDaniel Mendler <mail@daniel-mendler.de>2023-10-29 10:40:32 +0100
committerDaniel Mendler <mail@daniel-mendler.de>2023-10-29 10:52:38 +0100
commite0a05483cfd8f90189dfde0d7e1ffe0217e6317d (patch)
tree8b69fb0748e71442fd5e2ce4fb7900c759d4fc35
parent0e14d8bcac6ee324d1fc2164b5d501ce966e93b5 (diff)
Add cape-capf-passthrough to disable completion style filtering
This Capf transformer can be useful in rare scenarios like debugging or when the wrapped Capf wants to completely control filtering, without any interference from outer completion styles. For example `cape-capf-passthrough` can be useful in combination with `cape-company-to-capf`, such that filtering is completely left to the Company backend. A special case discussed recently with @dgutov involves `company-dabbrev` which nowadays uses completion styles itself for its internal filtering, where double filtering can be avoided via `cape-capf-passthrough`, see company-mode/company-mode/pull/1215.
-rw-r--r--CHANGELOG.org2
-rw-r--r--README.org3
-rw-r--r--cape.el14
3 files changed, 18 insertions, 1 deletions
diff --git a/CHANGELOG.org b/CHANGELOG.org
index 40de742..86789d8 100644
--- a/CHANGELOG.org
+++ b/CHANGELOG.org
@@ -7,6 +7,8 @@
- =cape-emoji=: New Capf available on Emacs 29 and newer.
- =cape-wrap-debug=, =cape-capf-debug=: New Capf transformers to add debug messages
to a Capf.
+- =cape-wrap-passthrough=, =cape-capf-passthrough=: New Capf transformers to defeat
+ completion style filtering.
- =cape-capf-inside-faces=, =cape-wrap-inside-faces=: New transformer
- Rename =cape-super-capf= to =cape-capf-super=. Add =cape-wrap-super= for consistency
with other Capf combinators.
diff --git a/README.org b/README.org
index 4f60e4a..87dc824 100644
--- a/README.org
+++ b/README.org
@@ -260,8 +260,9 @@ the Capf transformers with =defalias= to a function symbol.
- ~cape-wrap-nonexclusive~, ~cape-capf-nonexclusive:~ Mark Capf as non-exclusive.
- ~cape-wrap-noninterruptible~, ~cape-capf-noninterruptible:~ Protect a Capf which does not like to be interrupted.
- ~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-passthrough~, ~cape-capf-passthrough~: Defeat entire completion style filtering.
- ~cape-wrap-predicate~, ~cape-capf-predicate~: Add candidate predicate to a Capf.
+- ~cape-wrap-properties~, ~cape-capf-properties~: Add completion properties to a Capf.
- ~cape-wrap-prefix-length~, ~cape-capf-prefix-length~: Enforce a minimal prefix length.
- ~cape-wrap-super~, ~cape-capf-super~: Merge multiple Capfs into a Super-Capf.
- ~cape-wrap-inside-comment~, ~cape-capf-inside-comment~: Ensure that Capf triggers only inside comment.
diff --git a/cape.el b/cape.el
index 54a9ba4..8de9436 100644
--- a/cape.el
+++ b/cape.el
@@ -187,6 +187,11 @@ BODY is the wrapping expression."
(cape--wrapped-table cape--accept-all-table
(or (eq action 'lambda))))
+(defun cape--passthrough-table (table)
+ "Create completion TABLE disabling any filtering."
+ (cape--wrapped-table cape--passthrough-table
+ (let (completion-ignore-case completion-regexp-list (_ (setq str ""))))))
+
(defun cape--noninterruptible-table (table)
"Create non-interruptible completion TABLE."
(cape--wrapped-table cape--noninterruptible-table
@@ -987,6 +992,13 @@ completion table is refreshed on every input change."
,@plist))))
;;;###autoload
+(defun cape-wrap-passthrough (capf)
+ "Call CAPF and make sure that no completion style filtering takes place."
+ (pcase (funcall capf)
+ (`(,beg ,end ,table . ,plist)
+ `(,beg ,end ,(cape--passthrough-table table) ,@plist))))
+
+;;;###autoload
(defun cape-wrap-properties (capf &rest properties)
"Call CAPF and add additional completion PROPERTIES.
Completion properties include for example :exclusive, :annotation-function and
@@ -1139,6 +1151,8 @@ This function can be used as an advice around an existing Capf."
(cape--capf-wrapper noninterruptible)
;;;###autoload (autoload 'cape-capf-nonexclusive "cape")
(cape--capf-wrapper nonexclusive)
+;;;###autoload (autoload 'cape-capf-passthrough "cape")
+(cape--capf-wrapper passthrough)
;;;###autoload (autoload 'cape-capf-predicate "cape")
(cape--capf-wrapper predicate)
;;;###autoload (autoload 'cape-capf-prefix-length "cape")