org-mode, I use easy templates a lot. But I also use
company-mode and easy templates are not listed there, even though I've managed to add support for some of the
org-mode keywords (see here). Does anyone know how to achieve this?
You could add your own completion function to
completion-at-point-functions and add
(defun org-easy-template--completion-table (str pred action) (pcase action (`nil (try-completion str org-structure-template-alist pred)) (`t (all-completions str org-structure-template-alist pred)))) (defun org-easy-template--annotation-function (s) (format " -> %s" (cadr (assoc s org-structure-template-alist)))) (defun org-easy-template-completion-function () (when (looking-back "^[ \t]*<\\([^ \t]*\\)" (point-at-bol)) (list (match-beginning 1) (point) 'org-easy-template--completion-table :annotation-function 'org-easy-template--annotation-function :exclusive 'no))) (defun add-easy-templates-to-capf () (add-hook 'completion-at-point-functions 'org-easy-template-completion-function nil t)) (add-hook 'org-mode-hook #'add-easy-templates-to-capf)
Since I'haven't seen a direct answer to my question yet, here's a workaround using
yasnippet: simply define a snippet for every easy template.
- Insert name, key, and content like this:
# -*- mode: snippet -*- # name: latex export # key: l_ # -- #+BEGIN_EXPORT latex $0 #+END_EXPORT
- Store it in
One could also use the key
<l instead of
l_, but this doesn't play well together with