babel: resolving references outside of the visible portion of narrowed buffers

Thanks to Tom Dye for pointing out the need for this fix

* contrib/babel/lisp/org-babel.el (org-babel-expand-noweb-references):
  now able to find noweb references even outside of the narrowed
  portion of the buffer when the buffer is narrowed

* contrib/babel/lisp/org-babel-ref.el (org-babel-ref-resolve-reference):
  now able to resolve references which are located outside of the
  narrowed portion of the buffer when the buffer is narrowed
This commit is contained in:
Eric Schulte 2010-06-07 17:38:35 -07:00
parent 93ab492464
commit ef931fcd3a
2 changed files with 61 additions and 56 deletions

View File

@ -120,6 +120,8 @@ return nil."
(setq split-file (match-string 1 ref))
(setq split-ref (match-string 2 ref))
(find-file split-file) (setq ref split-ref))
(save-restriction
(widen)
(goto-char (point-min))
(if (let ((result_regexp (concat "^#\\+\\(TBLNAME\\|RESNAME\\|RESULTS\\):[ \t]*"
(regexp-quote ref) "[ \t]*$"))
@ -160,7 +162,7 @@ return nil."
(format "%S" result)
(if (and index (listp result))
(org-babel-ref-index-list index result)
result)))))
result))))))
(defun org-babel-ref-index-list (index lis)
"Return the subset of LIS indexed by INDEX. If INDEX is

View File

@ -1232,6 +1232,8 @@ block but are passed literally to the \"example-block\"."
(let ((raw (org-babel-ref-resolve-reference
source-name nil)))
(if (stringp raw) raw (format "%S" raw)))
(save-restriction
(widen)
(let ((point (org-babel-find-named-block source-name)))
(if point
(save-excursion
@ -1246,7 +1248,8 @@ block but are passed literally to the \"example-block\"."
(concat "<<%s>> could not be resolved "
"(see `org-babel-noweb-error-langs')")
source-name)
"")))) "[\n\r]") (concat "\n" prefix)))))
"")))))
"[\n\r]") (concat "\n" prefix)))))
(nb-add (buffer-substring index (point-max)))))
new-body))