branch: externals/tempel
commit 699c91d84dd5aac28b478abc73aa7d6beab28852
Author: Daniel Mendler <[email protected]>
Commit: Daniel Mendler <[email protected]>
Remove tempel-trigger-prefix
I want to replace this mechanism with a generic mechanism in the Cape
package,
if possible. Other Capfs which expand the candidate string after completion
like
cape-abbrev would profit from a generic mechanism. Similarly multiple Capfs
combined via cape-capf-super could use a common trigger prefix.
---
CHANGELOG.org | 5 +++++
README.org | 15 ++++-----------
tempel.el | 24 +++---------------------
3 files changed, 12 insertions(+), 32 deletions(-)
diff --git a/CHANGELOG.org b/CHANGELOG.org
index 1a0eb3423b..c19b92d904 100644
--- a/CHANGELOG.org
+++ b/CHANGELOG.org
@@ -2,6 +2,11 @@
#+author: Daniel Mendler
#+language: en
+* Development
+
+- =tempel-trigger-prefix=: Remove feature. The goal is to replace this with a
+ generic mechanism in the Cape package.
+
* Version 1.7 (2025-10-13)
- Require Emacs 29.
diff --git a/README.org b/README.org
index 94eeaafdf9..5e650c44dd 100644
--- a/README.org
+++ b/README.org
@@ -63,10 +63,6 @@ contributions.
#+begin_src emacs-lisp
;; Configure Tempel
(use-package tempel
- ;; Require trigger prefix before template name when completing.
- ;; :custom
- ;; (tempel-trigger-prefix "<")
-
:bind (("M-+" . tempel-complete) ;; Alternative tempel-expand
("M-*" . tempel-insert))
@@ -74,13 +70,10 @@ contributions.
;; Setup completion at point
(defun tempel-setup-capf ()
- ;; Add the Tempel Capf to `completion-at-point-functions'.
- ;; `tempel-expand' only triggers on exact matches. Alternatively use
- ;; `tempel-complete' if you want to see all matches, but then you
- ;; should also configure `tempel-trigger-prefix', such that Tempel
- ;; does not trigger too often when you don't expect it. NOTE: We add
- ;; `tempel-expand' *before* the main programming mode Capf, such
- ;; that it will be tried first.
+ ;; Add the Tempel Capf to `completion-at-point-functions'. `tempel-expand'
+ ;; only triggers on exact matches. Alternatively use `tempel-complete' if
+ ;; you want to see all matches. NOTE: We add `tempel-expand' *before* the
+ ;; main programming mode Capf, such that it will be tried first.
(setq-local completion-at-point-functions
(cons #'tempel-expand
completion-at-point-functions)))
diff --git a/tempel.el b/tempel.el
index 3c23736a11..01ac7e6a25 100644
--- a/tempel.el
+++ b/tempel.el
@@ -63,12 +63,6 @@ The file paths can contain wildcards, e.g.,
directory."
:type '(choice string (repeat string)))
-(defcustom tempel-trigger-prefix nil
- "Trigger string prefixes the template names.
-The trigger prefix must be entered first before the template name to
-trigger completion."
- :type '(choice (const nil) string))
-
(defcustom tempel-mark
#(" " 0 1 (display (space :width (1)) face cursor))
"Field start indicator."
@@ -226,8 +220,6 @@ REGION are the current region bounds."
(sym (intern-soft name))
(template (alist-get sym templates)))
(tempel--delete-word name)
- (when tempel-trigger-prefix
- (tempel--delete-word tempel-trigger-prefix))
(tempel--insert template region)))
(defun tempel--range-modified (ov &rest _)
@@ -678,14 +670,7 @@ TEMPLATES must be a list in the form (modes plist .
templates)."
(defun tempel--prefix-bounds ()
"Return prefix bounds."
- (if tempel-trigger-prefix
- (let ((end (point))
- (beg (save-excursion
- (search-backward tempel-trigger-prefix (pos-bol)
'noerror))))
- (when (and beg (save-excursion
- (not (re-search-backward "\\s-" beg 'noerror))))
- (cons (+ beg (length tempel-trigger-prefix)) end)))
- (bounds-of-thing-at-point 'symbol)))
+ (bounds-of-thing-at-point 'symbol))
;;;###autoload
(defun tempel-expand (&optional interactive)
@@ -701,7 +686,7 @@ command."
(when interactive
(tempel--save))
(if-let ((templates (tempel--templates))
- (bounds (tempel--prefix-bounds))
+ (bounds (bounds-of-thing-at-point 'symbol))
(name (buffer-substring-no-properties
(car bounds) (cdr bounds)))
(sym (intern-soft name))
@@ -735,17 +720,14 @@ Capf, otherwise like an interactive completion command."
;; accept empty input bounds.
(let* ((manually (eq this-command #'tempel-complete))
(region (and manually (tempel--region))))
- (when (and manually tempel-trigger-prefix (not (tempel--prefix-bounds)))
- (insert tempel-trigger-prefix))
(when-let ((templates (tempel--templates))
- (bounds (or (and (not region) (tempel--prefix-bounds))
+ (bounds (or (and (not region) (bounds-of-thing-at-point
'symbol))
(and manually (cons (point) (point))))))
(list (car bounds) (cdr bounds) templates
:category 'tempel
:exclusive 'no
:company-kind (lambda (_) 'snippet)
:exit-function (apply-partially #'tempel--exit templates region)
- :company-prefix-length (and tempel-trigger-prefix t)
:company-doc-buffer
(apply-partially #'tempel--info-buffer templates
(lambda (elts)