mirror of
https://git.savannah.gnu.org/git/emacs/org-mode.git
synced 2024-11-27 07:37:25 +00:00
resurrect dropped pieces of a previous patch
* lisp/ob.el (org-babel-expand-noweb-references): Resurrect dropped pieces of a previous patch.
This commit is contained in:
parent
ded376f756
commit
d35c79aca9
37
lisp/ob.el
37
lisp/ob.el
@ -2019,6 +2019,8 @@ block but are passed literally to the \"example-block\"."
|
|||||||
(lang (nth 0 info))
|
(lang (nth 0 info))
|
||||||
(body (nth 1 info))
|
(body (nth 1 info))
|
||||||
(comment (string= "noweb" (cdr (assoc :comments (nth 2 info)))))
|
(comment (string= "noweb" (cdr (assoc :comments (nth 2 info)))))
|
||||||
|
(rx-prefix (concat "\\(" org-babel-src-name-regexp "\\|"
|
||||||
|
":noweb-ref[ \t]+" "\\)"))
|
||||||
(new-body "") index source-name evaluate prefix blocks-in-buffer)
|
(new-body "") index source-name evaluate prefix blocks-in-buffer)
|
||||||
(flet ((nb-add (text) (setq new-body (concat new-body text)))
|
(flet ((nb-add (text) (setq new-body (concat new-body text)))
|
||||||
(c-wrap (text)
|
(c-wrap (text)
|
||||||
@ -2059,31 +2061,36 @@ block but are passed literally to the \"example-block\"."
|
|||||||
(when (org-babel-ref-goto-headline-id source-name)
|
(when (org-babel-ref-goto-headline-id source-name)
|
||||||
(org-babel-ref-headline-body)))
|
(org-babel-ref-headline-body)))
|
||||||
;; find the expansion of reference in this buffer
|
;; find the expansion of reference in this buffer
|
||||||
(let (expansion)
|
(let ((rx (concat rx-prefix source-name))
|
||||||
|
expansion)
|
||||||
(save-excursion
|
(save-excursion
|
||||||
(goto-char (point-min))
|
(goto-char (point-min))
|
||||||
(if *org-babel-use-quick-and-dirty-noweb-expansion*
|
(if *org-babel-use-quick-and-dirty-noweb-expansion*
|
||||||
(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))
|
||||||
(if comment
|
(full (if comment
|
||||||
((lambda (cs)
|
((lambda (cs)
|
||||||
(concat (c-wrap (car cs)) "\n"
|
(concat (c-wrap (car cs)) "\n"
|
||||||
body "\n" (c-wrap (cadr cs))))
|
body "\n"
|
||||||
(org-babel-tangle-comment-links i))
|
(c-wrap (cadr cs))))
|
||||||
(setq expansion (concat expansion body)))))
|
(org-babel-tangle-comment-links i))
|
||||||
|
body)))
|
||||||
|
(setq expansion (concat expansion full))))
|
||||||
(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))
|
||||||
(if comment
|
(full (if comment
|
||||||
((lambda (cs)
|
((lambda (cs)
|
||||||
(concat (c-wrap (car cs)) "\n"
|
(concat (c-wrap (car cs)) "\n"
|
||||||
body "\n" (c-wrap (cadr cs))))
|
body "\n"
|
||||||
(org-babel-tangle-comment-links i))
|
(c-wrap (cadr cs))))
|
||||||
(setq expansion (concat expansion body)))))))))
|
(org-babel-tangle-comment-links i))
|
||||||
|
body)))
|
||||||
|
(setq expansion (concat expansion full))))))))
|
||||||
expansion)
|
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)
|
||||||
|
Loading…
Reference in New Issue
Block a user