From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from mp1 ([2001:41d0:2:4a6f::]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits)) by ms11 with LMTPS id eDuWC6fuSl+kGAAA0tVLHw (envelope-from ) for ; Sun, 30 Aug 2020 00:11:19 +0000 Received: from aspmx1.migadu.com ([2001:41d0:2:4a6f::]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits)) by mp1 with LMTPS id yLpmB6fuSl/lLAAAbx9fmQ (envelope-from ) for ; Sun, 30 Aug 2020 00:11:19 +0000 Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by aspmx1.migadu.com (Postfix) with ESMTPS id AFF289408DB for ; Sun, 30 Aug 2020 00:11:17 +0000 (UTC) Received: from localhost ([::1]:53456 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1kCAwF-0003Pv-6T for larch@yhetil.org; Sat, 29 Aug 2020 20:11:15 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]:38182) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1kCAvv-0003O7-CP for emacs-orgmode@gnu.org; Sat, 29 Aug 2020 20:10:55 -0400 Received: from coral.adamspiers.org ([2001:ba8:1f1:f27f::2]:40036) by eggs.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1kCAvt-00066U-2A for emacs-orgmode@gnu.org; Sat, 29 Aug 2020 20:10:55 -0400 Received: from localhost (243.103.2.81.in-addr.arpa [81.2.103.243]) by coral.adamspiers.org (Postfix) with ESMTPSA id B90BD2E628 for ; Sun, 30 Aug 2020 01:10:49 +0100 (BST) From: Adam Spiers To: emacs-orgmode@gnu.org Subject: [PATCH] org-refile.el: Add org-refile-reverse which toggles org-reverse-note-order Date: Sun, 30 Aug 2020 01:10:47 +0100 Message-Id: <20200830001047.21362-1-orgmode@adamspiers.org> X-Mailer: git-send-email 2.27.0 MIME-Version: 1.0 Content-Transfer-Encoding: 8bit Received-SPF: pass client-ip=2001:ba8:1f1:f27f::2; envelope-from=orgmode@adamspiers.org; helo=coral.adamspiers.org X-detected-operating-system: by eggs.gnu.org: No matching host in p0f cache. That's all we know. X-Spam_score_int: -18 X-Spam_score: -1.9 X-Spam_bar: - X-Spam_report: (-1.9 / 5.0 requ) BAYES_00=-1.9, SPF_HELO_NONE=0.001, SPF_PASS=-0.001 autolearn=ham autolearn_force=no X-Spam_action: no action X-BeenThere: emacs-orgmode@gnu.org X-Mailman-Version: 2.1.23 Precedence: list List-Id: "General discussions about Org-mode." List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: emacs-orgmode-bounces+larch=yhetil.org@gnu.org Sender: "Emacs-orgmode" X-Scanner: scn0 Authentication-Results: aspmx1.migadu.com; dkim=none; dmarc=fail reason="SPF not aligned (relaxed), No valid DKIM" header.from=adamspiers.org (policy=none); spf=pass (aspmx1.migadu.com: domain of emacs-orgmode-bounces@gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=emacs-orgmode-bounces@gnu.org X-Spam-Score: 4.09 X-TUID: 263W2WbmDqFM This is useful for prepending to the start of the target headline instead of appending to the end, or vice-versa depending on org-reverse-note-order. --- doc/org-manual.org | 10 ++++++++++ etc/ORG-NEWS | 9 +++++++++ lisp/org-keys.el | 1 + lisp/org-refile.el | 11 +++++++++++ 4 files changed, 31 insertions(+) diff --git a/doc/org-manual.org b/doc/org-manual.org index 3eb745b5d..e499367b7 100644 --- a/doc/org-manual.org +++ b/doc/org-manual.org @@ -7190,6 +7190,16 @@ special command: Copying works like refiling, except that the original note is not deleted. +- {{{kbd(C-c C-M-w)}}} (~org-refile-reverse~) :: + + #+kindex: C-c C-M-w + #+findex: org-refile-reverse + Works like refiling, except that it temporarily toggles how the + value of ~org-reverse-note-order~ applies to the current buffer. So + if ~org-refile~ would append the entry as the last entry under the + target header, ~org-refile-reverse~ will prepend it as the first + entry, and vice-versa. + ** Archiving :PROPERTIES: :DESCRIPTION: What to do with finished products. diff --git a/etc/ORG-NEWS b/etc/ORG-NEWS index 10658a970..a3c8397fc 100644 --- a/etc/ORG-NEWS +++ b/etc/ORG-NEWS @@ -267,6 +267,15 @@ Source code block header argument =:file-mode= can set file permissions if =:file= argument is provided. ** New commands +*** ~org-refile-reverse~ + +Use default keybinding == to run command +~org-refile-reverse~. It is almost identical to ~org-refile~, except +that it temporarily toggles how ~org-reverse-note-order~ applies to +the current buffer. So if ~org-refile~ would append the entry as the +last entry under the target heading, ~org-refile-reverse~ will prepend +it as the first entry, and vice-versa. + *** ~org-table-header-line-mode~ Turn on a minor mode to display the first data row of the table at diff --git a/lisp/org-keys.el b/lisp/org-keys.el index 37df29983..902651175 100644 --- a/lisp/org-keys.el +++ b/lisp/org-keys.el @@ -582,6 +582,7 @@ (define-key org-mode-map (kbd "") #'org-shifttab) (org-defkey org-mode-map (kbd "C-c ;") #'org-toggle-comment) (org-defkey org-mode-map (kbd "C-c C-w") #'org-refile) (org-defkey org-mode-map (kbd "C-c M-w") #'org-refile-copy) +(org-defkey org-mode-map (kbd "C-c C-M-w") #'org-refile-reverse) (org-defkey org-mode-map (kbd "C-c /") #'org-sparse-tree) ;minor-mode reserved (org-defkey org-mode-map (kbd "C-c \\") #'org-match-sparse-tree) ;minor-mode r. (org-defkey org-mode-map (kbd "C-c RET") #'org-ctrl-c-ret) diff --git a/lisp/org-refile.el b/lisp/org-refile.el index 7eb0a9643..c6ff35535 100644 --- a/lisp/org-refile.el +++ b/lisp/org-refile.el @@ -384,6 +384,17 @@ (defun org-refile-copy () (defvar org-capture-last-stored-marker) +;;;###autoload +(defun org-refile-reverse (&optional arg default-buffer rfloc msg) + "Invoke `org-refile', but temporarily toggling how +~org-reverse-note-order~ applies to the current buffer. So if +`org-refile' would append the entry as the last entry under the +target heading, ~org-refile-reverse~ will prepend it as the first +entry, and vice-versa." + (interactive "P") + (let ((org-reverse-note-order (not (org-notes-order-reversed-p)))) + (org-refile arg default-buffer rfloc msg))) + ;;;###autoload (defun org-refile (&optional arg default-buffer rfloc msg) "Move the entry or entries at point to another heading. -- 2.27.0