[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[elpa] externals/org b34bdc8719: org-capture-finalize: Do not save new f
From: |
ELPA Syncer |
Subject: |
[elpa] externals/org b34bdc8719: org-capture-finalize: Do not save new file with :no-save aborted capture |
Date: |
Sun, 22 Jan 2023 05:58:11 -0500 (EST) |
branch: externals/org
commit b34bdc871950f9780615ab4c64f149a0f5983d22
Author: Ihor Radchenko <yantar92@posteo.net>
Commit: Ihor Radchenko <yantar92@posteo.net>
org-capture-finalize: Do not save new file with :no-save aborted capture
* lisp/org-capture.el (org-capture-finalize): Do not save the newly
created file buffer when the capture is aborted and org-capture is not
asked to save upon capture.
* testing/lisp/test-org-capture.el (test-org-capture/abort): Add test.
---
lisp/org-capture.el | 14 ++++++++++----
testing/lisp/test-org-capture.el | 12 ++++++++++++
2 files changed, 22 insertions(+), 4 deletions(-)
diff --git a/lisp/org-capture.el b/lisp/org-capture.el
index a696c615b2..b96e9f3363 100644
--- a/lisp/org-capture.el
+++ b/lisp/org-capture.el
@@ -889,10 +889,16 @@ captured item after finalizing."
(goto-char (+ size pos))
(goto-char (if (< ipt pos) (+ size pos) pos))))))
- ;; Kill the target buffer if that is desired
- (when (and base-buffer new-buffer kill-buffer)
- (with-current-buffer base-buffer (save-buffer))
- (kill-buffer base-buffer))
+ (if (and base-buffer org-note-abort new-buffer)
+ ;; Unconditionally kill the new buffer when capture is
+ ;; aborted.
+ (with-current-buffer base-buffer
+ (set-buffer-modified-p nil)
+ (kill-buffer))
+ ;; Kill the target buffer if that is desired
+ (when (and base-buffer new-buffer kill-buffer)
+ (with-current-buffer base-buffer (save-buffer))
+ (kill-buffer base-buffer)))
;; Restore the window configuration before capture
(set-window-configuration return-wconf))
diff --git a/testing/lisp/test-org-capture.el b/testing/lisp/test-org-capture.el
index 44702c3ced..0ed44c6af0 100644
--- a/testing/lisp/test-org-capture.el
+++ b/testing/lisp/test-org-capture.el
@@ -152,6 +152,18 @@
(ert-deftest test-org-capture/abort ()
"Test aborting a capture process."
+ ;; Newly create capture buffer should not be saved.
+ (let ((capture-file (make-temp-name
+ (org-file-name-concat
+ temporary-file-directory
+ "org-test"))))
+ (unwind-protect
+ (let ((org-capture-templates `(("t" "Todo" entry (file ,capture-file)
nil :no-save t))))
+ (org-capture nil "t")
+ (org-capture-kill)
+ (should-not (file-exists-p capture-file)))
+ (when (file-exists-p capture-file)
+ (delete-file capture-file))))
;; Test that capture can be aborted after inserting at end of
;; capture buffer.
(should
[Prev in Thread] |
Current Thread |
[Next in Thread] |
- [elpa] externals/org b34bdc8719: org-capture-finalize: Do not save new file with :no-save aborted capture,
ELPA Syncer <=