The package org-structtempl.el
brings back the old structure template mechanism to Orgmode.
Therewith your desired behavior is the default.
The actual reason for extracting the old code from Org 9.1.14 and putting it in its own package org-structtempl.el
is that the old mechanism was more general than that one of org-tempo.el
.
For an instance there is no way to mimic the following entry of org-structtempl-alist
with org-tempo.el
:
("m" "\\begin{align*}\n?\n\\end{align*}")
Furthermore, I had heavily customized the structure templates with the help of the advice-mechanism. That suddenly didn't work anymore when Org 9.2 was out.
My customization does not interfere with the old functionality. Therefore, I plan to add it to org-structtempl.el
.
With my customization the following substitution is possible:
<s emacs-lisp :results silent
(cl-loop for i from 0 upto 3 do
(message "Structure templates are cool.")
)
With all that stuff marked as region, it is substituted by the following stuff when pressing tab:
#+BEGIN_SRC emacs-lisp :results silent
(cl-loop for i from 0 upto 3 do
(message "Structure templates are cool.")
)
#+END_SRC
Another feature of my modifications is that TAB-completion of a line only containing <m
asks you for a LaTeX environment and substitutes it for the shortcut <m
.
You can install org-structtempl.el
by saving it somewhere into your load-path
and adding the following lines to your init file:
(with-eval-after-load 'org
(require 'org-structtempl))