I'm trying to load the yasnippets
for the LaTeX
mode every time I open an org
file.
Is it possible? How can this be achieved?
Emacs Stack Exchange is a question and answer site for those using, extending or developing Emacs. It only takes a minute to sign up.
Sign up to join this communityI'm trying to load the yasnippets
for the LaTeX
mode every time I open an org
file.
Is it possible? How can this be achieved?
You can load an additional modes via yas-activate-extra-mode
in the hook of the major mode (it also works with yas-global-mode
turned on).
Just copy-paste following elisp snippet into your init file:
(defun my-org-latex-yas ()
"Activate org and LaTeX yas expansion in org-mode buffers."
(yas-minor-mode)
(yas-activate-extra-mode 'latex-mode))
(add-hook 'org-mode-hook #'my-org-latex-yas)
Tested with:
You can see what the yasnippet repo has to say about this.
Basically, if you put a .yas-parents
file (yes, a hidden file) inside your snippets/org-mode/
directory and as the content of said file you put latex-mode
the latex snippets will also be available in org-mode. This approach does not require any lisp and it is very simple to share many snippets across many different modes (by simply listing more modes in the .yas-parents
file).