瀏覽代碼

Make sure going to last capture also works after refile

Carsten Dominik 16 年之前
父節點
當前提交
b6305c713c
共有 2 個文件被更改,包括 19 次插入2 次删除
  1. 13 2
      lisp/org-capture.el
  2. 6 0
      lisp/org.el

+ 13 - 2
lisp/org-capture.el

@@ -534,7 +534,9 @@ already gone."
   (unless (eq (org-capture-get :type 'local) 'entry)
   (unless (eq (org-capture-get :type 'local) 'entry)
     (error
     (error
      "Refiling from a capture buffer makes only sense for `entry'-type templates"))
      "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)
     (org-capture-finalize)
     (save-window-excursion
     (save-window-excursion
       (with-current-buffer (or base (current-buffer))
       (with-current-buffer (or base (current-buffer))
@@ -542,7 +544,16 @@ already gone."
 	  (save-restriction
 	  (save-restriction
 	    (widen)
 	    (widen)
 	    (goto-char pos)
 	    (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 ()
 (defun org-capture-kill ()
   "Abort the current capture process."
   "Abort the current capture process."

+ 6 - 0
lisp/org.el

@@ -10022,6 +10022,7 @@ such as the file name."
 Note that this is still *before* the stuff will be removed from
 Note that this is still *before* the stuff will be removed from
 the *old* location.")
 the *old* location.")
 
 
+(defvar org-capture-last-stored-marker)
 (defun org-refile (&optional goto default-buffer rfloc)
 (defun org-refile (&optional goto default-buffer rfloc)
   "Move the entry at point to another heading.
   "Move the entry at point to another heading.
 The list of target headings is compiled using the information in
 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))))
 		      (save-excursion (org-add-log-note))))
 		  (and org-auto-align-tags (org-set-tags nil t))
 		  (and org-auto-align-tags (org-set-tags nil t))
 		  (bookmark-set "org-refile-last-stored")
 		  (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))
 		  (if (fboundp 'deactivate-mark) (deactivate-mark))
 		  (run-hooks 'org-after-refile-insert-hook))))
 		  (run-hooks 'org-after-refile-insert-hook))))
 	    (if regionp
 	    (if regionp