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>
This commit is contained in:
Nicolas Goaziou 2018-09-15 16:56:35 +02:00
parent 1e6ab19b2a
commit fa3dab48d0
1 changed files with 9 additions and 11 deletions

View File

@ -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."