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

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

[elpa] externals/tempel 5dbdc76eb2 74/82: Specify the completion categor


From: ELPA Syncer
Subject: [elpa] externals/tempel 5dbdc76eb2 74/82: Specify the completion category tempel
Date: Sun, 9 Jan 2022 20:58:46 -0500 (EST)

branch: externals/tempel
commit 5dbdc76eb22a7d34bfcd7e0e4ada9abb8dee2280
Author: Daniel Mendler <mail@daniel-mendler.de>
Commit: Daniel Mendler <mail@daniel-mendler.de>

    Specify the completion category tempel
---
 tempel.el | 14 ++++++++++++--
 1 file changed, 12 insertions(+), 2 deletions(-)

diff --git a/tempel.el b/tempel.el
index d35de96042..f3b5cd7e65 100644
--- a/tempel.el
+++ b/tempel.el
@@ -415,6 +415,14 @@ PROMPT is the optional prompt/default value."
     (tempel--save)
     (or (completion-at-point) (user-error "%s: No completions" capf))))
 
+(defun tempel--completion-table (templates)
+  "Return a completion table for a list of TEMPLATES.
+The completion table specifies the category `tempel'."
+  (lambda (str pred action)
+    (if (eq action 'metadata)
+        '(metadata (category . tempel))
+      (complete-with-action action templates str pred))))
+
 ;;;###autoload
 (defun tempel-expand (&optional interactive)
   "Expand exactly matching template name at point.
@@ -429,7 +437,8 @@ If INTERACTIVE is nil the function acts like a capf."
                 (sym (intern-soft name))
                 (template (assq sym templates)))
       (setq templates (list template))
-      (list (car bounds) (cdr bounds) templates
+      (list (car bounds) (cdr bounds)
+            (tempel--completion-table templates)
             :exclusive 'no
             :exit-function (apply-partially #'tempel--exit templates nil)))))
 
@@ -444,7 +453,8 @@ If INTERACTIVE is nil the function acts like a capf."
       (let* ((region (tempel--region))
              (bounds (or (and (not region) (bounds-of-thing-at-point 'symbol))
                          (cons (point) (point)))))
-        (list (car bounds) (cdr bounds) templates
+        (list (car bounds) (cdr bounds)
+              (tempel--completion-table templates)
               :exclusive 'no
               :company-kind (lambda (_) 'snippet)
               :exit-function (apply-partially #'tempel--exit templates region)



reply via email to

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