emacs-elpa-diffs
[Top][All Lists]
Advanced

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

[elpa] externals/org 1523e21d82 1/2: org-babel-expand-noweb-references:


From: ELPA Syncer
Subject: [elpa] externals/org 1523e21d82 1/2: org-babel-expand-noweb-references: Add trialing newline after comments
Date: Sat, 4 May 2024 09:58:33 -0400 (EDT)

branch: externals/org
commit 1523e21d829dce3b2e41113702c2e90b6f7e258a
Author: Ihor Radchenko <yantar92@posteo.net>
Commit: Ihor Radchenko <yantar92@posteo.net>

    org-babel-expand-noweb-references: Add trialing newline after comments
    
    * lisp/ob-core.el (org-babel-expand-noweb-references): After closing
    comment, when using :comments noweb, leave trailing newline after the
    closing comment.
    * testing/lisp/test-ob-tangle.el (ob-tangle/comment-noweb-relative):
    Modify test to check for the newline.
    
    Reported-by: João Pedro <jpedrodeamorim@gmail.com>
    Link: https://orgmode.org/list/87fruy2rw6.fsf@ergo
---
 lisp/ob-core.el                | 78 +++++++++++++++++++++---------------------
 testing/lisp/test-ob-tangle.el | 26 +++++++-------
 2 files changed, 52 insertions(+), 52 deletions(-)

diff --git a/lisp/ob-core.el b/lisp/ob-core.el
index 470db9fe6f..d7f6241cbe 100644
--- a/lisp/ob-core.el
+++ b/lisp/ob-core.el
@@ -3136,47 +3136,47 @@ block but are passed literally to the 
\"example-block\"."
                   (with-current-buffer parent-buffer
                     (buffer-chars-modified-tick)))))
     (cl-macrolet ((c-wrap
-                  (s)
-                  ;; Comment string S, according to LANG mode.  Return new
-                  ;; string.
-                  `(unless org-babel-tangle-uncomment-comments
-                     (with-temp-buffer
-                       (funcall (org-src-get-lang-mode lang))
-                       (comment-region (point)
-                                       (progn (insert ,s) (point)))
-                       (org-trim (buffer-string)))))
+                   (s)
+                   ;; Comment string S, according to LANG mode.  Return new
+                   ;; string.
+                   `(unless org-babel-tangle-uncomment-comments
+                      (with-temp-buffer
+                        (funcall (org-src-get-lang-mode lang))
+                        (comment-region (point)
+                                        (progn (insert ,s) (point)))
+                        (org-trim (buffer-string)))))
                  (expand-body
-                  (i)
-                  ;; Expand body of code represented by block info I.
-                  `(let ((b (if (org-babel-noweb-p (nth 2 ,i) :eval)
-                                (org-babel-expand-noweb-references ,i)
-                              (nth 1 ,i))))
-                     (if (not comment) b
-                       (let ((cs (org-babel-tangle-comment-links ,i)))
-                         (concat (c-wrap (car cs)) "\n"
-                                 b "\n"
-                                 (c-wrap (cadr cs)))))))
+                   (i)
+                   ;; Expand body of code represented by block info I.
+                   `(let ((b (if (org-babel-noweb-p (nth 2 ,i) :eval)
+                                 (org-babel-expand-noweb-references ,i)
+                               (nth 1 ,i))))
+                      (if (not comment) b
+                        (let ((cs (org-babel-tangle-comment-links ,i)))
+                          (concat (c-wrap (car cs)) "\n"
+                                  b "\n"
+                                  (c-wrap (cadr cs)) "\n")))))
                  (expand-references
-                  (ref)
-                  `(pcase (gethash ,ref 
org-babel-expand-noweb-references--cache)
-                     (`(,last . ,previous)
-                      ;; Ignore separator for last block.
-                      (let ((strings (list (expand-body last))))
-                        (dolist (i previous)
-                          (let ((parameters (nth 2 i)))
-                            ;; Since we're operating in reverse order, first
-                            ;; push separator, then body.
-                            (push (or (cdr (assq :noweb-sep parameters)) "\n")
-                                  strings)
-                            (push (expand-body i) strings)))
-                        (mapconcat #'identity strings "")))
-                     ;; Raise an error about missing reference, or return the
-                     ;; empty string.
-                     ((guard (or org-babel-noweb-error-all-langs
-                                 (member lang org-babel-noweb-error-langs)))
-                      (error "Cannot resolve %s (see 
`org-babel-noweb-error-langs')"
-                             (org-babel-noweb-wrap ,ref)))
-                     (_ ""))))
+                   (ref)
+                   `(pcase (gethash ,ref 
org-babel-expand-noweb-references--cache)
+                      (`(,last . ,previous)
+                       ;; Ignore separator for last block.
+                       (let ((strings (list (expand-body last))))
+                         (dolist (i previous)
+                           (let ((parameters (nth 2 i)))
+                             ;; Since we're operating in reverse order, first
+                             ;; push separator, then body.
+                             (push (or (cdr (assq :noweb-sep parameters)) "\n")
+                                   strings)
+                             (push (expand-body i) strings)))
+                         (mapconcat #'identity strings "")))
+                      ;; Raise an error about missing reference, or return the
+                      ;; empty string.
+                      ((guard (or org-babel-noweb-error-all-langs
+                                  (member lang org-babel-noweb-error-langs)))
+                       (error "Cannot resolve %s (see 
`org-babel-noweb-error-langs')"
+                              (org-babel-noweb-wrap ,ref)))
+                      (_ ""))))
       (replace-regexp-in-string
        noweb-re
        (lambda (m)
diff --git a/testing/lisp/test-ob-tangle.el b/testing/lisp/test-ob-tangle.el
index 7054136984..e13bca0cbf 100644
--- a/testing/lisp/test-ob-tangle.el
+++ b/testing/lisp/test-ob-tangle.el
@@ -191,20 +191,20 @@ echo 1
 * Main
 #+header: :tangle \"test-ob-tangle.el\" :comments noweb :noweb yes
 #+begin_src emacs-lisp
-1
-<<inner>>
+'(1
+<<inner>>)
 #+end_src"
-     (unwind-protect
-        (let ((org-babel-tangle-use-relative-file-links t))
-           (org-babel-tangle)
-           (with-temp-buffer
-             (insert-file-contents "test-ob-tangle.el")
-             (buffer-string)
-             (goto-char (point-min))
-             (and
-              (search-forward (concat ";; [[file:" (file-name-nondirectory 
file) "::inner") nil t)
-              (search-forward ";; inner ends here" nil t))))
-       (delete-file "test-ob-tangle.el")))))
+    (unwind-protect
+       (let ((org-babel-tangle-use-relative-file-links t))
+          (org-babel-tangle)
+          (with-temp-buffer
+            (insert-file-contents "test-ob-tangle.el")
+            (buffer-string)
+            (goto-char (point-min))
+            (and
+             (search-forward (concat ";; [[file:" (file-name-nondirectory 
file) "::inner") nil t)
+             (search-forward ";; inner ends here\n" nil t))))
+      (delete-file "test-ob-tangle.el")))))
 
 (ert-deftest ob-tangle/comment-noweb-absolute ()
   "Test :comments noweb tangling with absolute file path."



reply via email to

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