Function: tempel-complete

tempel-complete is an interactive and natively compiled function defined in tempel.el.

Signature

(tempel-complete &optional INTERACTIVE)

Documentation

Complete template name at point and expand.

This completion-at-point-function (Capf) returns a list of all possible template names, which are then displayed in the completion UI (e.g. Corfu) for selection. See also tempel-expand. If INTERACTIVE is nil the function acts like a Capf, otherwise like an interactive completion command.

Key Bindings

This command is not in any keymaps.

Source Code

;; Defined in /nix/store/b3ibjbs2i12kyhwapibfx6i39f025i85-emacs-packages-deps/share/emacs/site-lisp/elpa/tempel-20260705.1258/tempel.el
;;;###autoload
(defun tempel-complete (&optional interactive)
  "Complete template name at point and expand.
This completion-at-point-function (Capf) returns a list of all
possible template names, which are then displayed in the
completion UI (e.g. Corfu) for selection.  See also
`tempel-expand'.  If INTERACTIVE is nil the function acts like a
Capf, otherwise like an interactive completion command."
  (interactive (list t))
  (if interactive
      (let ((completion-at-point-functions (list #'tempel-complete))
            completion-cycle-threshold)
        (tempel--save)
        (unless (completion-at-point)
          (user-error "tempel-complete: No matching templates")))
    ;; Use the marked region for template insertion if triggered manually.
    (let ((region (and (eq this-command #'tempel-complete) (tempel--region))))
      (when-let* ((templates (tempel--templates))
                  (bounds (or (and (not region)
                                   (tempel--prefix-bounds templates))
                              (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-doc-buffer
              (apply-partially #'tempel--info-buffer templates
                               (lambda (template)
                                 (insert (tempel--print-template template))
                                 (tempel--insert-doc template)
                                 (current-buffer)))
              :company-location
              (apply-partially #'tempel--info-buffer templates
                               (lambda (template)
                                 (pp (cl-loop for x in template
                                              until (keywordp x) collect x)
                                     (current-buffer))
                                 (tempel--insert-doc template)
                                 (list (current-buffer))))
              :annotation-function
              (when tempel-complete-annotation
                (apply-partially #'tempel--annotate
                                 templates tempel-complete-annotation " ")))))))