ob-ref: fix bug

* lisp/ob-ref.el (org-babel-ref-resolve): Fix error when src block
result is nil.
This commit is contained in:
Aaron Ecay 2015-11-07 20:09:34 +00:00
parent 3f6e71e62e
commit f0380f54c1
1 changed files with 34 additions and 37 deletions

View File

@ -162,11 +162,9 @@ the variable."
(goto-char (point-min))
(let* ((params (append args '((:results . "silent"))))
(regexp (org-babel-named-data-regexp-for-name ref))
lob-info
(result
(cond
(catch :found
;; Check for code blocks or named data.
((catch :found
(while (re-search-forward regexp nil t)
;; Ignore COMMENTed headings and orphaned
;; affiliated keywords.
@ -191,14 +189,13 @@ the variable."
(guard v))
(throw :found v))
(_ (error "Reference not found")))))))
nil))
;; Check for local or global headlines by ID.
((org-babel-ref-goto-headline-id ref)
(org-babel-ref-headline-body))
(when (org-babel-ref-goto-headline-id ref)
(throw :found (org-babel-ref-headline-body)))
;; Check the Library of Babel.
((setq lob-info
(cdr (assq (intern ref) org-babel-library-of-babel)))
(org-babel-execute-src-block nil lob-info params))
(let ((lob-info (cdr (assq (intern ref) org-babel-library-of-babel))))
(when lob-info
(throw :found (org-babel-execute-src-block nil lob-info params))))
(t (error "Reference `%s' not found in this buffer" ref)))))
(cond
((symbolp result) (format "%S" result))