Browse Source

replace org-babel-noweb-separator variable with :noweb-sep header argument

* doc/org.texi (noweb-sep): Document new header argument.
* lisp/ob.el (org-babel-common-header-args-w-values): Add new header
  argument.
  (org-babel-expand-noweb-references): Use header argument rather than
  customization variable.
Eric Schulte 6 years ago
parent
commit
11d31e89c4
2 changed files with 23 additions and 14 deletions
  1. 14 5
      doc/org.texi
  2. 9 9
      lisp/ob.el

+ 14 - 5
doc/org.texi

@@ -708,6 +708,7 @@ Specific header arguments
 * session::                     Preserve the state of code evaluation
 * noweb::                       Toggle expansion of noweb references
 * noweb-ref::                   Specify block's noweb reference resolution target
+* noweb-sep::                   String used to separate noweb references
 * cache::                       Avoid re-evaluating unchanged code blocks
 * sep::                         Delimiter for writing tabular results outside Org
 * hlines::                      Handle horizontal lines in tables
@@ -13007,6 +13008,7 @@ argument in lowercase letters.  The following header arguments are defined:
 * session::                     Preserve the state of code evaluation
 * noweb::                       Toggle expansion of noweb references
 * noweb-ref::                   Specify block's noweb reference resolution target
+* noweb-sep::                   String used to separate noweb references
 * cache::                       Avoid re-evaluating unchanged code blocks
 * sep::                         Delimiter for writing tabular results outside Org
 * hlines::                      Handle horizontal lines in tables
@@ -13623,7 +13625,7 @@ Note that noweb replacement text that does not contain any newlines will not
 be affected by this change, so it is still possible to use inline noweb
 references.
 
-@node noweb-ref, cache, noweb, Specific header arguments
+@node noweb-ref, noweb-sep, noweb, Specific header arguments
 @subsubsection @code{:noweb-ref}
 When expanding ``noweb'' style references the bodies of all code block with
 @emph{either} a block name matching the reference name @emph{or} a
@@ -13667,11 +13669,18 @@ inheritance}).}.
  #+END_SRC
 @end example
 
-The @code{org-babel-noweb-separator} variable holds the string used to
-separate accumulate noweb references like those above.  By default this
-variable holds a newline.
+The @code{:noweb-sep} (see @ref{noweb-sep}) header argument holds the string
+used to separate accumulate noweb references like those above.  By default a
+newline is used.
 
-@node cache, sep, noweb-ref, Specific header arguments
+@node noweb-sep, cache, noweb-ref, Specific header arguments
+@subsubsection @code{:noweb-sep}
+
+The @code{:noweb-sep} header argument holds the string used to separate
+accumulate noweb references (see @ref{noweb-ref}).  By default a newline is
+used.
+
+@node cache, sep, noweb-sep, Specific header arguments
 @subsubsection @code{:cache}
 
 The @code{:cache} header argument controls the use of in-buffer caching of

+ 9 - 9
lisp/ob.el

@@ -120,11 +120,6 @@ be used."
   :group 'org-babel
   :type 'string)
 
-(defcustom org-babel-noweb-separator "\n"
-  "String used to separate accumulated noweb references."
-  :group 'org-babel
-  :type 'string)
-
 (defvar org-babel-src-name-regexp
   "^[ \t]*#\\+name:[ \t]*"
   "Regular expression used to match a source name line.")
@@ -388,6 +383,7 @@ then run `org-babel-pop-to-session'."
     (noeval)
     (noweb	. ((yes no tangle)))
     (noweb-ref	. :any)
+    (noweb-sep  . :any)
     (padline	. ((yes no)))
     (results	. ((file list vector table scalar verbatim)
 		    (raw org html latex code pp wrap)
@@ -2192,6 +2188,8 @@ block but are passed literally to the \"example-block\"."
 			  (while (re-search-forward rx nil t)
 			    (let* ((i (org-babel-get-src-block-info 'light))
 				   (body (org-babel-expand-noweb-references i))
+				   (sep (or (cdr (assoc :noweb-sep (nth 2 i)))
+					    "\n"))
 				   (full (if comment
 					     ((lambda (cs)
 						(concat (c-wrap (car cs)) "\n"
@@ -2199,13 +2197,15 @@ block but are passed literally to the \"example-block\"."
 							(c-wrap (cadr cs))))
 					      (org-babel-tangle-comment-links i))
 					   body)))
-			      (setq expansion (cons full expansion))))
+			      (setq expansion (cons sep (cons full expansion)))))
 			(org-babel-map-src-blocks nil
 			  (let ((i (org-babel-get-src-block-info 'light)))
 			    (when (equal (or (cdr (assoc :noweb-ref (nth 2 i)))
 					     (nth 4 i))
 					 source-name)
 			      (let* ((body (org-babel-expand-noweb-references i))
+				     (sep (or (cdr (assoc :noweb-sep (nth 2 i)))
+					      "\n"))
 				     (full (if comment
 					       ((lambda (cs)
 						  (concat (c-wrap (car cs)) "\n"
@@ -2213,9 +2213,9 @@ block but are passed literally to the \"example-block\"."
 							  (c-wrap (cadr cs))))
 						(org-babel-tangle-comment-links i))
 					     body)))
-				(setq expansion (cons full expansion))))))))
-		    (mapconcat #'identity (nreverse expansion)
-			       org-babel-noweb-separator))
+				(setq expansion
+				      (cons sep (cons full expansion)))))))))
+		    (mapconcat #'identity (nreverse (cdr expansion)) ""))
 		  ;; possibly raise an error if named block doesn't exist
 		  (if (member lang org-babel-noweb-error-langs)
 		      (error "%s" (concat