From mboxrd@z Thu Jan 1 00:00:00 1970 From: Sebastian Fischmeister Subject: patch to keep the level in refile Date: Sun, 1 Nov 2015 07:41:05 -0500 Message-ID: <87y4eh51yz.fsf@uwaterloo.ca> Reply-To: sfischme@uwaterloo.ca Mime-Version: 1.0 Content-Type: text/plain Return-path: Received: from eggs.gnu.org ([2001:4830:134:3::10]:51195) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1Zsrwg-0000kJ-A1 for emacs-orgmode@gnu.org; Sun, 01 Nov 2015 07:41:15 -0500 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1Zsrwd-000388-0p for emacs-orgmode@gnu.org; Sun, 01 Nov 2015 07:41:14 -0500 Received: from mailservices.uwaterloo.ca ([129.97.128.141]:53516 helo=mailchk-m06.uwaterloo.ca) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1Zsrwc-000380-SR for emacs-orgmode@gnu.org; Sun, 01 Nov 2015 07:41:10 -0500 Received: from connect.uwaterloo.ca (connhub2.connect.uwaterloo.ca [129.97.149.119]) by mailchk-m06.uwaterloo.ca (8.14.4/8.14.4) with ESMTP id tA1Cf6do007091 (version=TLSv1/SSLv3 cipher=AES128-SHA bits=128 verify=OK) for ; Sun, 1 Nov 2015 07:41:06 -0500 List-Id: "General discussions about Org-mode." List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: emacs-orgmode-bounces+geo-emacs-orgmode=m.gmane.org@gnu.org Sender: emacs-orgmode-bounces+geo-emacs-orgmode=m.gmane.org@gnu.org To: emacs-orgmode@gnu.org 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)