[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[elpa] externals/org d1c6d02092 2/3: ob-core: Display type of element ba
From: |
ELPA Syncer |
Subject: |
[elpa] externals/org d1c6d02092 2/3: ob-core: Display type of element babel executes |
Date: |
Sat, 24 Sep 2022 05:57:48 -0400 (EDT) |
branch: externals/org
commit d1c6d02092540eabdd4cef695d53891190b4704b
Author: TEC <git@tecosaur.net>
Commit: TEC <git@tecosaur.net>
ob-core: Display type of element babel executes
* lisp/ob-core.el (org-babel-execute-src-block): The babel execute
function is run on more than just source blocks, so it makes sense to
note the type of element being executed. A fourth optional argument is
added to allow for explicit specification of the type of element
responsible for the execution.
* lisp/ob-lob.el (org-babel-lob-execute-maybe): Pass the type of the
execution triggering element to `org-babel-execute-src-block'.
* lisp/org.el (org-ctrl-c-ctrl-c): When executing a babel call, pass the
type of the execution triggering element to
`org-babel-execute-src-block'.
---
lisp/ob-core.el | 36 +++++++++++++++++++++++++++++-------
lisp/ob-lob.el | 5 +++--
lisp/org.el | 2 +-
3 files changed, 33 insertions(+), 10 deletions(-)
diff --git a/lisp/ob-core.el b/lisp/ob-core.el
index 392de999e9..35a7ddc9a3 100644
--- a/lisp/ob-core.el
+++ b/lisp/ob-core.el
@@ -715,7 +715,7 @@ a list with the following pattern:
; and `org-babel-read'
;;;###autoload
-(defun org-babel-execute-src-block (&optional arg info params)
+(defun org-babel-execute-src-block (&optional arg info params executor-type)
"Execute the current source code block and return the result.
Insert the results of execution into the buffer. Source code
execution and the collection and formatting of results can be
@@ -729,13 +729,29 @@ Optionally supply a value for INFO in the form returned by
Optionally supply a value for PARAMS which will be merged with
the header arguments specified at the front of the source code
-block."
+block.
+
+EXECUTOR-TYPE is the type of the org element responsible for the
+execution of the source block. If not provided then informed
+guess will be made."
(interactive)
(let* ((org-babel-current-src-block-location
- (or org-babel-current-src-block-location
- (nth 5 info)
- (org-babel-where-is-src-block-head)))
- (info (if info (copy-tree info) (org-babel-get-src-block-info))))
+ (or org-babel-current-src-block-location
+ (nth 5 info)
+ (org-babel-where-is-src-block-head)))
+ (info (if info (copy-tree info) (org-babel-get-src-block-info)))
+ (executor-type
+ (or executor-type
+ ;; If `executor-type' is unset, then we will make an
+ ;; informed guess.
+ (pcase (char-after org-babel-current-src-block-location)
+ (?s 'inline-src-block)
+ (?c 'inline-babel-call)
+ (?# (pcase (char-after (+ 2
org-babel-current-src-block-location))
+ (?b 'src-block)
+ (?c 'call-block)
+ (_ 'unknown)))
+ (_ 'unknown)))))
;; Merge PARAMS with INFO before considering source block
;; evaluation since both could disagree.
(cl-callf org-babel-merge-params (nth 2 info) params)
@@ -776,8 +792,14 @@ block."
result)
(unless (fboundp cmd)
(error "No org-babel-execute function for %s!" lang))
- (message "executing %s code block%s..."
+ (message "executing %s %s %s..."
(capitalize lang)
+ (pcase executor-type
+ ('src-block "code block")
+ ('inline-src-block "inline code block")
+ ('babel-call "call")
+ ('inline-babel-call "inline call")
+ (e (symbol-name e)))
(let ((name (nth 4 info)))
(if name
(format "(%s)" name)
diff --git a/lisp/ob-lob.el b/lisp/ob-lob.el
index 8da91bdaf1..c6be8be809 100644
--- a/lisp/ob-lob.el
+++ b/lisp/ob-lob.el
@@ -78,9 +78,10 @@ should not be inherited from a source block.")
Detect if this is context for a Library Of Babel source block and
if so then run the appropriate source block from the Library."
(interactive)
- (let ((info (org-babel-lob-get-info)))
+ (let* ((datum (org-element-context))
+ (info (org-babel-lob-get-info datum)))
(when info
- (org-babel-execute-src-block nil info)
+ (org-babel-execute-src-block nil info nil (org-element-type datum))
t)))
(defun org-babel-lob--src-info (ref)
diff --git a/lisp/org.el b/lisp/org.el
index 34745ee616..0009224f9e 100644
--- a/lisp/org.el
+++ b/lisp/org.el
@@ -17297,7 +17297,7 @@ This command does many different things, depending on
context:
"`\\[org-ctrl-c-ctrl-c]' can do nothing useful here"))))
((or `babel-call `inline-babel-call)
(let ((info (org-babel-lob-get-info context)))
- (when info (org-babel-execute-src-block nil info))))
+ (when info (org-babel-execute-src-block nil info nil type))))
(`clock (org-clock-update-time-maybe))
(`dynamic-block
(save-excursion