From eb7206f7445cc86417c0bb4f5403e679bedd8e54 Mon Sep 17 00:00:00 2001 From: Dan Davison Date: Fri, 10 Jul 2009 18:38:12 -0400 Subject: [PATCH] Fixing function call-style source block arguments. style syntax. There still needs to be work done on the regexps for recognising #+srcname lines possibly with/without parenthesised arguments. This change makes org-babel-block-name return nil rather than fail when it doesn't find a src block head (e.g. in a #+lob line), which seems sensible. The sbe test table is failing half-way down at `simple ruby arrays'. For some reason it is making a mini table ("| |") to the right hand, and point keeps jumping out of the table. My ability to debug sbe-related stuff is hampered by me not understanding the code (I need to learn about macros). --- lisp/org-babel-ref.el | 2 +- lisp/org-babel.el | 15 +++++++++------ 2 files changed, 10 insertions(+), 7 deletions(-) diff --git a/lisp/org-babel-ref.el b/lisp/org-babel-ref.el index a04577f9b..df190c031 100644 --- a/lisp/org-babel-ref.el +++ b/lisp/org-babel-ref.el @@ -108,7 +108,7 @@ return nil." (if (let ((result_regexp (concat "^#\\+\\(TBL\\|RES\\)NAME:[ \t]*" (regexp-quote ref) "[ \t]*$")) (regexp (concat "^#\\+SRCNAME:[ \t]*" - (regexp-quote ref) "[ \t]*$"))) + (regexp-quote ref) "\\(\(.*\)\\)?" "[ \t]*$"))) (or (re-search-forward result_regexp nil t) (re-search-forward result_regexp nil t) (re-search-forward regexp nil t) diff --git a/lisp/org-babel.el b/lisp/org-babel.el index d1c190767..bd498a13d 100644 --- a/lisp/org-babel.el +++ b/lisp/org-babel.el @@ -256,12 +256,15 @@ replaced, and may need to be reinstated in this function. " (defun org-babel-get-src-block-name () "Return the name of the current source block if one exists" - (let ((case-fold-search t)) - (save-excursion - (goto-char (org-babel-where-is-src-block-head)) - (if (save-excursion (forward-line -1) - (looking-at "#\\+srcname:[ \f\t\n\r\v]*\\([^ \f\t\n\r\v]+\\)\(\\(.*\\)\)")) - (org-babel-clean-text-properties (match-string 1)))))) + (let ((case-fold-search t) + (head (org-babel-where-is-src-block-head))) + (when head + (save-excursion + (goto-char head) + (if (save-excursion + (forward-line -1) + (looking-at "#\\+srcname:[ \f\t\n\r\v]*\\([^ \f\t\n\r\v]+\\)\(\\(.*\\)\)")) + (org-babel-clean-text-properties (match-string 1))))))) (defun org-babel-get-src-block-info () "Return the information of the current source block as a list