I read org mode - Easy Templates in Org 9.2 - Emacs Stack Exchange, which instruct to get back org 9.1

by adding (require 'org-tempo) to your init file or by adding
org-tempo to the list org-modules. You can do that by customizing org-modules.

However, it is nothing of usage,

I can only read the old-fashion style, but cannot change it.

  • I'm not totally sure what you meant by "I can only read the old-fashion style, but cannot change it", but I wrote an answer explaining how to define templates in the new mechanism. – Omar Jul 5 '19 at 13:56

You can still configure this by changing the variable org-structure-template-alist as before, but the format of that variable has been simplified. Before if you wanted <lem to expand to



you would add an entry ("lem" "#begin_lemma\n?#end_lemma") to org-structure-template-alist. Now, instead you just add ("lem" "lemma").

So for easy cases, the new format is actually much simpler to use, but the older format was more general. You can still get more complicated expansions, but you will need to use tempo-define-template directly. For example, say you wanted <js to expand to:

#+begin_export html
<script type="text/javascript">


You can define a tempo template as follows:

(tempo-define-template "inline-js" ; just some name for the template
           '("#+begin_export html" n 
             "<script type=\"text/javascript\">" n p n
             "</script>" n
           "Insert a script tag" ; documentation

The various n in the template add newlines, and the p marks where the point will be left after expansion.

| improve this answer | |

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

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