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

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

[elpa] externals/cape 1d72f84b64 046/146: Add cape-capf-with-properties


From: ELPA Syncer
Subject: [elpa] externals/cape 1d72f84b64 046/146: Add cape-capf-with-properties and cape-silent-capf
Date: Sun, 9 Jan 2022 20:57:41 -0500 (EST)

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

    Add cape-capf-with-properties and cape-silent-capf
---
 cape.el | 25 +++++++++++++++++++++++++
 1 file changed, 25 insertions(+)

diff --git a/cape.el b/cape.el
index 13f3026129..8a8298f12e 100644
--- a/cape.el
+++ b/cape.el
@@ -669,5 +669,30 @@ The CMP argument determines how the new input is compared 
to the old input.
              ('equal (equal old-input new-input))
              ('substring (string-match-p (regexp-quote old-input) 
new-input))))))
 
+(defun cape-capf-with-properties (capf &rest properties)
+  "Return a new CAPF with additional completion PROPERTIES.
+Completion properties include for example :exclusive, :annotation-function
+and the various :company-* extensions."
+  (lambda ()
+    (pcase (funcall capf)
+      (`(,beg ,end ,table . ,plist)
+       `(,beg ,end ,table ,@properties ,@plist)))))
+
+(defmacro cape--silent (&rest body)
+  "Silence BODY."
+  `(cl-letf ((inhibit-message t)
+             ((symbol-function #'minibuffer-message) #'ignore))
+     (ignore-errors ,@body)))
+
+(defun cape-silent-capf (capf)
+  "Return a new CAPF which is silent (no messages, no errors)."
+  (lambda ()
+    (pcase (cape--silent (funcall capf))
+      (`(,beg ,end ,table . ,plist)
+       `(,beg ,end
+              ,(lambda (str pred action)
+                 (cape--silent (complete-with-action action table str pred)))
+              ,@plist)))))
+
 (provide 'cape)
 ;;; cape.el ends here



reply via email to

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