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?

nichijou
  • 1,158
  • 10
  • 14
  • 1
    For specific patterns I now use yasnippet (https://github.com/joaotavora/yasnippet) which is very versatile. – Lgen Aug 31 '19 at 18:48
  • 3
    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 ` – NickD Sep 01 '19 at 02: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 01 '19 at 06:12
  • 2
    You can use `tempo-define-template`, as I explained in [this answer](https://emacs.stackexchange.com/a/51411/2221). – Omar Sep 01 '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 02 '19 at 01:54

1 Answers1

3

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
zhouji
  • 155
  • 7
  • 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. – breathe_in_breathe_out Jul 24 '20 at 10:20