Note: This site is currently "Under construction". I'm migrating to a new version of my site building software. Lots of things are in a state of disrepair as a result (for example, footnote links aren't working). It's all part of the process of building in public. Most things should still be readable though.

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.

Code

(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 `

The `add-to-list` items let me type `

#+begin_example

#_+begin_src js :results output

#_+end_src

#+end_example

and

#+begin_example

#_+begin_src python :results output

#_+end_src

#+end_example