Browse Source

ob-lob: Improve `org-babel-lob-get-info' consistency

* lisp/ob-lob.el (org-babel-lob-get-info): Make the function on par with
  `org-babel-get-src-block-info' by providing the beginning position of
  Babel code.

(org-babel-lob-execute):
* lisp/ob-exp.el (org-babel-exp-process-buffer):
(org-babel-exp-results): Handle new data.
Nicolas Goaziou 9 years ago
parent
commit
94dfa7fa9c
2 changed files with 13 additions and 8 deletions
  1. 3 3
      lisp/ob-exp.el
  2. 10 5
      lisp/ob-lob.el

+ 3 - 3
lisp/ob-exp.el

@@ -217,9 +217,9 @@ may make them unreachable."
 					   (concat
 					    ":var results="
 					    (mapconcat #'identity
-						       (butlast lob-info)
+						       (butlast lob-info 2)
 						       " ")))))))
-				"" (nth 2 lob-info))
+				"" (nth 2 lob-info) (nth 3 lob-info))
 			  'lob))
 			(rep (org-fill-template
 			      org-babel-exp-call-line-template
@@ -412,7 +412,7 @@ inhibit insertion of results into the buffer."
 	      (org-babel-execute-src-block nil info))
 	    (`lob
 	     (save-excursion
-	      (goto-char (org-element-property :begin (org-element-context)))
+	      (goto-char (nth 5 info))
 	      (let (org-confirm-babel-evaluate)
 		(org-babel-execute-src-block nil info))))))))))
 

+ 10 - 5
lisp/ob-lob.el

@@ -82,15 +82,19 @@ if so then run the appropriate source block from the Library."
   "Return a Library of Babel function call as a string.
 Return nil when not on an appropriate location.  Build string
 from `inline-babel-call' or `babel-call' DATUM, when provided."
-  (let ((context (or datum (org-element-context))))
-    (when (memq (org-element-type context) '(babel-call inline-babel-call))
+  (let* ((context (or datum (org-element-context)))
+	 (type (org-element-type context)))
+    (when (memq type '(babel-call inline-babel-call))
       (list (format "%s%s(%s)"
 		    (org-element-property :call context)
 		    (let ((in (org-element-property :inside-header context)))
 		      (if in (format "[%s]" in) ""))
 		    (or (org-element-property :arguments context) ""))
 	    (org-element-property :end-header context)
-	    (org-element-property :name context)))))
+	    (org-element-property :name context)
+	    (org-element-property
+	     (if (eq type 'babel-call) :post-affiliated :begin)
+	     datum)))))
 
 (defvar org-babel-default-header-args:emacs-lisp) ; Defined in ob-emacs-lisp.el
 (defun org-babel-lob-execute (info)
@@ -98,7 +102,8 @@ from `inline-babel-call' or `babel-call' DATUM, when provided."
   (let* ((mkinfo (lambda (p)
 		   ;; Make plist P compatible with
 		   ;; `org-babel-get-src-block-info'.
-		   (list "emacs-lisp" "results" p nil (nth 2 info))))
+		   (list
+		    "emacs-lisp" "results" p nil (nth 2 info) (nth 3 info))))
 	 (pre-params
 	  (apply #'org-babel-merge-params
 		 org-babel-default-header-args
@@ -109,7 +114,7 @@ from `inline-babel-call' or `babel-call' DATUM, when provided."
 		   (org-babel-parse-header-arguments
 		    (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))
 		       (string= "yes" (cdr (assoc :cache pre-params)))))