I'm currently working with a lot of javascript in my org files.
Therefore I introduce a local buffer variable that will automatically insert javascript
as language identifier in my file whenever I use <s TAB
.
Here is how I've done it, it's inspired by the mailing list post here.
# -*- org-structure-template-alist: (("s" "#+BEGIN_SRC javascript\n?\n#+END_SRC")); -*-
When I put this as first line in my org file it will complete <s
to the desired.
#+BEGIN_SRC javascript
#+END_SRC
Now when I look up the definition C-h v org-structure-template-alist
the current value is just.
Value:
(("s" "#+BEGIN_SRC javascript\n?\n#+END_SRC"))
While the original value was:
(("s" "#+BEGIN_SRC ?\n\n#+END_SRC" "<src lang=\"?\">\n\n</src>")
("e" "#+BEGIN_EXAMPLE\n?\n#+END_EXAMPLE" "<example>\n?\n</example>")
("q" "#+BEGIN_QUOTE\n?\n#+END_QUOTE" "<quote>\n?\n</quote>")
...
So is it possible to access the global definition of org-structure-template-alist
inside the local org defining block and just replace the default binding to <s
with my definition?
This way I can use <s
to get the javascript, but also use the other defined shortcuts like <e
for Example block. Currently the buffer in which I define org-structure-template-alist
will only complete <s
and ignore all things.
I tried this but it doesn't seem to evaluate the add-to-list
.
# -*- org-structure-template-alist: (add-to-list 'org-structure-template-alist (("s" "#+BEGIN_SRC javascript\n?\n#+END_SRC" "<src lang=\"javascript\">\n\n</src>"))); -*-
Update:
This is now my final solution based on the answer of Tyler. I include the following code as last statement in my org file. It is marked as a comment so it won't get exported, which was also a requirement. Loading the file now ask if I want to apply local variables, but this is not a problem right now.
* COMMENT
### Local Variables:
### eval: (make-variable-buffer-local 'org-structure-template-alist)
### eval: (add-to-list 'org-structure-template-alist '("s" "#+BEGIN_SRC javascript :tangle yes\n?\n#+END_SRC" "<src lang=\"javascript\">\n\n</src>"))
### End: