[Top][All Lists]

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

[O] patch to keep the level in refile

From: Sebastian Fischmeister
Subject: [O] patch to keep the level in refile
Date: Sun, 1 Nov 2015 07:41:05 -0500


This allows to specify via a variable whether org-refile should keep the
level of the item when refiling. At the moment, org-refile automatically
creates a sub-item at the next level. This causes problems, when the
level has semantic meaning beyond defining the hierarchy (e.g., level 3
always indicates a task while levels 2 and 1 are project headings).

Maybe it would be better to have this as a parameter to org-refile, but
I'm just looking for feedback and suggestions right now.


diff --git a/lisp/org.el b/lisp/org.el
index 6218a3a..8657be8 100755
--- a/lisp/org.el
+++ b/lisp/org.el
@@ -1296,6 +1296,11 @@ commands in the Help buffer using the `?' speed command."
+(defcustom org-refile-keep-level t
+  "Non-nil means entering Org-mode will set keep the level under `org-refile'."
+  :group 'org-structure
+  :type 'boolean)
 (defcustom org-bookmark-names-plist
   '(:last-capture "org-capture-last-stored"
                  :last-refile "org-refile-last-stored"
@@ -11867,6 +11872,7 @@ prefix argument (`C-u C-u C-u C-c C-w')."
           (region-end (and regionp (region-end)))
           (filename (buffer-file-name (buffer-base-buffer cbuf)))
           (org-refile-keep (if (equal arg 3) t org-refile-keep))
+          (curlevel (funcall outline-level))
           pos it nbuf file re level reversed)
       (setq last-command nil)
       (when regionp
@@ -11959,6 +11965,8 @@ prefix argument (`C-u C-u C-u C-c C-w')."
                      (goto-char (point-min))
                      (or (outline-next-heading) (goto-char (point-max)))))
                  (if (not (bolp)) (newline))
+                 (when org-refile-keep-level
+                    (setq level curlevel))
                  (org-paste-subtree level nil nil t)
                  (when org-log-refile
                    (org-add-log-setup 'refile nil nil 'findpos org-log-refile)

reply via email to

[Prev in Thread] Current Thread [Next in Thread]