1

I have made a hierarchial list of headlines in skeleton, like this:

(define-skeleton myskel-list
"Insert claim block"  nil
"* Heading a\n"
"** Heading aa\n"
"* Heading b\n"
"** Heading bb\n"
)

I want to insert this skeleton inside a an allready existing headline hierarchy in such av way that the skeleton headings becomes subheadings at the pont I insert it.

Hence if my existing headline hierarchy look like this

* My book
** Chapter 1

and I insert my skeleton under "Chapter 1" the result should look like this

* My book
** Chapter 1
*** headline a\n
**** headline aa\n
*** headline b\n
**** headline bb\n 

Hence, the levels in the skeleton (level 1 and 2) must be added the level of the insert point, in this case level 2, so that "heading a" ends on level 1+2=3, "heading aa" ends up at level 2+2=4, and so on.

So, how can I make a skeleton that add its heading levels to the heading level at the point I insert it? What must be changed in my skeleton code to accomplish this?

Thanks for any suggestings and help.

  • I don't know how to do that but you can easily org-demote-subtree (M-S-<right>) your skeleton once inserted. – JeanPierre May 22 '16 at 15:18
2

I use this setting to make yasnippet snippets behave like org-paste-subtree.

(defun my--yas-expand-org-snippet (orig content &optional start end expand-env)
;;  (require 'cl)
  (if (eq major-mode 'org-mode)
    (flet ((insert (content)
                   (org-paste-subtree nil content)))
      (funcall orig content start end expand-env))
    (funcall orig content start end expand-env)
    )
  )
(advice-add 'yas-expand-snippet :around 'my--yas-expand-org-snippet)

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.