branch: externals/tempel
commit 6c288c32a2cbbc8233fe86a6fde3a12a827df815
Author: Daniel Mendler <[email protected]>
Commit: Daniel Mendler <[email protected]>

    README: Document Capf setup (Fix #14)
---
 README.org | 14 ++++++++++++++
 1 file changed, 14 insertions(+)

diff --git a/README.org b/README.org
index 16429e2599..7ac6f76f58 100644
--- a/README.org
+++ b/README.org
@@ -56,6 +56,20 @@ and has to be installed manually with ~package-install-file~.
     :bind (("M-+" . tempel-complete) ;; Alternative tempel-expand
            ("M-*" . tempel-insert))
     :init
+
+    ;; Setup completion at point
+    (defun tempel-setup-capf ()
+      ;; Add the Tempel Capf to `completion-at-point-functions'.
+      ;; The depth is set to -1, such that `tempel-expand' is tried *before* 
the
+      ;; programming mode Capf. If a template name can be completed it takes
+      ;; precedence over the programming mode completion. `tempel-expand' only
+      ;; triggers on exact matches. Alternatively use `tempel-complete' if you
+      ;; want to see all matches, but then Tempel will probably trigger too
+      ;; often when you don't expect it.
+      (add-hook 'completion-at-point-functions #'tempel-expand -1 'local))
+    (add-hook 'prog-mode-hook 'tempel-setup-capf)
+    (add-hook 'text-mode-hook 'tempel-setup-capf)
+
     ;; Optionally make the Tempel templates available to Abbrev,
     ;; either locally or globally. `expand-abbrev' is bound to C-x '.
     ;; (add-hook 'prog-mode-hook #'tempel-abbrev-mode)

Reply via email to