emacs-orgmode@gnu.org archives
 help / color / mirror / code / Atom feed
* patch to keep the level in refile
@ 2015-11-01 12:41 Sebastian Fischmeister
  2015-11-01 14:43 ` Nicolas Goaziou
  0 siblings, 1 reply; 4+ messages in thread
From: Sebastian Fischmeister @ 2015-11-01 12:41 UTC (permalink / raw)
  To: emacs-orgmode

Hi,

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.

  Sebastian


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."
                                (function)
                                (sexp))))))
 
+(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)

^ permalink raw reply related	[flat|nested] 4+ messages in thread

end of thread, other threads:[~2015-11-08 15:32 UTC | newest]

Thread overview: 4+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2015-11-01 12:41 patch to keep the level in refile Sebastian Fischmeister
2015-11-01 14:43 ` Nicolas Goaziou
2015-11-01 20:32   ` Sebastian Fischmeister
2015-11-08 15:34     ` Nicolas Goaziou

Code repositories for project(s) associated with this public inbox

	https://git.savannah.gnu.org/cgit/emacs/org-mode.git

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).