Function: tempel-abbrev-mode

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

Signature

(tempel-abbrev-mode &optional ARG)

Documentation

Install Tempel templates as abbrevs.

This is a minor mode. If called interactively, toggle the Tempel-Abbrev mode mode. If the prefix argument is positive, enable the mode, and if it is zero or negative, disable the mode.

If called from Lisp, toggle the mode if ARG is toggle. Enable the mode if ARG is nil, omitted, or is a positive number. Disable the mode if ARG is a negative number.

To check whether the minor mode is enabled in the current buffer, evaluate the variable tempel-abbrev-mode(var)/tempel-abbrev-mode(fun).

The mode's hook is called both when the mode is enabled and when it is disabled.

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
(define-minor-mode tempel-abbrev-mode
  "Install Tempel templates as abbrevs."
  :group 'tempel
  :global nil
  (setq-local abbrev-minor-mode-table-alist
              (assq-delete-all 'tempel-abbrev-mode abbrev-minor-mode-table-alist))
  (when (eq abbrev-minor-mode-table-alist
            (default-value 'abbrev-minor-mode-table-alist))
    (kill-local-variable 'abbrev-minor-mode-table-alist))
  (when tempel-abbrev-mode
    (let ((table (make-abbrev-table))
          (tempel--ignore-condition t))
      (dolist (sym (delete-dups (mapcar #'car (tempel--templates))))
        (let ((hook (make-symbol (symbol-name sym))))
          (fset hook (lambda ()
                       (tempel--delete-word (symbol-name sym))
                       (tempel--insert (alist-get sym (tempel--templates)) nil)
                       t))
          (put hook 'no-self-insert t)
          (define-abbrev table (symbol-name sym) 'Template hook
            :system t :enable-function
            (lambda () (assq sym (tempel--templates))))))
      (setq-local abbrev-minor-mode-table-alist
                  (cons `(tempel-abbrev-mode . ,table)
                        abbrev-minor-mode-table-alist)))))