summaryrefslogtreecommitdiff
path: root/README.org
diff options
context:
space:
mode:
authorDaniel Mendler <mail@daniel-mendler.de>2022-12-23 19:19:43 +0100
committerDaniel Mendler <mail@daniel-mendler.de>2022-12-23 19:38:32 +0100
commit9b97dbbc7624415ee25f79de9ea357feb1e2e547 (patch)
tree8ea0c0acd1e467c74797749cb32aff707537860e /README.org
parent80d051389e3cc49367435f7b5d292d45c529ab49 (diff)
Add cape-capf-inside-string and cape-capf-inside-comment
These utilties can be used to tie a Capf to a certain context. There exist multiple ways you can organize your `completion-at-point-functions'. The main programming mode Capf can come first in the list. Then subsequent auxiliary Capfs will only take over if the main Capf bails out. Sometimes the main Capf is exclusive and never bails out. You could then turn it non-exclusive with `cape-capf-nonexclusive'. Alternatively you could move the auxiliary Capfs before the main Capf. Then you could use the `cape-capf-inside-*' helpers to make the auxiliary Capfs less aggressive, such that they trigger only inside comments or strings. There is no silver bullet here and the setup depends highly on the mode. These Capf transformers are just meant to give you flexible tools at hand such that you can build the completion pipeline which works best for you. (There has been some prior discussion about context dependent Capfs and predicates a long time ago in #9 and #11, but the addition of this feature got actually inspired by @LuigiPiucco's Doom PR.)
Diffstat (limited to 'README.org')
-rw-r--r--README.org9
1 files changed, 5 insertions, 4 deletions
diff --git a/README.org b/README.org
index c6d6474..aa853aa 100644
--- a/README.org
+++ b/README.org
@@ -100,7 +100,7 @@ could be upstreamed into Emacs itself.
)
#+end_src
-* Experimental features
+* CAPF adapters and transformers
** Company adapter
/Wrap your Company backend in a Cape and turn it into a Capf!/
@@ -219,7 +219,7 @@ achieve a similarly refreshing strategy.
(list (cape-capf-buster #'some-caching-capf)))
#+end_src
-** Other Capf transformers
+** Capf transformers
Cape provides a set of additional Capf transformation functions, which are
mostly meant to used by experts to fine tune the Capf behavior and Capf
@@ -236,8 +236,9 @@ the Capf transformers with =defalias= to a function symbol.
- ~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.
+- ~cape-wrap-prefix-length~, ~cape-capf-prefix-length~: Enforce a minimal prefix length.
+- ~cape-wrap-inside-comment~, ~cape-capf-inside-comment~: Ensure that Capf triggers only inside comment.
+- ~cape-wrap-inside-string~, ~cape-capf-inside-string~: Ensure that Capf triggers only inside a string literal.
In the following we show a few example configurations, which have come up on the
[[https://github.com/minad/cape/issues][Cape]] or [[https://github.com/minad/corfu/issues][Corfu issue tracker]] or the [[https://github.com/minad/corfu/wiki][Corfu wiki.]] I use some of these tweaks in my