babel: Simplify `org-babel-get-src-block-info'

* ob.el (org-babel-get-src-block-info): Simplify function
This commit is contained in:
Dan Davison 2010-09-26 22:06:12 +01:00
parent 8b327f2a77
commit ee96df5c73
1 changed files with 12 additions and 18 deletions

View File

@ -143,7 +143,7 @@ Unless HEADER-VARS-ONLY is non-nil, any variable
references provided in 'function call style' (i.e. in a
parenthesised argument list following the src block name) are
added to the header-arguments-alist."
(let ((case-fold-search t) head info args indent)
(let ((case-fold-search t) head info name args indent)
(if (setq head (org-babel-where-is-src-block-head))
(save-excursion
(goto-char head)
@ -151,11 +151,6 @@ added to the header-arguments-alist."
(setq indent (car (last info)))
(setq info (butlast info))
(forward-line -1)
(if (and (looking-at org-babel-src-name-w-name-regexp)
(match-string 2))
(progn
(setq info (append info (list (org-babel-clean-text-properties
(match-string 2)))))
;; Note that e.g. "name()" and "name( )" result in
;; ((:var . "")). We maintain that behaviour, and the
;; resulting non-nil sixth element is relied upon in
@ -163,18 +158,17 @@ added to the header-arguments-alist."
;; block in those cases. However, "name" without any
;; parentheses would result in the same thing, so we
;; explicitly avoid that.
(if (setq args (match-string 4))
(setq info
(append info (list
(mapcar
(when (and (looking-at org-babel-src-name-w-name-regexp)
(match-string 2))
(setq name (org-babel-clean-text-properties (match-string 2)))
(when (setq args (match-string 4))
(setq args (mapcar
(lambda (ref) (cons :var ref))
(org-babel-ref-split-args args)))))
(setq info (append info (list nil))))
(org-babel-ref-split-args args)))
(unless header-vars-only
(setf (nth 2 info)
(org-babel-merge-params (nth 5 info) (nth 2 info)))))
(setq info (append info (list nil nil))))
(append info (list indent)))
(org-babel-merge-params args (nth 2 info))))))
(append info (list name args indent)))
(if (save-excursion ;; inline source block
(re-search-backward "[ \f\t\n\r\v]" nil t)
(looking-at org-babel-inline-src-block-regexp))