summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorEric Schulte <eric.schulte@gmx.com>2011-12-29 12:46:42 -0700
committerBastien Guerry <bzg@altern.org>2012-01-03 09:17:03 +0100
commit1471af0b441f8109404d18d6b914e639440cd65c (patch)
tree5f735936512750bbfceaccf5b2fe6a579751d341
parentdc44b5897cf41f330add06bcb0a3b4f919b85c0b (diff)
downloadorg-mode-1471af0b441f8109404d18d6b914e639440cd65c.tar.gz
Resolve :noweb-ref when set at the property level during noweb expansion
* lisp/ob.el (org-babel-expand-noweb-references): Rather than using a pure regexp solution to resolve noweb references, actually check the information of every code block in the buffer. This will cause a slowdown in noweb reference expansion, but is necessary for correct behavior.
-rw-r--r--lisp/ob.el26
1 files changed, 13 insertions, 13 deletions
diff --git a/lisp/ob.el b/lisp/ob.el
index 9919416..a392c23 100644
--- a/lisp/ob.el
+++ b/lisp/ob.el
@@ -2014,8 +2014,6 @@ block but are passed literally to the \"example-block\"."
(lang (nth 0 info))
(body (nth 1 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)
(flet ((nb-add (text) (setq new-body (concat new-body text)))
(c-wrap (text)
@@ -2056,19 +2054,21 @@ block but are passed literally to the \"example-block\"."
(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))
- expansion)
+ (let (expansion)
(save-excursion
(goto-char (point-min))
- (while (re-search-forward rx nil t)
- (let* ((i (org-babel-get-src-block-info 'light))
- (body (org-babel-expand-noweb-references i)))
- (if comment
- ((lambda (cs)
- (concat (c-wrap (car cs)) "\n"
- body "\n" (c-wrap (cadr cs))))
- (org-babel-tangle-comment-links i))
- (setq expansion (concat expansion body))))))
+ (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)))
+ (if comment
+ ((lambda (cs)
+ (concat (c-wrap (car cs)) "\n"
+ body "\n" (c-wrap (cadr cs))))
+ (org-babel-tangle-comment-links i))
+ (setq expansion (concat expansion body))))))))
expansion)
;; possibly raise an error if named block doesn't exist
(if (member lang org-babel-noweb-error-langs)