Answer: org-mode how to keep the level when refiling

Question: https://emacs.stackexchange.com/questions/41362

Snapshot:

Answer:

(defun org-mode-keep-the-level-when-refiling ()
  (interactive)
  (cl-destructuring-bind (level reduced-level todo-keyword priority-character headline-text tags-string)
      (org-heading-components)
    (org-refile)
    (goto-char
     (point-max))
    (re-search-backward-lax-whitespace
     (format "** %s" headline-text))
    (dotimes (i 2)
      (org-toggle-heading level))))
H2
H3
H4
3 columns
2 columns
1 column
Join the conversation now