Browse Source

org-capture: Save buffer in `org-capture-refile'

* lisp/org-capture.el (org-capture-refile): When :kill-buffer option
  is active, save buffer before killing it.

Reported-by: Andrew Burgess <andrew.burgess@embecosm.com>
<http://lists.gnu.org/r/emacs-orgmode/2018-09/msg00052.html>
Nicolas Goaziou 1 year ago
parent
commit
fa3dab48d0
1 changed files with 9 additions and 11 deletions
  1. 9 11
      lisp/org-capture.el

+ 9 - 11
lisp/org-capture.el

@@ -869,17 +869,15 @@ for `entry'-type templates"))
     ;; 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)
-	  (save-window-excursion
-	    (with-current-buffer base
-	      (org-with-wide-buffer
-	       (goto-char pos)
-	       (call-interactively 'org-refile))))
-	  (when kill-buffer (kill-buffer base))
-	  (when jump-to-captured (org-capture-goto-last-stored)))
-      (set-marker pos nil))))
+    (org-capture-finalize)
+    (save-window-excursion
+      (with-current-buffer base
+	(org-with-point-at pos
+	  (call-interactively 'org-refile))))
+    (when kill-buffer
+      (with-current-buffer base (save-buffer))
+      (kill-buffer base))
+    (when jump-to-captured (org-capture-goto-last-stored))))
 
 (defun org-capture-kill ()
   "Abort the current capture process."