0

I like snippets. I use yassnippet a lot. I also use babel in org mode. I would quite like to be able to use my snippets in org babel blocks, but they don't work because I am in the wrong mode. Is there a way to make them work?

I am aware that there are plugins for multiple modes in the same buffer. Are these compatible with babel?

1
  • FYI all my snippets expand according to the block mode. BTW I'm using Emacs 30, Org 9.6.15, and YASnippet version 20240215.1909.
    – jagrg
    Commented Mar 2 at 19:42

1 Answer 1

0

You can create a folder named org-mode in your snippets directory. Yasnippet will allow you to expand all the snippets it contains when you write in org-mode code blocks. Then, you can create symbolic links for the snippets you want to use in your code blocks in this org-mode snippets directory.

If all the snippets you want to use are all in the same directory, you can directly create a symbolic link named org-mode to that directory.

2
  • Thanks for the answer. The problem is that I define python snippets while using python - but then I want to use them in a python block in babel.
    – Att Righ
    Commented Jun 6, 2023 at 14:51
  • Does Yasnippet prompt you for a file to save your Python snippet in when using yas-new-snippet ? If it does, then you can create a directory where you save theme all. Then you can create a symbolic link as I suggested before. Commented Jun 6, 2023 at 16:16

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.