0
0
Fork 1
mirror of https://git.savannah.gnu.org/git/emacs/org-mode.git synced 2024-09-29 22:47:56 +00:00

lisp/org-capture.el: Add a new :refile-targets template option

* lisp/org-capture.el (org-capture-templates): Add :refile-targets.
(org-capture-refile): Honor :refile-targets.

TINYCHANGE
This commit is contained in:
Richard Garner 2021-05-01 13:07:55 +02:00 committed by Bastien Guerry
parent b90b850ae8
commit 154e1f19a9

View file

@ -246,6 +246,10 @@ properties are:
:jump-to-captured When set, jump to the captured entry when finished. :jump-to-captured When set, jump to the captured entry when finished.
:refile-targets When exiting capture mode via `org-capture-refile', the
variable `org-refile-targets' will be temporarily bound
to the value of this property.
:empty-lines Set this to the number of lines that should be inserted :empty-lines Set this to the number of lines that should be inserted
before and after the new item. Default 0, only common before and after the new item. Default 0, only common
other value is 1. other value is 1.
@ -885,7 +889,8 @@ for `entry'-type templates"))
(pos (make-marker)) (pos (make-marker))
(org-capture-is-refiling t) (org-capture-is-refiling t)
(kill-buffer (org-capture-get :kill-buffer 'local)) (kill-buffer (org-capture-get :kill-buffer 'local))
(jump-to-captured (org-capture-get :jump-to-captured 'local))) (jump-to-captured (org-capture-get :jump-to-captured 'local))
(refile-targets (org-capture-get :refile-targets 'local)))
;; Since `org-capture-finalize' may alter buffer contents (e.g., ;; Since `org-capture-finalize' may alter buffer contents (e.g.,
;; empty lines) around entry, use a marker to refer to the ;; empty lines) around entry, use a marker to refer to the
;; headline to be refiled. Place the marker in the base buffer, ;; headline to be refiled. Place the marker in the base buffer,
@ -895,11 +900,12 @@ for `entry'-type templates"))
;; early. We want to wait for the refiling to be over, so we ;; early. We want to wait for the refiling to be over, so we
;; control when the latter function is called. ;; control when the latter function is called.
(org-capture-put :kill-buffer nil :jump-to-captured nil) (org-capture-put :kill-buffer nil :jump-to-captured nil)
(org-capture-finalize) (let ((org-refile-targets (or refile-targets org-refile-targets)))
(save-window-excursion (org-capture-finalize)
(with-current-buffer base (save-window-excursion
(org-with-point-at pos (with-current-buffer base
(call-interactively 'org-refile)))) (org-with-point-at pos
(call-interactively 'org-refile)))))
(when kill-buffer (when kill-buffer
(with-current-buffer base (save-buffer)) (with-current-buffer base (save-buffer))
(kill-buffer base)) (kill-buffer base))