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