emacs-orgmode
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: [O] Prevent creating empty lines with trailing spaces when tangling


From: Kaushal Modi
Subject: Re: [O] Prevent creating empty lines with trailing spaces when tangling noweb
Date: Sat, 06 May 2017 06:54:06 +0000

On Sat, May 6, 2017 at 2:30 AM Kaushal Modi <address@hidden> 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

PNG image

PNG image


reply via email to

[Prev in Thread] Current Thread [Next in Thread]