[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[elpa] externals/cape bee13e568d: Add cape-capf-inside-faces (Fix #96)
From: |
ELPA Syncer |
Subject: |
[elpa] externals/cape bee13e568d: Add cape-capf-inside-faces (Fix #96) |
Date: |
Sun, 22 Oct 2023 09:57:45 -0400 (EDT) |
branch: externals/cape
commit bee13e568d42ffec9010fbf795e8f942973da174
Author: Daniel Mendler <mail@daniel-mendler.de>
Commit: Daniel Mendler <mail@daniel-mendler.de>
Add cape-capf-inside-faces (Fix #96)
---
CHANGELOG.org | 1 +
README.org | 1 +
cape.el | 12 ++++++++++++
3 files changed, 14 insertions(+)
diff --git a/CHANGELOG.org b/CHANGELOG.org
index 033c4f9278..40de742171 100644
--- a/CHANGELOG.org
+++ b/CHANGELOG.org
@@ -7,6 +7,7 @@
- =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-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.
- Rename =cape-symbol= to =cape-elisp-symbol=.
diff --git a/README.org b/README.org
index b26f9bc4db..4f60e4acaf 100644
--- a/README.org
+++ b/README.org
@@ -265,6 +265,7 @@ the Capf transformers with =defalias= to a function symbol.
- ~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.
+- ~cape-wrap-inside-faces~, ~cape-capf-inside-faces~: Ensure that Capf
triggers only inside text with certain faces.
- ~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
diff --git a/cape.el b/cape.el
index e666bd88eb..fa4b43f53c 100644
--- a/cape.el
+++ b/cape.el
@@ -1060,6 +1060,16 @@ If the prefix is long enough, enforce auto completion."
:company-prefix-length t
,@plist)))))
+;;;###autoload
+(defun cape-wrap-inside-faces (capf &rest faces)
+ "Call CAPF only if inside FACES.
+This function can be used as an advice around an existing Capf."
+ (when-let ((fs (get-text-property (point) 'face))
+ ((if (listp fs)
+ (cl-loop for f in fs thereis (memq f faces))
+ (memq fs faces))))
+ (funcall capf)))
+
;;;###autoload
(defun cape-wrap-inside-comment (capf)
"Call CAPF only if inside comment.
@@ -1117,6 +1127,8 @@ This function can be used as an advice around an existing
Capf."
(cape--capf-wrapper debug)
;;;###autoload (autoload 'cape-capf-inside-comment "cape")
(cape--capf-wrapper inside-comment)
+;;;###autoload (autoload 'cape-capf-inside-faces "cape")
+(cape--capf-wrapper inside-faces)
;;;###autoload (autoload 'cape-capf-inside-string "cape")
(cape--capf-wrapper inside-string)
;;;###autoload (autoload 'cape-capf-super "cape")
[Prev in Thread] |
Current Thread |
[Next in Thread] |
- [elpa] externals/cape bee13e568d: Add cape-capf-inside-faces (Fix #96),
ELPA Syncer <=