babel: now able to reference links as results

This commit is contained in:
Eric Schulte 2010-02-09 19:38:50 -07:00
parent db1fe2a619
commit 2531d704c0
2 changed files with 18 additions and 0 deletions

View File

@ -150,6 +150,7 @@ return nil."
(case type
('results-line (org-babel-read-result))
('table (org-babel-read-table))
('file (org-babel-read-file))
('source-block (org-babel-execute-src-block nil nil params))
('lob (org-babel-execute-src-block nil lob-info params))))
(if (symbolp result)
@ -202,6 +203,7 @@ of the supported reference types are found. Supported reference
types are tables and source blocks."
(cond ((org-at-table-p) 'table)
((looking-at "^#\\+BEGIN_SRC") 'source-block)
((looking-at org-bracket-link-regexp) 'file)
((looking-at org-babel-result-regexp) 'results-line)))
(provide 'org-babel-ref)

View File

@ -657,6 +657,7 @@ following the source block."
(let ((case-fold-search t) result-string)
(cond
((org-at-table-p) (org-babel-read-table))
((looking-at org-bracket-link-regexp) (org-babel-read-link))
((looking-at org-block-regexp) (org-babel-trim (match-string 4)))
((looking-at ": ")
(setq result-string
@ -679,6 +680,21 @@ following the source block."
(mapcar #'org-babel-read row)))
(org-table-to-lisp)))
(defun org-babel-read-link ()
"Read the link at `point' into emacs-lisp. If the path of the
link is a file path it is expanded using `expand-file-name'."
(let* ((case-fold-search t)
(raw (and (looking-at org-bracket-link-regexp)
(org-babel-clean-text-properties (match-string 1))))
(type (and (string-match org-link-types-re raw)
(match-string 1 raw))))
(cond
((not type) (expand-file-name raw))
((string= type "file")
(and (string-match "file\\(.*\\):\\(.+\\)" raw)
(expand-file-name (match-string 2 raw))))
(t raw))))
(defun org-babel-insert-result (result &optional result-params info hash)
"Insert RESULT into the current buffer after the end of the
current source block. With optional argument RESULT-PARAMS