From mboxrd@z Thu Jan 1 00:00:00 1970 From: Kaushal Modi Subject: Re: Prevent creating empty lines with trailing spaces when tangling noweb Date: Sat, 06 May 2017 12:59:07 +0000 Message-ID: References: <87tw4yfnz8.fsf@nicolasgoaziou.fr> Mime-Version: 1.0 Content-Type: multipart/alternative; boundary=f403045f9f94f1f4a5054eda9263 Return-path: Received: from eggs.gnu.org ([2001:4830:134:3::10]:40659) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1d6zIw-0000QX-32 for emacs-orgmode@gnu.org; Sat, 06 May 2017 08:59:23 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1d6zIu-0007Vt-Gv for emacs-orgmode@gnu.org; Sat, 06 May 2017 08:59:21 -0400 Received: from mail-lf0-x22b.google.com ([2a00:1450:4010:c07::22b]:32958) by eggs.gnu.org with esmtps (TLS1.0:RSA_AES_128_CBC_SHA1:16) (Exim 4.71) (envelope-from ) id 1d6zIu-0007V7-5O for emacs-orgmode@gnu.org; Sat, 06 May 2017 08:59:20 -0400 Received: by mail-lf0-x22b.google.com with SMTP id r17so15275510lfg.0 for ; Sat, 06 May 2017 05:59:19 -0700 (PDT) In-Reply-To: <87tw4yfnz8.fsf@nicolasgoaziou.fr> 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: Nicolas Goaziou Cc: emacs-org list --f403045f9f94f1f4a5054eda9263 Content-Type: text/plain; charset=UTF-8 On Sat, May 6, 2017, 3:23 AM Nicolas Goaziou wrote: > Hello, > > Kaushal Modi writes: > > I'd rather clean every empty line upon tangling, or let the user do it > with `org-babel-post-tangle-hook'. I just tried this again and it worked this time! (add-hook 'org-babel-post-tangle-hook #'delete-trailing-whitespace) (add-hook 'org-babel-post-tangle-hook #'save-buffer :append) Thanks! Some back-story on what led me to modify ob-core.el: I did try changing the hook earlier, but that did not work. So this was my next attempt[1], and that led me to try this approach of preventing white spaces in the first place. Earlier I was also trying to tangle using ox-publish with this element in org-publish-project-alist: ("foo" :base-directory "/some/dir" :publishing-function org-babel-tangle-publish :publishing-directory "/some/dir") Probably the base directory and publishing directory being the same caused some issue with saving the buffer after delete-trailing-whitespace. So I ended up having to manually save the tangled file after each publish step. Or probably I somehow didn't have the hooks right. After that I switched to calling just the below separately instead of tangling through publish step: (org-babel-tangle file FILE) And now with the above hook modifications, the deletion of whitespaces is working exactly as I wanted. Well, that was an interesting journey. [1]: https://github.com/kaushalmodi/eless/blob/aa060eaede906e6bd4205f997074e7048c0c810c/build/build.el#L28-L47 -- Kaushal Modi --f403045f9f94f1f4a5054eda9263 Content-Type: text/html; charset=UTF-8 Content-Transfer-Encoding: quoted-printable
On Sat, M= ay 6, 2017, 3:23 AM Nicolas Goaziou <mail@nicolasgoaziou.fr> wrote:
Hello,

Kaushal Modi <kaushal.modi@gmail.com> writes:
<= div class=3D"gmail_quote">

I'd rather clean every empty line upon tangling, or let the user do it<= br> with `org-babel-post-tangle-hook'.

I just tried this again and it worked this time!
=C2=A0 =C2=A0 (add-hook 'org-babel-post-tangle-ho= ok #'delete-trailing-whitespace)
=C2=A0 =C2=A0 (add-hook '= ;org-babel-post-tangle-hook #'save-buffer :append)

=
Thanks!

Some back-story on what led me to mo= dify ob-core.el:

I did try changing the hook earli= er, but that did not work. So this was my next attempt[1], and that led me = to try this approach of preventing white spaces in the first place.=C2=A0

Earlier I was also trying to tangle using ox-publis= h with this element in org-publish-project-alist:

<= div>
=C2=A0 =C2=A0 =C2=A0 =C2=A0 ("foo"
=C2=A0 =C2= =A0 =C2=A0 =C2=A0 =C2=A0:base-directory "/some/dir"
=C2= =A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0:publishing-function org-babel-tangle-publis= h
=C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0:publishing-directory "/= some/dir")

Probably the base directory = and publishing directory being the same caused some issue with saving the b= uffer after delete-trailing-whitespace. So I ended up having to manually sa= ve the tangled file after each publish step.

Or pr= obably I somehow didn't have the hooks right.

= After that I switched to calling just the below separately instead of tangl= ing through publish step:

=C2=A0 =C2=A0 (org-babel= -tangle file FILE)

And now with the above hook mod= ifications, the deletion of whitespaces is working exactly as I wanted.

Well, that was an interesting journey.

=
<= span>
--

Kaushal Modi

--f403045f9f94f1f4a5054eda9263--