2

Can yasnippet be used to insert an org subtree of the same level as the last? For example, if one often writes

***** $1
#+BEGIN_SRC latex
    \paragraph{$1.}
    $0
#+END_SRC

how might one avoid having to adjust the number of stars manually?

1 Answer 1

5

You can determine the current level within embedded Emacs-lisp code.

# -*- mode: snippet -*-
# name: org subtree
# key: ost
# --
`(make-string (org-current-level) ?*)` $1
#+BEGIN_SRC latex
    \paragraph{$1.}
    $0
#+END_SRC
1
  • This failed with invalid argument (wholep, nil) for me. (make-string (if (org-current-level) (+ (org-current-level) 1) 1) ?*) Packing List for $1 📦 [/]` worked for me. Apr 18, 2023 at 13:48

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

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