Similar to ~org-babel-get-src-block-info~ it is sometimes useful to disable 
evaluation of lisp parameters when getting the info of a lob call. This patch 
adds an argument for that.

Better name for the argument could be ~no-eval~, but I decided to stick with 
the naming in ~org-babel-get-src-block-info~. To be completely consistent with 
~org-babel-get-src-block-info~ the argument order could be swapped, but this 
would break existing function calls. 

What do you think?


>From ba8069a3b83489ee1de8c4eeba059883809d0ea7 Mon Sep 17 00:00:00 2001
From: fpi <>
Date: Sun, 16 Oct 2022 13:17:40 +0200
Subject: [PATCH] org-babel-lob-get-info: Add light argument

* lisp/ob-lob.el (org-babel-lob-get-info): Add light argument to
prevent recursive evaluation of lisp values in parameters.
 lisp/ob-exp.el |  2 +-
 lisp/ob-lob.el | 13 +++++++++----
 lisp/ob-ref.el |  2 +-
 3 files changed, 11 insertions(+), 6 deletions(-)

diff --git a/lisp/ob-exp.el b/lisp/ob-exp.el
index e9b304b86..83dd5fc74 100644
--- a/lisp/ob-exp.el
+++ b/lisp/ob-exp.el
@@ -25,7 +25,7 @@
 ;;; Code:
 (require 'ob-core)
-(declare-function org-babel-lob-get-info "ob-lob" (&optional datum))
+(declare-function org-babel-lob-get-info "ob-lob" (&optional datum light))
 (declare-function org-element-at-point "org-element" ())
 (declare-function org-element-context "org-element" (&optional element))
 (declare-function org-element-property "org-element" (property element))
diff --git a/lisp/ob-lob.el b/lisp/ob-lob.el
index 903dabfbd..3043ff647 100644
--- a/lisp/ob-lob.el
+++ b/lisp/ob-lob.el
@@ -114,11 +114,16 @@ after REF in the Library of Babel."
 	    (cdr (assoc-string ref org-babel-library-of-babel))))))))
-(defun org-babel-lob-get-info (&optional datum)
+(defun org-babel-lob-get-info (&optional datum light)
   "Return internal representation for Library of Babel function call.
 Consider DATUM, when provided, or element at point otherwise.
+When optional argument LIGHT is non-nil, Babel does not resolve
+remote variable references; a process which could likely result
+in the execution of other code blocks, and do not evaluate Lisp
+values in parameters.
 Return nil when not on an appropriate location.  Otherwise return
 a list compatible with `org-babel-get-src-block-info', which
@@ -139,16 +144,16 @@ see."
 			 (org-with-point-at begin
-			   (org-babel-params-from-properties language))
+			   (org-babel-params-from-properties language light))
-			   (org-element-property :inside-header context))
+			   (org-element-property :inside-header context) light)
 			  (let ((args (org-element-property :arguments context)))
 			    (and args
 				 (mapcar (lambda (ref) (cons :var ref))
 					 (org-babel-ref-split-args args))))
-			   (org-element-property :end-header context)))))
+			   (org-element-property :end-header context) light))))
 		 (org-element-property :name context)
diff --git a/lisp/ob-ref.el b/lisp/ob-ref.el
index a7ab299b2..a7cdb22e1 100644
--- a/lisp/ob-ref.el
+++ b/lisp/ob-ref.el
@@ -53,7 +53,7 @@
 (require 'org-macs)
 (require 'cl-lib)
-(declare-function org-babel-lob-get-info "ob-lob" (&optional datum))
+(declare-function org-babel-lob-get-info "ob-lob" (&optional datum light))
 (declare-function org-element-at-point "org-element" ())
 (declare-function org-element-property "org-element" (property element))
 (declare-function org-element-type "org-element" (element))

Reply via email to