From mboxrd@z Thu Jan 1 00:00:00 1970 From: Kaushal Modi Subject: Re: [PATCH] org-capture: Add a custom to control save target file or not. Date: Thu, 27 Sep 2018 09:33:13 -0400 Message-ID: References: <19dc1211.1e75.162b770bd5c.Coremail.tumashu@163.com> <87po34y2ya.fsf@nicolasgoaziou.fr> <77a63bcf.32cc.162bcc4a5d0.Coremail.tumashu@163.com> <877epap70f.fsf@nicolasgoaziou.fr> <875zyro5jz.fsf@gmail.com> Mime-Version: 1.0 Content-Type: multipart/alternative; boundary="000000000000b2c87a0576da6321" Return-path: Received: from eggs.gnu.org ([2001:4830:134:3::10]:44051) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1g5WaC-0006bu-Ej for emacs-orgmode@gnu.org; Thu, 27 Sep 2018 09:43:57 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1g5WQT-0007Ey-2M for emacs-orgmode@gnu.org; Thu, 27 Sep 2018 09:33:56 -0400 Received: from mail-lj1-x242.google.com ([2a00:1450:4864:20::242]:43169) by eggs.gnu.org with esmtps (TLS1.0:RSA_AES_128_CBC_SHA1:16) (Exim 4.71) (envelope-from ) id 1g5WQS-0007EX-Po for emacs-orgmode@gnu.org; Thu, 27 Sep 2018 09:33:52 -0400 Received: by mail-lj1-x242.google.com with SMTP id r8-v6so2408930ljc.10 for ; Thu, 27 Sep 2018 06:33:52 -0700 (PDT) In-Reply-To: <875zyro5jz.fsf@gmail.com> List-Id: "General discussions about Org-mode." List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: emacs-orgmode-bounces+geo-emacs-orgmode=m.gmane.org@gnu.org Sender: "Emacs-orgmode" To: tumashu , emacs-org list , Nicolas Goaziou --000000000000b2c87a0576da6321 Content-Type: text/plain; charset="UTF-8" On Thu, Sep 27, 2018 at 1:47 AM Eric S Fraga wrote: > On Wednesday, 26 Sep 2018 at 13:11, Kaushal Modi wrote: > > I had been wondering for quite some time (about since 5 months :P) why > > my Org captures have stopped auto-saving. > > This has been really annoying me for some time. Thanks for the code > you've posted which I will try out. I use at least 2 instances of Emacs, 1 > for gnus which often leads to capturing notes and tasks and the others for > writing etc. Not having an automatic save can lead to problems. > I'd suggest reverting that commit. Removing save-buffer from org-capture-finalize, makes the whole concept of Org Capture very unsafe (i.e. no guarantee that the captured date will be saved - unless the finalize hooks workaround is used). It feels like a bit more extra work is needed to make org capture do the "right thing". If the hooks are not configured, then there's a mental overhead of having to save all the capture target buffers manually. @tumashu You can easily avoid saving of the capture target buffers on your phone by adding this to the emacs config just on your phone: (defun advice/dont-save-during-org-capture (orig-fun &rest args) "Make `save-buffer' do nothing during `org-capture-finalize'." (cl-letf (((symbol-function #'save-buffer) (lambda () (message "Skipping `save-buffer' in `org-capture-finalize'") nil))) (apply orig-fun args))) (advice-add 'org-capture-finalize :around #'advice/dont-save-during-org-capture) Above just makes save-buffer to do nothing, but *only* in org-capture-finalize. Summary: - Proposal to revert https://code.orgmode.org/bzg/org-mode/commit/b4422add3745c26ec3b2e11b8da425844b2e9d3d - Use the above advice if you don't want to save buffer during org-capture. --000000000000b2c87a0576da6321 Content-Type: text/html; charset="UTF-8" Content-Transfer-Encoding: quoted-printable
On Thu, Sep 27, 2018 at 1:47 AM Eric S Fraga <esflists@gmail.com> wrote:
=
On Wednesday, 26 Sep 2018= at 13:11, Kaushal Modi wrote:
> I had been wondering for quite some time (about since 5 months :P) why=
> my Org captures have stopped auto-saving.

This has been really annoying me for some time.=C2=A0 Thanks for the code y= ou've posted which I will try out.=C2=A0 I use at least 2 instances of = Emacs, 1 for gnus which often leads to capturing notes and tasks and the ot= hers for writing etc.=C2=A0 Not having an automatic save can lead to proble= ms.

I'd suggest reverting that comm= it.

Removing save-buffer from org-capture-finalize= , makes the whole concept of Org Capture very unsafe (i.e. no guarantee tha= t the captured date will be saved - unless the finalize hooks workaround is= used). It feels like a bit more extra work is needed to make org capture d= o the "right thing". If the hooks are not configured, then there&= #39;s a mental overhead of having to save all the capture target buffers ma= nually.


<= div>(defun advice/dont-save-during-org-capture (orig-fun &rest args)=C2=A0 "Make `save-buffer' do nothing during `org-capture-finaliz= e'."
=C2=A0 (cl-letf (((symbol-function #'save-buffer)
= =C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0 (l= ambda ()
=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2= =A0=C2=A0=C2=A0=C2=A0 (message "Skipping `save-buffer' in `org-cap= ture-finalize'")
=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2= =A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0 nil)))
=C2=A0=C2=A0=C2=A0 (apply= orig-fun args)))
(advice-add 'org-capture-finalize :around #'ad= vice/dont-save-during-org-capture)

<= div>

- Use the above advice if yo= u don't want to save buffer during org-capture.
--000000000000b2c87a0576da6321--