From: Kaushal Modi <kaushal.modi@gmail.com>
To: emacs-org list <emacs-orgmode@gnu.org>
Subject: Re: Prevent creating empty lines with trailing spaces when tangling noweb
Date: Sat, 06 May 2017 06:54:06 +0000 [thread overview]
Message-ID: <CAFyQvY3JgtGMfz2PBrggUzOzDvQV9NS0wZ9Ddj-VypfEc49NEA@mail.gmail.com> (raw)
In-Reply-To: <CAFyQvY1cLjuEyqc_EhyjV2g67sFwws5wLtaSaPDCmCXhaJv6sg@mail.gmail.com>
[-- Attachment #1.1: Type: text/plain, Size: 1347 bytes --]
On Sat, May 6, 2017 at 2:30 AM Kaushal Modi <kaushal.modi@gmail.com> wrote:
> + (setq body-str (replace-regexp-in-string "^[ \n\r]*\n" "\n"
> body-str)))
>
>
Just one correction to this regexp so that two or more consecutive empty
lines in the source block get retained:
(setq body-str (replace-regexp-in-string "^[ ]+\n" "\n" body-str))
Here's the draft diff again:
diff --git a/lisp/ob-core.el b/lisp/ob-core.el
index cb332ffea92..96628f44ab4 100644
--- a/lisp/ob-core.el
+++ b/lisp/ob-core.el
@@ -2730,9 +2730,7 @@ block but are passed literally to the
\"example-block\"."
(funcall nb-add (buffer-substring index (point)))
(goto-char (match-end 0))
(setq index (point))
- (funcall
- nb-add
- (with-current-buffer parent-buffer
+ (let ((body-str (with-current-buffer parent-buffer
(save-restriction
(widen)
(mapconcat ;; Interpose PREFIX between every line.
@@ -2794,6 +2792,9 @@ block but are passed literally to the
\"example-block\"."
"`org-babel-noweb-error-langs')"))
"")))
"[\n\r]") (concat "\n" prefix))))))
+ (when (string= "yes" (cdr (assq :noweb-notrailingspc (nth 2 info))))
+ (setq body-str (replace-regexp-in-string "^[ ]+\n" "\n" body-str)))
+ (funcall nb-add body-str)))
(funcall nb-add (buffer-substring index (point-max))))
new-body))
--
Kaushal Modi
[-- Attachment #1.2: Type: text/html, Size: 3219 bytes --]
[-- Attachment #2: image.png --]
[-- Type: image/png, Size: 17908 bytes --]
[-- Attachment #3: image.png --]
[-- Type: image/png, Size: 17794 bytes --]
next prev parent reply other threads:[~2017-05-06 6:54 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 [this message]
2017-05-06 7:23 ` Nicolas Goaziou
2017-05-06 12:59 ` Kaushal Modi
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=CAFyQvY3JgtGMfz2PBrggUzOzDvQV9NS0wZ9Ddj-VypfEc49NEA@mail.gmail.com \
--to=kaushal.modi@gmail.com \
--cc=emacs-orgmode@gnu.org \
/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).