summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorNicolas Goaziou <mail@nicolasgoaziou.fr>2017-08-31 23:15:56 +0200
committerNicolas Goaziou <mail@nicolasgoaziou.fr>2017-08-31 23:15:56 +0200
commit8a0c89244d69198d326ea00e8aae5bf49e760ca5 (patch)
treef5a5cdda8228e8ffe2ad067239502ce8dacaa49b
parentab6f43fcac75666689b4d06c39c4538c50d26064 (diff)
parent1654a5a98ab28fea3b74536e423bfffddfd86531 (diff)
downloadorg-mode-8a0c89244d69198d326ea00e8aae5bf49e760ca5.tar.gz
Merge branch 'maint'
-rw-r--r--lisp/org-capture.el11
-rw-r--r--testing/lisp/test-org-capture.el18
2 files changed, 25 insertions, 4 deletions
diff --git a/lisp/org-capture.el b/lisp/org-capture.el
index 7547c1a..cd1944d 100644
--- a/lisp/org-capture.el
+++ b/lisp/org-capture.el
@@ -847,13 +847,17 @@ for `entry'-type templates"))
(let* ((base (or (buffer-base-buffer) (current-buffer)))
(pos (make-marker))
(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)))
;; Since `org-capture-finalize' may alter buffer contents (e.g.,
;; empty lines) around entry, use a marker to refer to the
;; headline to be refiled. Place the marker in the base buffer,
;; as the current indirect one is going to be killed.
(set-marker pos (save-excursion (org-back-to-heading t) (point)) base)
- (org-capture-put :kill-buffer nil)
+ ;; `org-capture-finalize' calls `org-capture-goto-last-stored' too
+ ;; early. We want to wait for the refiling to be over, so we
+ ;; control when the latter function is called.
+ (org-capture-put :kill-buffer nil :jump-to-captured nil)
(unwind-protect
(progn
(org-capture-finalize)
@@ -862,7 +866,8 @@ for `entry'-type templates"))
(org-with-wide-buffer
(goto-char pos)
(call-interactively 'org-refile))))
- (when kill-buffer (kill-buffer base)))
+ (when kill-buffer (kill-buffer base))
+ (when jump-to-captured (org-capture-goto-last-stored)))
(set-marker pos nil))))
(defun org-capture-kill ()
diff --git a/testing/lisp/test-org-capture.el b/testing/lisp/test-org-capture.el
index 7b022b1..4d5dfb7 100644
--- a/testing/lisp/test-org-capture.el
+++ b/testing/lisp/test-org-capture.el
@@ -127,7 +127,23 @@
(buffer-substring-no-properties
(line-beginning-position)
(line-end-position))))))
- (catch :return (org-capture-refile))))))))
+ (catch :return (org-capture-refile)))))))
+ ;; When the entry is refiled, `:jump-to-captured' moves point to the
+ ;; refile location, not the initial capture target.
+ (should
+ (org-test-with-temp-text-in-file "* Refile target"
+ (let ((file1 (buffer-file-name)))
+ (org-test-with-temp-text-in-file "* A"
+ (let* ((file2 (buffer-file-name))
+ (org-capture-templates
+ `(("t" "Todo" entry (file+headline ,file2 "A")
+ "** H1 %?" :jump-to-captured t))))
+ (org-capture nil "t")
+ (cl-letf (((symbol-function 'org-refile-get-location)
+ (lambda (&rest args)
+ (list (file-name-nondirectory file1) file1 nil nil))))
+ (org-capture-refile)
+ (list file1 file2 (buffer-file-name)))))))))
(provide 'test-org-capture)