2

I want to append \n to specific easy-template

before 9.2 I could:

(setq org-structure-template-alist
      '(("s" "#+BEGIN_SRC ?\n\n#+END_SRC\n")
       ("e" "#+BEGIN_EXAMPLE\n?\n#+END_EXAMPLE\n")
       ("q" "#+BEGIN_QUOTE\n?\n#+END_QUOTE\n")
       ("v" "#+BEGIN_VERSE\n?\n#+END_VERSE\n")
       ("V" "#+BEGIN_VERBATIM\n?\n#+END_VERBATIM\n")))

the new value looks like this

Value: (("a" . "export ascii")
 ("c" . "center")
 ("C" . "comment")
 ("e" . "example")
 ("E" . "export")
 ("h" . "export html")
 ("l" . "export latex")
 ("q" . "quote")
 ("s" . "src")
 ("v" . "verse"))

more abstract but I can no longer do what I used to do.

any solution?

5
  • 1
    For specific patterns I now use yasnippet (github.com/joaotavora/yasnippet) which is very versatile.
    – Lgen
    Aug 31 '19 at 18:48
  • 2
    The new template mechanism already adds a newline at the end. Try C-c C-, s shell RET e.g. It also has the great advantage that it will wrap a block around a selected region. You can also load org-tempo and use the old <sTAB mechanism to insert a template and you can apparently use tempo templates to do more complicated things, but I have not felt the need to do so yet.
    – NickD
    Sep 1 '19 at 2:23
  • 1
    @NickD No, there is no extra \n added at the end. BTW wrap a block around a selected region is neat! never know this.
    – nichijou
    Sep 1 '19 at 6:12
  • 2
    You can use tempo-define-template, as I explained in this answer.
    – Omar
    Sep 1 '19 at 18:19
  • 1
    @nichijou: if you start with an empty buffer and do C-c C-, s shell RET and then do M-> to go to the end of the buffer, do you really end up at the end of the #+end_src line? Not at the line below it? BTW, there is no extra newline: just one newline at the end.
    – NickD
    Sep 2 '19 at 1:54
2

I also prefer a new line between the begin and end markers, you can customize org-structure-template-alist to add a new line between the begin and end markers, such as:

(setq org-structure-template-alist
  '(("a" . "export ascii\n")
    ("c" . "center\n")
    ("C" . "comment\n")
    ("e" . "example\n")
    ("E" . "export")
    ("h" . "export html\n")
    ("l" . "export latex\n")
    ("q" . "quote\n")
    ("s" . "src")
    ("v" . "verse\n")))

after this, when the C-c C-, will have a \n line between the begin and end markers:

#+BEGIN_QUOTE

#+END_QUOTE
1
  • 1
    Can confirm this works. Although because there is no "\n" in ("s" . "src") in the above code, it first did not work for me. And the "\n" also extends the dispatcher/selcetion window with a newline for every "\n" in the list. Jul 24 '20 at 10:20

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.