Setting Up Org Mode Source Code Block Snippets In Spacemacs (Emacs)
TODO: Roll this into the other post where you show the actual snippets that you used (assuming you can find it)
ID of the other post is: 2afrtrcdfbfn
Took a bit to figure this one out. The goal it to setup snippets that auto expand into Org mode source code blocks. By default, you can type "SPC m i b s" when you're not in edit mode to generate a generic source code block like this:
#+begin_example
#_+begin_src
#_+end_src
#+end_example
That's a lot of keys and you still have to define the language and any other options. I made the following additions to the `defun dotspacemacs/user-config` section at the bottom of my `~/.spacemacs` config file to make it nicer.
(defun dotspacemacs/user-config ()
(require 'org-tempo)
(add-to-list 'org-structure-template-alist
'("j" . "src js :results output"))
(add-to-list 'org-structure-template-alist
'("p" . "src python :results output"))
)
The `(require 'org-tempo)` line turns on some default snippet expansions like `<s` followed by TAB at the start of a line (in INSERT mode) for the basic begin/end src block.
The `add-to-list` items let me type `<j` followed by TAB and `<p` followed by a TAB to generate:
#+begin_example
#_+begin_src js :results output
#_+end_src
#+end_example
and
#+begin_example
#_+begin_src python :results output
#_+end_src
#+end_example