diff options
author | Eric Schulte <schulte.eric@gmail.com> | 2010-06-10 15:46:16 -0700 |
---|---|---|
committer | Eric Schulte <schulte.eric@gmail.com> | 2010-06-10 21:36:57 -0700 |
commit | cc1c4467913e218d9253a4d7b83b40616034cf20 (patch) | |
tree | f3650fd33e1004d21c3690d1cdf47ece84925861 | |
parent | 93113250301bef77a8404105655ae0e73c4080eb (diff) | |
download | org-mode-cc1c4467913e218d9253a4d7b83b40616034cf20.tar.gz |
babel: ensure positional invariance of the `info' list
* contrib/babel/lisp/org-babel.el (org-babel-get-src-block-info):
ensure that info always has the same number of arguments in the same
order
-rw-r--r-- | contrib/babel/lisp/org-babel.el | 44 |
1 files changed, 24 insertions, 20 deletions
diff --git a/contrib/babel/lisp/org-babel.el b/contrib/babel/lisp/org-babel.el index fe91390..d1ec6e5 100644 --- a/contrib/babel/lisp/org-babel.el +++ b/contrib/babel/lisp/org-babel.el @@ -398,7 +398,7 @@ the current subtree." (defun org-babel-get-src-block-info (&optional header-vars-only) "Get information of the current source block. Returns a list - (language body header-arguments-alist switches name function-args). + (language body header-arguments-alist switches name function-args indent). 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 @@ -411,25 +411,29 @@ added to the header-arguments-alist." (setq indent (car (last info))) (setq info (butlast info)) (forward-line -1) - (when (looking-at - (concat org-babel-source-name-regexp - "\\([^ ()\f\t\n\r\v]+\\)\\(\(\\(.*\\)\)\\|\\)")) - (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 org-babel-exp-code to detect - ;; a functional-style 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 (lambda (ref) (cons :var ref)) - (org-babel-ref-split-args args)))))) - (unless header-vars-only - (setf (third info) - (org-babel-merge-params (sixth info) (third info))))) + (if (looking-at + (concat org-babel-source-name-regexp + "\\([^ ()\f\t\n\r\v]+\\)\\(\(\\(.*\\)\)\\|\\)")) + (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 + ;; org-babel-exp-code to detect a functional-style + ;; 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 + (lambda (ref) (cons :var ref)) + (org-babel-ref-split-args args)))))) + (unless header-vars-only + (setf (third info) + (org-babel-merge-params (sixth info) (third info))))) + (setq info (append info (list nil nil)))) (append info (list indent))) (if (save-excursion ;; inline source block (re-search-backward "[ \f\t\n\r\v]" nil t) |