From b6305c713c54421257759c38c260f516686f2811 Mon Sep 17 00:00:00 2001 From: Carsten Dominik Date: Tue, 6 Jul 2010 12:46:12 +0200 Subject: [PATCH] Make sure going to last capture also works after refile --- lisp/org-capture.el | 15 +++++++++++++-- lisp/org.el | 6 ++++++ 2 files changed, 19 insertions(+), 2 deletions(-) diff --git a/lisp/org-capture.el b/lisp/org-capture.el index 2e12ddcab..2b02b77c9 100644 --- a/lisp/org-capture.el +++ b/lisp/org-capture.el @@ -534,7 +534,9 @@ already gone." (unless (eq (org-capture-get :type 'local) 'entry) (error "Refiling from a capture buffer makes only sense for `entry'-type templates")) - (let ((pos (point)) (base (buffer-base-buffer (current-buffer)))) + (let ((pos (point)) + (base (buffer-base-buffer (current-buffer))) + (org-refile-for-capture t)) (org-capture-finalize) (save-window-excursion (with-current-buffer (or base (current-buffer)) @@ -542,7 +544,16 @@ already gone." (save-restriction (widen) (goto-char pos) - (call-interactively 'org-refile))))))) + (call-interactively 'org-refile) + (when (and (boundp 'bookmark-alist) + (assoc "org-capture-last-stored" bookmark-alist)) + (if (assoc "org-refile-last-stored" bookmark-alist) + (setcdr (assoc "org-refile-last-stored" bookmark-alist) + (cdr (assoc "org-refile-last-stored" bookmark-alist))) + (push (cons "org-capture-last-stored" + (cdr (assoc "org-refile-last-stored" + bookmark-alist))) + bookmark-alist))))))))) (defun org-capture-kill () "Abort the current capture process." diff --git a/lisp/org.el b/lisp/org.el index d207e5dff..8848565bf 100644 --- a/lisp/org.el +++ b/lisp/org.el @@ -10022,6 +10022,7 @@ such as the file name." Note that this is still *before* the stuff will be removed from the *old* location.") +(defvar org-capture-last-stored-marker) (defun org-refile (&optional goto default-buffer rfloc) "Move the entry at point to another heading. The list of target headings is compiled using the information in @@ -10142,6 +10143,11 @@ This can be done with a 0 prefix: `C-0 C-c C-w'" (save-excursion (org-add-log-note)))) (and org-auto-align-tags (org-set-tags nil t)) (bookmark-set "org-refile-last-stored") + ;; If we are refiling for capture, make sure that the + ;; last-capture pointers point here + (when (org-bound-and-true-p org-refile-for-capture) + (bookmark-set "org-refile-last-stored") + (move-marker org-capture-last-stored-marker (point))) (if (fboundp 'deactivate-mark) (deactivate-mark)) (run-hooks 'org-after-refile-insert-hook)))) (if regionp -- 2.11.4.GIT