Commit 666ffc7e authored by Stefan Monnier's avatar Stefan Monnier
Browse files

Address some byte-compiler warnings.

* lisp/org/ob-abc.el (org-babel-expand-body:abc): Use dolist.
(org-babel-execute:abc): Fix regexp quoting.
* lisp/org/ob-calc.el (org--var-syms): Rename from `var-syms'.
* lisp/org/ob-lilypond.el (ly-compile-lilyfile): Remove redundant let-binding.
* lisp/org/ob-table.el (sbe): Move debug declaration.
* lisp/org/org-clock.el (org--msg-extra): Rename from `msg-extra'.
* lisp/org/org.el (org-version): Avoid var name starting with _.
(org-inhibit-startup, org-called-with-limited-levels)
(org-link-search-inhibit-query, org-time-was-given)
(org-end-time-was-given, org-def, org-defdecode, org-with-time):
* lisp/org/org-colview.el (org-agenda-overriding-columns-format):
* lisp/org/org-agenda.el (org-agenda-multi, org-depend-tag-blocked)
(org-agenda-show-log-scoped):
* lisp/org/ob-python.el (py-which-bufname, python-shell-buffer-name):
* lisp/org/ob-haskell.el (org-export-copy-to-kill-ring):
* lisp/org/ob-exp.el (org-link-search-inhibit-query):
* lisp/org/ob-R.el (ess-eval-visibly-p):
* lisp/org/ob-core.el (org-src-window-setup): Declare before use.
(org-babel-expand-noweb-references): Remove unused `blocks-in-buffer'.
* lisp/org/ox-odt.el (org-odt-hfy-face-to-css):
* lisp/org/org-src.el (org-src-associate-babel-session, org-src-get-lang-mode):
* lisp/org/org-bibtex.el (org-bibtex-get, org-bibtex-ask, org-bibtex)
(org-bibtex-check):
* lisp/org/ob-tangle.el (org-babel-tangle, org-babel-spec-to-string)
(org-babel-tangle-single-block, org-babel-tangle-comment-links):
* ob-table.el (sbe):
* lisp/org/ob-sqlite.el (org-babel-sqlite-expand-vars):
* lisp/org/ob-sql.el (org-babel-sql-expand-vars):
* lisp/org/ob-shen.el (org-babel-execute:shen):
* lisp/org/ob-sh.el (org-babel-execute:sh, org-babel-sh-evaluate):
* lisp/org/ob-scala.el (org-babel-scala-evaluate):
* lisp/org/ob-ruby.el (org-babel-ruby-table-or-string)
(org-babel-ruby-evaluate):
* ob-python.el (org-babel-python-table-or-string)
(org-babel-python-evaluate-external-process)
(org-babel-python-evaluate-session):
* lisp/org/ob-picolisp.el (org-babel-execute:picolisp):
* lisp/org/ob-perl.el (org-babel-perl-evaluate):
* lisp/org/ob-maxima.el (org-babel-execute:maxima):
* lisp/org/ob-lisp.el (org-babel-execute:lisp):
* lisp/org/ob-java.el (org-babel-execute:java):
* lisp/org/ob-io.el (org-babel-io-evaluate):
* ob-haskell.el (org-babel-execute:haskell):
* lisp/org/ob-fortran.el (org-babel-execute:fortran):
* ob-exp.el (org-babel-exp-code):
* lisp/org/ob-emacs-lisp.el (org-babel-execute:emacs-lisp):
* lisp/org/ob-ditaa.el (org-babel-execute:ditaa):
* ob-core.el (org-babel-execute-src-block, org-babel-sha1-hash)
(org-babel-parse-header-arguments, org-babel-reassemble-table)
(org-babel-goto-src-block-head, org-babel-mark-block)
(org-babel-expand-noweb-references, org-babel-script-escape)
(org-babel-process-file-name):
* lisp/org/ob-clojure.el (org-babel-execute:clojure):
* ob-calc.el (org-babel-execute:calc):
* lisp/org/ob-awk.el (org-babel-execute:awk):
* ob-abc.el (org-babel-execute:abc):
* ob-R.el (org-babel-expand-body:R):
* lisp/org/ob-C.el (org-babel-C-execute): Avoid deprecated ((lambda) ...).
parent 32d15ad9
2013-11-12 Stefan Monnier <monnier@iro.umontreal.ca>
Address some byte-compiler warnings.
* ob-abc.el (org-babel-expand-body:abc): Use dolist.
(org-babel-execute:abc): Fix regexp quoting.
* ob-calc.el (org--var-syms): Rename from `var-syms'.
* ob-lilypond.el (ly-compile-lilyfile): Remove redundant let-binding.
* ob-table.el (sbe): Move debug declaration.
* org-clock.el (org--msg-extra): Rename from `msg-extra'.
* org.el (org-version): Avoid var name starting with _.
(org-inhibit-startup, org-called-with-limited-levels)
(org-link-search-inhibit-query, org-time-was-given)
(org-end-time-was-given, org-def, org-defdecode, org-with-time):
* org-colview.el (org-agenda-overriding-columns-format):
* org-agenda.el (org-agenda-multi, org-depend-tag-blocked)
(org-agenda-show-log-scoped):
* ob-python.el (py-which-bufname, python-shell-buffer-name):
* ob-haskell.el (org-export-copy-to-kill-ring):
* ob-exp.el (org-link-search-inhibit-query):
* ob-R.el (ess-eval-visibly-p):
* ob-core.el (org-src-window-setup): Declare before use.
(org-babel-expand-noweb-references): Remove unused `blocks-in-buffer'.
* ox-odt.el (org-odt-hfy-face-to-css):
* org-src.el (org-src-associate-babel-session, org-src-get-lang-mode):
* org-bibtex.el (org-bibtex-get, org-bibtex-ask, org-bibtex)
(org-bibtex-check):
* ob-tangle.el (org-babel-tangle, org-babel-spec-to-string)
(org-babel-tangle-single-block, org-babel-tangle-comment-links):
* ob-table.el (sbe):
* ob-sqlite.el (org-babel-sqlite-expand-vars):
* ob-sql.el (org-babel-sql-expand-vars):
* ob-shen.el (org-babel-execute:shen):
* ob-sh.el (org-babel-execute:sh, org-babel-sh-evaluate):
* ob-scala.el (org-babel-scala-evaluate):
* ob-ruby.el (org-babel-ruby-table-or-string)
(org-babel-ruby-evaluate):
* ob-python.el (org-babel-python-table-or-string)
(org-babel-python-evaluate-external-process)
(org-babel-python-evaluate-session):
* ob-picolisp.el (org-babel-execute:picolisp):
* ob-perl.el (org-babel-perl-evaluate):
* ob-maxima.el (org-babel-execute:maxima):
* ob-lisp.el (org-babel-execute:lisp):
* ob-java.el (org-babel-execute:java):
* ob-io.el (org-babel-io-evaluate):
* ob-haskell.el (org-babel-execute:haskell):
* ob-fortran.el (org-babel-execute:fortran):
* ob-exp.el (org-babel-exp-code):
* ob-emacs-lisp.el (org-babel-execute:emacs-lisp):
* ob-ditaa.el (org-babel-execute:ditaa):
* ob-core.el (org-babel-execute-src-block, org-babel-sha1-hash)
(org-babel-parse-header-arguments, org-babel-reassemble-table)
(org-babel-goto-src-block-head, org-babel-mark-block)
(org-babel-expand-noweb-references, org-babel-script-escape)
(org-babel-process-file-name):
* ob-clojure.el (org-babel-execute:clojure):
* ob-calc.el (org-babel-execute:calc):
* ob-awk.el (org-babel-execute:awk):
* ob-abc.el (org-babel-execute:abc):
* ob-R.el (org-babel-expand-body:R):
* ob-C.el (org-babel-C-execute): Avoid deprecated ((lambda) ...).
2013-11-12 Glenn Morris <rgm@gnu.org>
 
* ox-html.el (org-html-scripts): Add 2013 to copyright years.
......@@ -14,7 +76,7 @@
* ob-python.el: Update the arglist passed to `declare-function'
for `run-python'.
 
* ob-tangle.el (org-babel-tangle): Use 'light argument to
* ob-tangle.el (org-babel-tangle): Use `light' argument to
`org-babel-get-src-block-info'.
 
* ob-core.el (org-babel-execute-src-block): Return nil in case of
......@@ -5191,7 +5253,7 @@
* org-clock.el (org-clock-notify-once-if-expired): Honor
`org-clock-sound'.
 
2013-11-12 Rasmus Pank <rasmus.pank@gmail.com>
2013-11-12 Rasmus Pank <rasmus.pank@gmail.com>
 
* org.el (org-format-latex-header): Remove eucal and amsmath.
(org-latex-default-packages-alist): Remove amstext and add
......@@ -103,20 +103,21 @@ or `org-babel-execute:C++'."
(mapconcat 'identity
(if (listp flags) flags (list flags)) " ")
(org-babel-process-file-name tmp-src-file)) ""))))
((lambda (results)
(org-babel-reassemble-table
(org-babel-result-cond (cdr (assoc :result-params params))
(org-babel-read results)
(let ((tmp-file (org-babel-temp-file "c-")))
(with-temp-file tmp-file (insert results))
(org-babel-import-elisp-from-file tmp-file)))
(org-babel-pick-name
(cdr (assoc :colname-names params)) (cdr (assoc :colnames params)))
(org-babel-pick-name
(cdr (assoc :rowname-names params)) (cdr (assoc :rownames params)))))
(org-babel-trim
(org-babel-eval
(concat tmp-bin-file (if cmdline (concat " " cmdline) "")) "")))))
(let ((results
(org-babel-trim
(org-babel-eval
(concat tmp-bin-file (if cmdline (concat " " cmdline) "")) ""))))
(org-babel-reassemble-table
(org-babel-result-cond (cdr (assoc :result-params params))
(org-babel-read results)
(let ((tmp-file (org-babel-temp-file "c-")))
(with-temp-file tmp-file (insert results))
(org-babel-import-elisp-from-file tmp-file)))
(org-babel-pick-name
(cdr (assoc :colname-names params)) (cdr (assoc :colnames params)))
(org-babel-pick-name
(cdr (assoc :rowname-names params)) (cdr (assoc :rownames params)))))
))
(defun org-babel-C-expand (body params)
"Expand a block of C or C++ code with org-babel according to
......
......@@ -85,21 +85,22 @@
(or graphics-file (org-babel-R-graphical-output-file params))))
(mapconcat
#'identity
((lambda (inside)
(if graphics-file
(append
(list (org-babel-R-construct-graphics-device-call
graphics-file params))
inside
(list "dev.off()"))
inside))
(append
(when (cdr (assoc :prologue params))
(list (cdr (assoc :prologue params))))
(org-babel-variable-assignments:R params)
(list body)
(when (cdr (assoc :epilogue params))
(list (cdr (assoc :epilogue params)))))) "\n")))
(let ((inside
(append
(when (cdr (assoc :prologue params))
(list (cdr (assoc :prologue params))))
(org-babel-variable-assignments:R params)
(list body)
(when (cdr (assoc :epilogue params))
(list (cdr (assoc :epilogue params)))))))
(if graphics-file
(append
(list (org-babel-R-construct-graphics-device-call
graphics-file params))
inside
(list "dev.off()"))
inside))
"\n")))
(defun org-babel-execute:R (body params)
"Execute a block of R code.
......@@ -324,6 +325,8 @@ last statement in BODY, as elisp."
column-names-p)))
(output (org-babel-eval org-babel-R-command body))))
(defvar ess-eval-visibly-p)
(defun org-babel-R-evaluate-session
(session body result-type result-params column-names-p row-names-p)
"Evaluate BODY in SESSION.
......
......@@ -24,9 +24,11 @@
;;; Commentary:
;;; This file adds support to Org Babel for music in ABC notation.
;;; It requires that the abcm2ps program is installed.
;;; See http://moinejf.free.fr/
;; This file adds support to Org Babel for music in ABC notation.
;; It requires that the abcm2ps program is installed.
;; See http://moinejf.free.fr/
;;; Code:
(require 'ob)
......@@ -40,18 +42,15 @@
(defun org-babel-expand-body:abc (body params)
"Expand BODY according to PARAMS, return the expanded body."
(let ((vars (mapcar #'cdr (org-babel-get-header params :var))))
(mapc
(lambda (pair)
(let ((name (symbol-name (car pair)))
(value (cdr pair)))
(setq body
(replace-regexp-in-string
(concat "\$" (regexp-quote name))
(if (stringp value) value (format "%S" value))
body))))
vars)
body))
(dolist (pair (mapcar #'cdr (org-babel-get-header params :var)))
(let ((name (symbol-name (car pair)))
(value (cdr pair)))
(setq body
(replace-regexp-in-string
(concat "\$" (regexp-quote name)) ;FIXME: "\$" == "$"!
(if (stringp value) value (format "%S" value))
body))))
body)
(defun org-babel-execute:abc (body params)
"Execute a block of ABC code with org-babel. This function is
......@@ -59,10 +58,10 @@
(message "executing Abc source code block")
(let* ((result-params (split-string (or (cdr (assoc :results params)))))
(cmdline (cdr (assoc :cmdline params)))
(out-file ((lambda (el)
(or el
(error "abc code block requires :file header argument")))
(replace-regexp-in-string "\.pdf$" ".ps" (cdr (assoc :file params)))))
(out-file
(let ((el (cdr (assoc :file params))))
(if el (replace-regexp-in-string "\\.pdf\\'" ".ps" el)
(error "abc code block requires :file header argument"))))
(in-file (org-babel-temp-file "abc-"))
(render (concat "abcm2ps" " " cmdline
" -O " (org-babel-process-file-name out-file)
......
......@@ -59,34 +59,33 @@ called by `org-babel-execute-src-block'"
(cmd-line (cdr (assoc :cmd-line params)))
(in-file (cdr (assoc :in-file params)))
(full-body (org-babel-expand-body:awk body params))
(code-file ((lambda (file) (with-temp-file file (insert full-body)) file)
(org-babel-temp-file "awk-")))
(stdin ((lambda (stdin)
(code-file (let ((file (org-babel-temp-file "awk-")))
(with-temp-file file (insert full-body)) file))
(stdin (let ((stdin (cdr (assoc :stdin params))))
(when stdin
(let ((tmp (org-babel-temp-file "awk-stdin-"))
(res (org-babel-ref-resolve stdin)))
(with-temp-file tmp
(insert (org-babel-awk-var-to-awk res)))
tmp)))
(cdr (assoc :stdin params))))
tmp))))
(cmd (mapconcat #'identity (remove nil (list org-babel-awk-command
"-f" code-file
cmd-line
in-file))
" ")))
(org-babel-reassemble-table
((lambda (results)
(when results
(org-babel-result-cond result-params
results
(let ((tmp (org-babel-temp-file "awk-results-")))
(with-temp-file tmp (insert results))
(org-babel-import-elisp-from-file tmp)))))
(cond
(stdin (with-temp-buffer
(call-process-shell-command cmd stdin (current-buffer))
(buffer-string)))
(t (org-babel-eval cmd ""))))
(let ((results
(cond
(stdin (with-temp-buffer
(call-process-shell-command cmd stdin (current-buffer))
(buffer-string)))
(t (org-babel-eval cmd "")))))
(when results
(org-babel-result-cond result-params
results
(let ((tmp (org-babel-temp-file "awk-results-")))
(with-temp-file tmp (insert results))
(org-babel-import-elisp-from-file tmp)))))
(org-babel-pick-name
(cdr (assoc :colname-names params)) (cdr (assoc :colnames params)))
(org-babel-pick-name
......
......@@ -42,13 +42,15 @@
(defun org-babel-expand-body:calc (body params)
"Expand BODY according to PARAMS, return the expanded body." body)
(defvar org--var-syms) ; Dynamically scoped from org-babel-execute:calc
(defun org-babel-execute:calc (body params)
"Execute a block of calc code with Babel."
(unless (get-buffer "*Calculator*")
(save-window-excursion (calc) (calc-quit)))
(let* ((vars (mapcar #'cdr (org-babel-get-header params :var)))
(var-syms (mapcar #'car vars))
(var-names (mapcar #'symbol-name var-syms)))
(org--var-syms (mapcar #'car vars))
(var-names (mapcar #'symbol-name org--var-syms)))
(mapc
(lambda (pair)
(calc-push-list (list (cdr pair)))
......@@ -66,33 +68,32 @@
;; complex expression
(t
(calc-push-list
(list ((lambda (res)
(cond
((numberp res) res)
((math-read-number res) (math-read-number res))
((listp res) (error "Calc error \"%s\" on input \"%s\""
(cadr res) line))
(t (replace-regexp-in-string
"'" ""
(calc-eval
(math-evaluate-expr
;; resolve user variables, calc built in
;; variables are handled automatically
;; upstream by calc
(mapcar #'org-babel-calc-maybe-resolve-var
;; parse line into calc objects
(car (math-read-exprs line)))))))))
(calc-eval line))))))))
(list (let ((res (calc-eval line)))
(cond
((numberp res) res)
((math-read-number res) (math-read-number res))
((listp res) (error "Calc error \"%s\" on input \"%s\""
(cadr res) line))
(t (replace-regexp-in-string
"'" ""
(calc-eval
(math-evaluate-expr
;; resolve user variables, calc built in
;; variables are handled automatically
;; upstream by calc
(mapcar #'org-babel-calc-maybe-resolve-var
;; parse line into calc objects
(car (math-read-exprs line)))))))))
))))))
(mapcar #'org-babel-trim
(split-string (org-babel-expand-body:calc body params) "[\n\r]"))))
(save-excursion
(with-current-buffer (get-buffer "*Calculator*")
(calc-eval (calc-top 1)))))
(defvar var-syms) ; Dynamically scoped from org-babel-execute:calc
(defun org-babel-calc-maybe-resolve-var (el)
(if (consp el)
(if (and (equal 'var (car el)) (member (cadr el) var-syms))
(if (and (equal 'var (car el)) (member (cadr el) org--var-syms))
(progn
(calc-recall (cadr el))
(prog1 (calc-top 1)
......
......@@ -24,17 +24,17 @@
;;; Commentary:
;;; support for evaluating clojure code, relies on slime for all eval
;; Support for evaluating clojure code, relies on slime for all eval.
;;; Requirements:
;;; - clojure (at least 1.2.0)
;;; - clojure-mode
;;; - slime
;; - clojure (at least 1.2.0)
;; - clojure-mode
;; - slime
;;; By far, the best way to install these components is by following
;;; the directions as set out by Phil Hagelberg (Technomancy) on the
;;; web page: http://technomancy.us/126
;; By far, the best way to install these components is by following
;; the directions as set out by Phil Hagelberg (Technomancy) on the
;; web page: http://technomancy.us/126
;;; Code:
(require 'ob)
......@@ -77,16 +77,16 @@
(require 'slime)
(with-temp-buffer
(insert (org-babel-expand-body:clojure body params))
((lambda (result)
(let ((result-params (cdr (assoc :result-params params))))
(org-babel-result-cond result-params
result
(condition-case nil (org-babel-script-escape result)
(error result)))))
(slime-eval
`(swank:eval-and-grab-output
,(buffer-substring-no-properties (point-min) (point-max)))
(cdr (assoc :package params))))))
(let ((result
(slime-eval
`(swank:eval-and-grab-output
,(buffer-substring-no-properties (point-min) (point-max)))
(cdr (assoc :package params)))))
(let ((result-params (cdr (assoc :result-params params))))
(org-babel-result-cond result-params
result
(condition-case nil (org-babel-script-escape result)
(error result)))))))
(provide 'ob-clojure)
......
......@@ -632,15 +632,14 @@ block."
(message "result silenced")
(setq result nil))
(setq result
((lambda (result)
(if (and (eq (cdr (assoc :result-type params))
'value)
(or (member "vector" result-params)
(member "table" result-params))
(not (listp result)))
(list (list result)) result))
(funcall cmd body params)))
;; if non-empty result and :file then write to :file
(let ((result (funcall cmd body params)))
(if (and (eq (cdr (assoc :result-type params))
'value)
(or (member "vector" result-params)
(member "table" result-params))
(not (listp result)))
(list (list result)) result)))
;; If non-empty result and :file then write to :file.
(when (cdr (assoc :file params))
(when result
(with-temp-file (cdr (assoc :file params))
......@@ -648,7 +647,7 @@ block."
(org-babel-format-result
result (cdr (assoc :sep (nth 2 info)))))))
(setq result (cdr (assoc :file params))))
;; possibly perform post process provided its appropriate
;; Possibly perform post process provided its appropriate.
(when (cdr (assoc :post params))
(let ((*this* (if (cdr (assoc :file params))
(org-babel-result-to-file
......@@ -893,6 +892,8 @@ with a prefix argument then this is passed on to
(defalias 'org-babel-pop-to-session 'org-babel-switch-to-session)
(defvar org-src-window-setup)
;;;###autoload
(defun org-babel-switch-to-session-with-code (&optional arg info)
"Switch to code buffer and display session."
......@@ -1157,18 +1158,18 @@ the current subtree."
(mapconcat #'identity (sort (funcall rm (split-string v))
#'string<) " "))
(t v)))))))
((lambda (hash)
(when (org-called-interactively-p 'interactive) (message hash)) hash)
(let ((it (format "%s-%s"
(mapconcat
#'identity
(delq nil (mapcar (lambda (arg)
(let ((normalized (funcall norm arg)))
(when normalized
(format "%S" normalized))))
(nth 2 info))) ":")
(nth 1 info))))
(sha1 it))))))
(let* ((it (format "%s-%s"
(mapconcat
#'identity
(delq nil (mapcar (lambda (arg)
(let ((normalized (funcall norm arg)))
(when normalized
(format "%S" normalized))))
(nth 2 info))) ":")
(nth 1 info)))
(hash (sha1 it)))
(when (org-called-interactively-p 'interactive) (message hash))
hash))))
(defun org-babel-current-result-hash ()
"Return the current in-buffer hash."
......@@ -1453,9 +1454,8 @@ instances of \"[ \t]:\" set ALTS to '((32 9) . 58)."
(cons (intern (match-string 1 arg))
(org-babel-read (org-babel-chomp (match-string 2 arg))))
(cons (intern (org-babel-chomp arg)) nil)))
((lambda (raw)
(cons (car raw) (mapcar (lambda (r) (concat ":" r)) (cdr raw))))
(org-babel-balanced-split arg-string '((32 9) . 58))))))))
(let ((raw (org-babel-balanced-split arg-string '((32 9) . 58))))
(cons (car raw) (mapcar (lambda (r) (concat ":" r)) (cdr raw)))))))))
(defun org-babel-parse-multiple-vars (header-arguments)
"Expand multiple variable assignments behind a single :var keyword.
......@@ -1598,12 +1598,11 @@ of the vars, cnames and rnames."
Given a TABLE and set of COLNAMES and ROWNAMES add the names
to the table for reinsertion to org-mode."
(if (listp table)
((lambda (table)
(if (and colnames (listp (car table)) (= (length (car table))
(length colnames)))
(org-babel-put-colnames table colnames) table))
(if (and rownames (= (length table) (length rownames)))
(org-babel-put-rownames table rownames) table))
(let ((table (if (and rownames (= (length table) (length rownames)))
(org-babel-put-rownames table rownames) table)))
(if (and colnames (listp (car table)) (= (length (car table))
(length colnames)))
(org-babel-put-colnames table colnames) table))
table))
(defun org-babel-where-is-src-block-head ()
......@@ -1640,9 +1639,8 @@ If the point is not on a source block then return nil."
(defun org-babel-goto-src-block-head ()
"Go to the beginning of the current code block."
(interactive)
((lambda (head)
(if head (goto-char head) (error "Not currently in a code block")))
(org-babel-where-is-src-block-head)))
(let ((head (org-babel-where-is-src-block-head)))
(if head (goto-char head) (error "Not currently in a code block"))))
;;;###autoload
(defun org-babel-goto-named-src-block (name)
......@@ -1763,14 +1761,13 @@ With optional prefix argument ARG, jump backward ARG many source blocks."
(defun org-babel-mark-block ()
"Mark current src block."
(interactive)
((lambda (head)
(when head
(save-excursion
(goto-char head)
(looking-at org-babel-src-block-regexp))
(push-mark (match-end 5) nil t)
(goto-char (match-beginning 5))))
(org-babel-where-is-src-block-head)))
(let ((head (org-babel-where-is-src-block-head)))
(when head
(save-excursion
(goto-char head)
(looking-at org-babel-src-block-regexp))
(push-mark (match-end 5) nil t)
(goto-char (match-beginning 5)))))
(defun org-babel-demarcate-block (&optional arg)
"Wrap or split the code in the region or on the point.
......@@ -2450,7 +2447,7 @@ block but are passed literally to the \"example-block\"."
(funcall (intern (concat lang "-mode")))
(comment-region (point) (progn (insert text) (point)))
(org-babel-trim (buffer-string)))))
index source-name evaluate prefix blocks-in-buffer)
index source-name evaluate prefix)
(with-temp-buffer
(org-set-local 'org-babel-noweb-wrap-start ob-nww-start)
(org-set-local 'org-babel-noweb-wrap-end ob-nww-end)
......@@ -2469,119 +2466,118 @@ 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
(save-restriction
(widen)
(mapconcat ;; interpose PREFIX between every line
#'identity
(split-string
(if evaluate
(let ((raw (org-babel-ref-resolve source-name)))
(if (stringp raw) raw (format "%S" raw)))
(or
;; retrieve from the library of babel
(nth 2 (assoc (intern source-name)
org-babel-library-of-babel))
;; return the contents of headlines literally
(save-excursion
(when (org-babel-ref-goto-headline-id source-name)
(funcall
nb-add
(with-current-buffer parent-buffer
(save-restriction
(widen)
(mapconcat ;; Interpose PREFIX between every line.
#'identity
(split-string
(if evaluate
(let ((raw (org-babel-ref-resolve source-name)))
(if (stringp raw) raw (format "%S" raw)))
(or
;; Retrieve from the library of babel.
(nth 2 (assoc (intern source-name)
org-babel-library-of-babel))
;; Return the contents of headlines literally.
(save-excursion
(when (org-babel-ref-goto-headline-id source-name)
(org-babel-ref-headline-body)))
;; find the expansion of reference in this buffer
(let ((rx (concat rx-prefix source-name "[ \t\n]"))
expansion)
(save-excursion
(goto-char (point-min))
(if org-babel-use-quick-and-dirty-noweb-expansion
(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 (funcall c-wrap (car cs)) "\n"
body "\n"
(funcall c-wrap (cadr cs))))
(org-babel-tangle-comment-links i))
body)))
(setq expansion (cons sep (cons full expansion)))))
(org-babel-map-src-blocks nil
(let ((