summaryrefslogtreecommitdiff
path: root/cape.el
diff options
context:
space:
mode:
authorDaniel Mendler <mail@daniel-mendler.de>2023-10-22 13:45:01 +0200
committerDaniel Mendler <mail@daniel-mendler.de>2023-10-22 13:57:14 +0200
commitbee13e568d42ffec9010fbf795e8f942973da174 (patch)
tree7d76a279f6d559ff03f45b58415ee319c2abcb96 /cape.el
parent116063b9ee912cbaa7318dbe6597ade4a62b3f59 (diff)
Add cape-capf-inside-faces (Fix #96)
Diffstat (limited to 'cape.el')
-rw-r--r--cape.el12
1 files changed, 12 insertions, 0 deletions
diff --git a/cape.el b/cape.el
index e666bd8..fa4b43f 100644
--- a/cape.el
+++ b/cape.el
@@ -1061,6 +1061,16 @@ If the prefix is long enough, enforce auto completion."
,@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.
This function can be used as an advice around an existing Capf."
@@ -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")