Prechádzať zdrojové kódy

Make sure going to last capture also works after refile

Carsten Dominik 14 rokov pred
rodič
commit
b6305c713c
2 zmenil súbory, kde vykonal 19 pridanie a 2 odobranie
  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)
     (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."

+ 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
 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