1
0
mirror of https://git.savannah.gnu.org/git/emacs/org-mode.git synced 2024-11-23 07:18:53 +00:00

Merge branch 'origin-maint'

This commit is contained in:
Eric Schulte 2012-01-24 00:02:52 -07:00
commit 2395c3eff1
4 changed files with 26 additions and 16 deletions

View File

@ -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
@ -13017,6 +13018,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
@ -13640,7 +13642,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
@ -13684,11 +13686,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

View File

@ -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)
@ -2204,6 +2200,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"
@ -2211,13 +2209,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"
@ -2225,9 +2225,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

View File

@ -217,6 +217,7 @@ src_sh{echo 3} Here is one at the beginning of a line.
* using the =:noweb-ref= header argument
:PROPERTIES:
:ID: 54d68d4b-1544-4745-85ab-4f03b3cbd8a0
:noweb-sep: ""
:END:
#+begin_src sh :tangle yes :noweb yes :shebang #!/bin/sh

View File

@ -644,11 +644,11 @@ on two lines
#+end_src
#+name: foo
#+begin_src sh
#+begin_src sh :noweb-sep \"\"
bar
#+end_src
#+begin_src sh :noweb-ref foo
#+begin_src sh :noweb-ref foo :noweb-sep \"\"
baz
#+end_src"
(should (string= (org-babel-expand-noweb-references) "barbaz"))))