emacs-orgmode@gnu.org archives
 help / color / mirror / code / Atom feed
From: Kaushal Modi <kaushal.modi@gmail.com>
To: Nicolas Goaziou <mail@nicolasgoaziou.fr>
Cc: van@scratch.space, Eric Abrahamsen <eric@ericabrahamsen.net>,
	emacs-org list <emacs-orgmode@gnu.org>,
	Bastien Guerry <bzg@gnu.org>
Subject: Re: [PATCH] org-capture: Add a custom to control save target file or not.
Date: Thu, 13 Dec 2018 10:24:47 -0500	[thread overview]
Message-ID: <CAFyQvY3Onmh=k7VDqZdZSjL8TDFCEDXGypwPuCF0k9WOeBZ_PA@mail.gmail.com> (raw)
In-Reply-To: <CAFyQvY3k6ozPk5TUyPBhyxCi7WmtiZuzT9wiDfQE60C_S2G9qg@mail.gmail.com>


[-- Attachment #1.1: Type: text/plain, Size: 739 bytes --]

On Thu, Dec 13, 2018 at 10:08 AM Kaushal Modi <kaushal.modi@gmail.com>
wrote:

> Hello Nicolas,
>
> While we are planning to cut Org 9.2 release this week, this one
> regression in the Org Capture and auto-saving behavior comes to my mind,
> that I think should be fixed.
>
> Summary:
>
> In Org 9.1.x, org-capture target files got auto-saved after C-c C-c when
> ending the capture. In Org master branch, that stopped happening.
>
> As per your last proposal, we should revert
> https://code.orgmode.org/bzg/org-mode/commit/b4422add3745c26ec3b2e11b8da425844b2e9d3d
> and then add a :no-save option that skips that save-buffer call.
>

I have formatted 2 patches to address this (attached). If they look fine, I
can commit them to master.

[-- Attachment #1.2: Type: text/html, Size: 1313 bytes --]

[-- Attachment #2: 0001-Revert-org-capture-Do-not-save-buffer-when-running-o.patch --]
[-- Type: application/octet-stream, Size: 984 bytes --]

From 54123cd7f20227d9679130bee907ede9e42e73fd Mon Sep 17 00:00:00 2001
From: Kaushal Modi <kaushal.modi@gmail.com>
Date: Thu, 13 Dec 2018 10:11:25 -0500
Subject: [PATCH 1/2] Revert "org-capture: Do not save buffer when running
 `org-capture-finalize'"

This reverts commit b4422add3745c26ec3b2e11b8da425844b2e9d3d.

Revert the regression in Org capture + auto-saving behavior.

Ref: https://lists.gnu.org/r/emacs-orgmode/2018-09/msg00325.html
---
 lisp/org-capture.el | 1 +
 1 file changed, 1 insertion(+)

diff --git a/lisp/org-capture.el b/lisp/org-capture.el
index 2946b6fc5..a463e29fa 100644
--- a/lisp/org-capture.el
+++ b/lisp/org-capture.el
@@ -796,6 +796,7 @@ captured item after finalizing."
 	(org-encrypt-entry)))
 
     ;; Kill the indirect buffer
+    (save-buffer)
     (let ((return-wconf (org-capture-get :return-to-wconf 'local))
 	  (new-buffer (org-capture-get :new-buffer 'local))
 	  (kill-buffer (org-capture-get :kill-buffer 'local))
-- 
2.18.0.547.g1d89318c4


[-- Attachment #3: 0002-Add-no-save-keyword-for-Org-capture-templates.patch --]
[-- Type: application/octet-stream, Size: 2100 bytes --]

From cbe7d03b427b31f30af04761eab04dd70191b64b Mon Sep 17 00:00:00 2001
From: Kaushal Modi <kaushal.modi@gmail.com>
Date: Thu, 13 Dec 2018 10:18:18 -0500
Subject: [PATCH 2/2] Add :no-save keyword for Org capture templates

Setting this will prevent capture target file saving upon finishing a
capture.

Ref: https://lists.gnu.org/r/emacs-orgmode/2018-09/msg00325.html
---
 doc/org-manual.org  | 4 ++++
 lisp/org-capture.el | 8 ++++++--
 2 files changed, 10 insertions(+), 2 deletions(-)

diff --git a/doc/org-manual.org b/doc/org-manual.org
index 051ffaa4d..b301d0a6a 100644
--- a/doc/org-manual.org
+++ b/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
           the buffer again after capture is completed.
 
+     - ~:no-save~ ::
+
+          Do not save the target file after finishing the capture.
+
 **** Template expansion
 :PROPERTIES:
 :DESCRIPTION: Filling in information about time and context.
diff --git a/lisp/org-capture.el b/lisp/org-capture.el
index a463e29fa..1d83741fc 100644
--- a/lisp/org-capture.el
+++ b/lisp/org-capture.el
@@ -266,6 +266,8 @@ properties are:
                      capture was invoked, kill the buffer again after capture
                      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
 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
@@ -795,8 +797,10 @@ captured item after finalizing."
 	(goto-char (org-capture-get :decrypted))
 	(org-encrypt-entry)))
 
-    ;; Kill the indirect buffer
-    (save-buffer)
+    (unless (org-capture-get :no-save)
+      ;; Save the target file.
+      (save-buffer))
+
     (let ((return-wconf (org-capture-get :return-to-wconf 'local))
 	  (new-buffer (org-capture-get :new-buffer 'local))
 	  (kill-buffer (org-capture-get :kill-buffer 'local))
-- 
2.18.0.547.g1d89318c4


  reply	other threads:[~2018-12-13 15:25 UTC|newest]

Thread overview: 24+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2018-04-12  1:20 [PATCH] org-capture: Add a custom to control save target file or not tumashu
2018-04-12 13:22 ` Nicolas Goaziou
2018-04-13  2:10   ` tumashu
2018-04-14  7:44     ` Nicolas Goaziou
2018-04-14  9:42       ` tumashu
2018-04-16  1:06         ` tumashu
2018-04-16 10:11           ` Nicolas Goaziou
2018-09-26 17:11         ` Kaushal Modi
2018-09-26 17:29           ` Kaushal Modi
2018-09-26 18:11             ` Kaushal Modi
2018-09-27  5:47           ` Eric S Fraga
2018-09-27 13:33             ` Kaushal Modi
2018-09-28 12:28               ` Kaushal Modi
2018-09-28 20:50                 ` Nicolas Goaziou
2018-09-28 21:17                   ` Kaushal Modi
2018-09-29  6:31                     ` Nicolas Goaziou
2018-09-29 10:27                       ` Eric S Fraga
2018-09-29 10:35                         ` Van L
2018-12-13 15:08                           ` Kaushal Modi
2018-12-13 15:24                             ` Kaushal Modi [this message]
2018-12-13 15:33                               ` Kaushal Modi
2018-12-13 16:25                               ` Nicolas Goaziou
2018-12-13 19:12                                 ` Kaushal Modi
2018-04-26 23:34   ` Bastien

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

  List information: https://www.orgmode.org/

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to='CAFyQvY3Onmh=k7VDqZdZSjL8TDFCEDXGypwPuCF0k9WOeBZ_PA@mail.gmail.com' \
    --to=kaushal.modi@gmail.com \
    --cc=bzg@gnu.org \
    --cc=emacs-orgmode@gnu.org \
    --cc=eric@ericabrahamsen.net \
    --cc=mail@nicolasgoaziou.fr \
    --cc=van@scratch.space \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
Code repositories for project(s) associated with this public inbox

	https://git.savannah.gnu.org/cgit/emacs/org-mode.git

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).