Browse Source

named call lines insert results like code blocks

* lisp/ob-core.el (org-babel-find-named-result): Call lines are not
  results.
  (org-babel-where-is-src-block-result): Don't implicitly name the
  results of call lines.

* lisp/ob-exp.el (org-babel-exp-non-block-elements): There is now
  another element on the call line info list.
* lisp/ob-lob.el (org-babel-lob-get-info): Return the name (if any)
  at the end of the info list.
  (org-babel-lob-execute): Pass the name through to execution.
Eric Schulte 11 years ago
parent
commit
884f5ced13
3 changed files with 15 additions and 9 deletions
  1. 3 5
      lisp/ob-core.el
  2. 1 1
      lisp/ob-exp.el
  3. 11 3
      lisp/ob-lob.el

+ 3 - 5
lisp/ob-core.el

@@ -1717,7 +1717,8 @@ buffer or nil if no such result exists."
 	  (when (and (string= "name" (downcase (match-string 1)))
 		     (or (beginning-of-line 1)
 			 (looking-at org-babel-src-block-regexp)
-			 (looking-at org-babel-multi-line-header-regexp)))
+			 (looking-at org-babel-multi-line-header-regexp)
+			 (looking-at org-babel-lob-one-liner-regexp)))
 	    (throw 'is-a-code-block (org-babel-find-named-result name (point))))
 	  (beginning-of-line 0) (point))))))
 
@@ -1822,10 +1823,7 @@ following the source block."
 			  (looking-at org-babel-lob-one-liner-regexp)))
 	   (inlinep (when (org-babel-get-inline-src-block-matches)
 		      (match-end 0)))
-	   (name (if on-lob-line
-		     (mapconcat #'identity (butlast (org-babel-lob-get-info))
-				"")
-		   (nth 4 (or info (org-babel-get-src-block-info 'light)))))
+	   (name (nth 4 (or info (org-babel-get-src-block-info 'light))))
 	   (head (unless on-lob-line (org-babel-where-is-src-block-head)))
 	   found beg end)
       (when head (goto-char head))

+ 1 - 1
lisp/ob-exp.el

@@ -217,7 +217,7 @@ this template."
 					     (concat
 					      ":var results="
 					      (mapconcat 'identity
-							 (butlast lob-info)
+							 (butlast lob-info 2)
 							 " ")))))))
 				  "" nil (car (last lob-info)))
 			    'lob))

+ 11 - 3
lisp/ob-lob.el

@@ -114,12 +114,20 @@ if so then run the appropriate source block from the Library."
 			  (or (funcall nonempty 8 19) ""))
 		  (funcall nonempty 9 18)))
 	 (list (length (if (= (length (match-string 12)) 0)
-			   (match-string 2) (match-string 11)))))))))
+			   (match-string 2) (match-string 11)))
+	       (save-excursion
+		 (forward-line -1)
+		 (and (looking-at (concat org-babel-src-name-regexp
+					  "\\([^\n]*\\)$"))
+		      (org-no-properties (match-string 1))))))))))
 
 (defvar org-babel-default-header-args:emacs-lisp) ; Defined in ob-emacs-lisp.el
 (defun org-babel-lob-execute (info)
   "Execute the lob call specified by INFO."
-  (let* ((mkinfo (lambda (p) (list "emacs-lisp" "results" p nil nil (nth 2 info))))
+  (let* ((mkinfo (lambda (p)
+		   (list "emacs-lisp" "results" p nil
+			 (nth 3 info) ;; name
+			 (nth 2 info))))
 	 (pre-params (apply #'org-babel-merge-params
 			    org-babel-default-header-args
 			    org-babel-default-header-args:emacs-lisp
@@ -130,7 +138,7 @@ if so then run the appropriate source block from the Library."
 			       (org-no-properties
 				(concat
 				 ":var results="
-				 (mapconcat #'identity (butlast info)
+				 (mapconcat #'identity (butlast info 2)
 					    " "))))))))
 	 (pre-info (funcall mkinfo pre-params))
 	 (cache-p (and (cdr (assoc :cache pre-params))