emacs-orgmode@gnu.org archives
 help / color / mirror / code / Atom feed
* [PATCH] Add light argument to org-babel-lob-get-info
@ 2022-10-16 12:17 Ferdinand Pieper
  2022-10-17  9:10 ` Ihor Radchenko
  0 siblings, 1 reply; 10+ messages in thread
From: Ferdinand Pieper @ 2022-10-16 12:17 UTC (permalink / raw)
  To: emacs-orgmode

[-- Attachment #1: Type: text/plain, Size: 491 bytes --]

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?

Best,
Ferdinand


[-- Warning: decoded text below may be mangled, UTF-8 assumed --]
[-- Attachment #2: 0001-org-babel-lob-get-info-Add-light-argument.patch --]
[-- Type: text/x-diff, Size: 3134 bytes --]

From ba8069a3b83489ee1de8c4eeba059883809d0ea7 Mon Sep 17 00:00:00 2001
From: fpi <git@pie.tf>
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))))))))
 
 ;;;###autoload
-(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
 see."
@@ -139,16 +144,16 @@ see."
 			org-babel-default-lob-header-args
 			(append
 			 (org-with-point-at begin
-			   (org-babel-params-from-properties language))
+			   (org-babel-params-from-properties language light))
 			 (list
 			  (org-babel-parse-header-arguments
-			   (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-babel-parse-header-arguments
-			   (org-element-property :end-header context)))))
+			   (org-element-property :end-header context) light))))
 		 nil
 		 (org-element-property :name context)
 		 begin
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))
-- 
2.20.1


^ permalink raw reply related	[flat|nested] 10+ messages in thread

end of thread, other threads:[~2022-10-24  9:12 UTC | newest]

Thread overview: 10+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2022-10-16 12:17 [PATCH] Add light argument to org-babel-lob-get-info Ferdinand Pieper
2022-10-17  9:10 ` Ihor Radchenko
2022-10-18 16:15   ` Ferdinand Pieper
2022-10-19  7:01     ` Ihor Radchenko
2022-10-22 15:28       ` Possible bugs in org-babel-temp-stable-file (was: [PATCH] Add light argument to org-babel-lob-get-info) Ferdinand Pieper
2022-10-23  4:01         ` Ihor Radchenko
2022-10-23 11:27           ` Possible bugs in org-babel-temp-stable-file Ferdinand Pieper
2022-10-24  4:12             ` Ihor Radchenko
2022-10-24  7:49               ` Ferdinand Pieper
2022-10-24  8:24                 ` Ihor Radchenko

Code repositories for project(s) associated with this public inbox

	https://git.savannah.gnu.org/cgit/emacs/org-mode.git

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).