Ver código fonte

Add :no-save keyword for Org capture templates

* lisp/org-capture.el (org-capture-finalize): Do not save the target
  capture file if :no-save keyword is non-nil in the capture template.
* doc/org-manual.org (Template elements),
  lisp/org-capture.el (org-capture-templates): Document :no-save.

Ref: https://lists.gnu.org/r/emacs-orgmode/2018-09/msg00325.html
Kaushal Modi 6 anos atrás
pai
commit
a60a0edc6f
2 arquivos alterados com 8 adições e 2 exclusões
  1. 4 0
      doc/org-manual.org
  2. 4 2
      lisp/org-capture.el

+ 4 - 0
doc/org-manual.org

@@ -7352,6 +7352,10 @@ Now lets look at the elements of a template definition.  Each entry in
           If the target file was not yet visited when capture was invoked, kill
           If the target file was not yet visited when capture was invoked, kill
           the buffer again after capture is completed.
           the buffer again after capture is completed.
 
 
+     - ~:no-save~ ::
+
+          Do not save the target file after finishing the capture.
+
 **** Template expansion
 **** Template expansion
 :PROPERTIES:
 :PROPERTIES:
 :DESCRIPTION: Filling in information about time and context.
 :DESCRIPTION: Filling in information about time and context.

+ 4 - 2
lisp/org-capture.el

@@ -266,6 +266,8 @@ properties are:
                      capture was invoked, kill the buffer again after capture
                      capture was invoked, kill the buffer again after capture
                      is finalized.
                      is finalized.
 
 
+ :no-save            Do not save the target file after finishing the capture.
+
 The template defines the text to be inserted.  Often this is an
 The template defines the text to be inserted.  Often this is an
 Org mode entry (so the first line should start with a star) that
 Org mode entry (so the first line should start with a star) that
 will be filed as a child of the target headline.  It can also be
 will be filed as a child of the target headline.  It can also be
@@ -795,8 +797,8 @@ captured item after finalizing."
 	(goto-char (org-capture-get :decrypted))
 	(goto-char (org-capture-get :decrypted))
 	(org-encrypt-entry)))
 	(org-encrypt-entry)))
 
 
-    ;; Kill the indirect buffer
-    (save-buffer)
+    (unless (org-capture-get :no-save) (save-buffer))
+
     (let ((return-wconf (org-capture-get :return-to-wconf 'local))
     (let ((return-wconf (org-capture-get :return-to-wconf 'local))
 	  (new-buffer (org-capture-get :new-buffer 'local))
 	  (new-buffer (org-capture-get :new-buffer 'local))
 	  (kill-buffer (org-capture-get :kill-buffer 'local))
 	  (kill-buffer (org-capture-get :kill-buffer 'local))