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: emacs-org list <emacs-orgmode@gnu.org>
Subject: Re: Prevent creating empty lines with trailing spaces when tangling noweb
Date: Sat, 06 May 2017 12:59:07 +0000	[thread overview]
Message-ID: <CAFyQvY3Bva9vabc65braQBRf4_-63=X1Y3ZEUYj7JKAjXhVLJg@mail.gmail.com> (raw)
In-Reply-To: <87tw4yfnz8.fsf@nicolasgoaziou.fr>

[-- Attachment #1: Type: text/plain, Size: 1619 bytes --]

On Sat, May 6, 2017, 3:23 AM Nicolas Goaziou <mail@nicolasgoaziou.fr> wrote:

> Hello,
>
> Kaushal Modi <kaushal.modi@gmail.com> 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

[-- Attachment #2: Type: text/html, Size: 2883 bytes --]

      reply	other threads:[~2017-05-06 12:59 UTC|newest]

Thread overview: 4+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2017-05-06  6:30 Prevent creating empty lines with trailing spaces when tangling noweb Kaushal Modi
2017-05-06  6:54 ` Kaushal Modi
2017-05-06  7:23 ` Nicolas Goaziou
2017-05-06 12:59   ` Kaushal Modi [this message]

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='CAFyQvY3Bva9vabc65braQBRf4_-63=X1Y3ZEUYj7JKAjXhVLJg@mail.gmail.com' \
    --to=kaushal.modi@gmail.com \
    --cc=emacs-orgmode@gnu.org \
    --cc=mail@nicolasgoaziou.fr \
    /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).