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

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

[elpa] externals/cape e0a05483cf 2/4: Add cape-capf-passthrough to disab


From: ELPA Syncer
Subject: [elpa] externals/cape e0a05483cf 2/4: Add cape-capf-passthrough to disable completion style filtering
Date: Sun, 29 Oct 2023 06:57:36 -0400 (EDT)

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

    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.
---
 CHANGELOG.org |  2 ++
 README.org    |  3 ++-
 cape.el       | 14 ++++++++++++++
 3 files changed, 18 insertions(+), 1 deletion(-)

diff --git a/CHANGELOG.org b/CHANGELOG.org
index 40de742171..86789d8f01 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 4f60e4acaf..87dc824225 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 54a9ba4696..8de943623a 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
@@ -986,6 +991,13 @@ completion table is refreshed on every input change."
             (complete-with-action action table str pred)))
        ,@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.
@@ -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")



reply via email to

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