浏览代码

New command `org-refile-reverse' bound to C-c C-M-w

* lisp/org-refile.el (org-refile-reverse): New command.

* lisp/org-keys.el (org-mode-map): Bind C-c C-M-w to
`org-refile-reverse'.

* doc/org-manual.org (Refile and Copy): Document
`org-refile-reverse'.

* etc/ORG-NEWS (New command ~org-refile-reverse~ (=C-c C-M-w=)):
Announce the new command.

Link: https://orgmode.org/list/20200830001047.21362-1-orgmode@adamspiers.org/
Adam Spiers 3 年之前
父节点
当前提交
33027f992d
共有 4 个文件被更改,包括 32 次插入0 次删除
  1. 10 0
      doc/org-manual.org
  2. 10 0
      etc/ORG-NEWS
  3. 1 0
      lisp/org-keys.el
  4. 11 0
      lisp/org-refile.el

+ 10 - 0
doc/org-manual.org

@@ -7246,6 +7246,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.

+ 10 - 0
etc/ORG-NEWS

@@ -230,6 +230,16 @@ package, to convert pandas Dataframes into orgmode tables:
 | 2 | 3 | 6 |
 #+end_src
 
+*** New command ~org-refile-reverse~ (=C-c C-M-w=)
+
+You can now use =C-c C-M-w= to run ~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.
+
 *** New startup options =#+startup: show<n>levels=
 
 These startup options complement the existing =overview=, =content=,

+ 1 - 0
lisp/org-keys.el

@@ -581,6 +581,7 @@ COMMANDS is a list of alternating OLDDEF NEWDEF command names."
 (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)

+ 11 - 0
lisp/org-refile.el

@@ -383,8 +383,19 @@ the *old* location.")
   (let ((org-refile-keep t))
     (org-refile nil nil nil "Copy")))
 
+;;;###autoload
+(defun org-refile-reverse (&optional arg default-buffer rfloc msg)
+  "Refile while temporarily toggling `org-reverse-note-order'.
+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)))
+
 (defvar org-capture-last-stored-marker)
 
+
 ;;;###autoload
 (defun org-refile (&optional arg default-buffer rfloc msg)
   "Move the entry or entries at point to another heading.