Przeglądaj źródła

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 13 lat temu
rodzic
commit
11d31e89c4
2 zmienionych plików z 23 dodań i 14 usunięć
  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
 * session::                     Preserve the state of code evaluation
 * noweb::                       Toggle expansion of noweb references
 * noweb::                       Toggle expansion of noweb references
 * noweb-ref::                   Specify block's noweb reference resolution target
 * noweb-ref::                   Specify block's noweb reference resolution target
+* noweb-sep::                   String used to separate noweb references
 * cache::                       Avoid re-evaluating unchanged code blocks
 * cache::                       Avoid re-evaluating unchanged code blocks
 * sep::                         Delimiter for writing tabular results outside Org
 * sep::                         Delimiter for writing tabular results outside Org
 * hlines::                      Handle horizontal lines in tables
 * 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
 * session::                     Preserve the state of code evaluation
 * noweb::                       Toggle expansion of noweb references
 * noweb::                       Toggle expansion of noweb references
 * noweb-ref::                   Specify block's noweb reference resolution target
 * noweb-ref::                   Specify block's noweb reference resolution target
+* noweb-sep::                   String used to separate noweb references
 * cache::                       Avoid re-evaluating unchanged code blocks
 * cache::                       Avoid re-evaluating unchanged code blocks
 * sep::                         Delimiter for writing tabular results outside Org
 * sep::                         Delimiter for writing tabular results outside Org
 * hlines::                      Handle horizontal lines in tables
 * 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
 be affected by this change, so it is still possible to use inline noweb
 references.
 references.
 
 
-@node noweb-ref, cache, noweb, Specific header arguments
+@node noweb-ref, noweb-sep, noweb, Specific header arguments
 @subsubsection @code{:noweb-ref}
 @subsubsection @code{:noweb-ref}
 When expanding ``noweb'' style references the bodies of all code block with
 When expanding ``noweb'' style references the bodies of all code block with
 @emph{either} a block name matching the reference name @emph{or} a
 @emph{either} a block name matching the reference name @emph{or} a
@@ -13667,11 +13669,18 @@ inheritance}).}.
  #+END_SRC
  #+END_SRC
 @end example
 @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}
 @subsubsection @code{:cache}
 
 
 The @code{:cache} header argument controls the use of in-buffer caching of
 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
   :group 'org-babel
   :type 'string)
   :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
 (defvar org-babel-src-name-regexp
   "^[ \t]*#\\+name:[ \t]*"
   "^[ \t]*#\\+name:[ \t]*"
   "Regular expression used to match a source name line.")
   "Regular expression used to match a source name line.")
@@ -388,6 +383,7 @@ then run `org-babel-pop-to-session'."
     (noeval)
     (noeval)
     (noweb	. ((yes no tangle)))
     (noweb	. ((yes no tangle)))
     (noweb-ref	. :any)
     (noweb-ref	. :any)
+    (noweb-sep  . :any)
     (padline	. ((yes no)))
     (padline	. ((yes no)))
     (results	. ((file list vector table scalar verbatim)
     (results	. ((file list vector table scalar verbatim)
 		    (raw org html latex code pp wrap)
 		    (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)
 			  (while (re-search-forward rx nil t)
 			    (let* ((i (org-babel-get-src-block-info 'light))
 			    (let* ((i (org-babel-get-src-block-info 'light))
 				   (body (org-babel-expand-noweb-references i))
 				   (body (org-babel-expand-noweb-references i))
+				   (sep (or (cdr (assoc :noweb-sep (nth 2 i)))
+					    "\n"))
 				   (full (if comment
 				   (full (if comment
 					     ((lambda (cs)
 					     ((lambda (cs)
 						(concat (c-wrap (car cs)) "\n"
 						(concat (c-wrap (car cs)) "\n"
@@ -2199,13 +2197,15 @@ block but are passed literally to the \"example-block\"."
 							(c-wrap (cadr cs))))
 							(c-wrap (cadr cs))))
 					      (org-babel-tangle-comment-links i))
 					      (org-babel-tangle-comment-links i))
 					   body)))
 					   body)))
-			      (setq expansion (cons full expansion))))
+			      (setq expansion (cons sep (cons full expansion)))))
 			(org-babel-map-src-blocks nil
 			(org-babel-map-src-blocks nil
 			  (let ((i (org-babel-get-src-block-info 'light)))
 			  (let ((i (org-babel-get-src-block-info 'light)))
 			    (when (equal (or (cdr (assoc :noweb-ref (nth 2 i)))
 			    (when (equal (or (cdr (assoc :noweb-ref (nth 2 i)))
 					     (nth 4 i))
 					     (nth 4 i))
 					 source-name)
 					 source-name)
 			      (let* ((body (org-babel-expand-noweb-references i))
 			      (let* ((body (org-babel-expand-noweb-references i))
+				     (sep (or (cdr (assoc :noweb-sep (nth 2 i)))
+					      "\n"))
 				     (full (if comment
 				     (full (if comment
 					       ((lambda (cs)
 					       ((lambda (cs)
 						  (concat (c-wrap (car cs)) "\n"
 						  (concat (c-wrap (car cs)) "\n"
@@ -2213,9 +2213,9 @@ block but are passed literally to the \"example-block\"."
 							  (c-wrap (cadr cs))))
 							  (c-wrap (cadr cs))))
 						(org-babel-tangle-comment-links i))
 						(org-babel-tangle-comment-links i))
 					     body)))
 					     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
 		  ;; possibly raise an error if named block doesn't exist
 		  (if (member lang org-babel-noweb-error-langs)
 		  (if (member lang org-babel-noweb-error-langs)
 		      (error "%s" (concat
 		      (error "%s" (concat