Browse Source

configurable names for inline data labels

* lisp/ob-ref.el (org-babel-ref-resolve): Using the new result regexp.
* lisp/ob.el (org-babel-data-names): Configurable list of names of data.
  (org-babel-result-regexp): Using new results regexp.
Eric Schulte 14 years ago
parent
commit
ec293ae62b
2 changed files with 13 additions and 10 deletions
  1. 8 9
      lisp/ob-ref.el
  2. 5 1
      lisp/ob.el

+ 8 - 9
lisp/ob-ref.el

@@ -116,17 +116,16 @@ the variable."
       (save-restriction
 	(widen)
 	(goto-char (point-min))
-	(if (let ((result_regexp (concat "^[ \t]*#\\+\\(TBLNAME\\|RESNAME"
-					 "\\|RESULTS\\):[ \t]*"
-					 (regexp-quote ref) "[ \t]*$"))
-		  (regexp (concat org-babel-src-name-regexp
-				  (regexp-quote ref) "\\(\(.*\)\\)?" "[ \t]*$")))
+	(if (let* ((rx (regexp-quote ref))
+		   (res-rx (concat org-babel-result-regexp rx "[ \t]*$"))
+		   (src-rx (concat org-babel-src-name-regexp
+				   rx "\\(\(.*\)\\)?" "[ \t]*$")))
 	      ;; goto ref in the current buffer
 	      (or (and (not args)
-		       (or (re-search-forward result_regexp nil t)
-			   (re-search-backward result_regexp nil t)))
-		  (re-search-forward regexp nil t)
-		  (re-search-backward regexp nil t)
+		       (or (re-search-forward res-rx nil t)
+			   (re-search-backward res-rx nil t)))
+		  (re-search-forward src-rx nil t)
+		  (re-search-backward src-rx nil t)
 		  ;; check the Library of Babel
 		  (setq lob-info (cdr (assoc (intern ref)
 					     org-babel-library-of-babel)))))

+ 5 - 1
lisp/ob.el

@@ -306,8 +306,12 @@ specific header arguments as well.")
   '((:session . "none") (:results . "replace") (:exports . "results"))
   "Default arguments to use when evaluating an inline source block.")
 
+(defvar org-babel-data-names '("TBLNAME" "RESNAME" "RESULTS" "DATA"))
+
 (defvar org-babel-result-regexp
-  "^[ \t]*#\\+res\\(ults\\|name\\)\\(\\[\\([[:alnum:]]+\\)\\]\\)?\\:[ \t]*"
+  (concat "^[ \t]*#\\+"
+	  (regexp-opt org-babel-data-names)
+	  "\\(\\[\\([[:alnum:]]+\\)\\]\\)?\\:[ \t]*")
   "Regular expression used to match result lines.
 If the results are associated with a hash key then the hash will
 be saved in the second match data.")