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:
parent
93ab492464
commit
ef931fcd3a
|
@ -120,6 +120,8 @@ return nil."
|
||||||
(setq split-file (match-string 1 ref))
|
(setq split-file (match-string 1 ref))
|
||||||
(setq split-ref (match-string 2 ref))
|
(setq split-ref (match-string 2 ref))
|
||||||
(find-file split-file) (setq ref split-ref))
|
(find-file split-file) (setq ref split-ref))
|
||||||
|
(save-restriction
|
||||||
|
(widen)
|
||||||
(goto-char (point-min))
|
(goto-char (point-min))
|
||||||
(if (let ((result_regexp (concat "^#\\+\\(TBLNAME\\|RESNAME\\|RESULTS\\):[ \t]*"
|
(if (let ((result_regexp (concat "^#\\+\\(TBLNAME\\|RESNAME\\|RESULTS\\):[ \t]*"
|
||||||
(regexp-quote ref) "[ \t]*$"))
|
(regexp-quote ref) "[ \t]*$"))
|
||||||
|
@ -160,7 +162,7 @@ return nil."
|
||||||
(format "%S" result)
|
(format "%S" result)
|
||||||
(if (and index (listp result))
|
(if (and index (listp result))
|
||||||
(org-babel-ref-index-list index result)
|
(org-babel-ref-index-list index result)
|
||||||
result)))))
|
result))))))
|
||||||
|
|
||||||
(defun org-babel-ref-index-list (index lis)
|
(defun org-babel-ref-index-list (index lis)
|
||||||
"Return the subset of LIS indexed by INDEX. If INDEX is
|
"Return the subset of LIS indexed by INDEX. If INDEX is
|
||||||
|
|
|
@ -1232,6 +1232,8 @@ block but are passed literally to the \"example-block\"."
|
||||||
(let ((raw (org-babel-ref-resolve-reference
|
(let ((raw (org-babel-ref-resolve-reference
|
||||||
source-name nil)))
|
source-name nil)))
|
||||||
(if (stringp raw) raw (format "%S" raw)))
|
(if (stringp raw) raw (format "%S" raw)))
|
||||||
|
(save-restriction
|
||||||
|
(widen)
|
||||||
(let ((point (org-babel-find-named-block source-name)))
|
(let ((point (org-babel-find-named-block source-name)))
|
||||||
(if point
|
(if point
|
||||||
(save-excursion
|
(save-excursion
|
||||||
|
@ -1246,7 +1248,8 @@ block but are passed literally to the \"example-block\"."
|
||||||
(concat "<<%s>> could not be resolved "
|
(concat "<<%s>> could not be resolved "
|
||||||
"(see `org-babel-noweb-error-langs')")
|
"(see `org-babel-noweb-error-langs')")
|
||||||
source-name)
|
source-name)
|
||||||
"")))) "[\n\r]") (concat "\n" prefix)))))
|
"")))))
|
||||||
|
"[\n\r]") (concat "\n" prefix)))))
|
||||||
(nb-add (buffer-substring index (point-max)))))
|
(nb-add (buffer-substring index (point-max)))))
|
||||||
new-body))
|
new-body))
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue