diff options
author | Rodrigo Morales <rodrigo@morales.pe> | 2024-09-21 19:04:55 -0500 |
---|---|---|
committer | Ihor Radchenko <yantar92@posteo.net> | 2024-09-22 12:28:08 +0200 |
commit | d8fc26aefa70a0fcbbbbbb73ef09f4b6b0b600a8 (patch) | |
tree | 1cae87929c8a7acc5a06c69dd403186e0a6c7a9d | |
parent | 2a85367ea80d8a110f76c42aa6927cf220ab5c33 (diff) |
org-babel-view-src-block-info: Fix querying Org properties in Help buffer
* lisp/ob-core.el (org-babel-view-src-block-info): Query in-buffer
header arguments (`org-entry-get') from Org buffer. It does nothing
from *Help* buffer.
In the previous version, when the user interactively calls
`org-babel-view-src-block-info' and the point is on a code block, these
two warnings are shown in the buffer *Warnings*:
⛔ Warning (org-element): ‘org-element-at-point’ cannot be used in non-Org buffer #<buffer *Help*> (help-mode)
⛔ Warning (org-element): ‘org-element-at-point’ cannot be used in non-Org buffer #<buffer *Help*> (help-mode)
This happened because `org-babel-view-src-block-info'
calls (org-entry-get (point) "header-args" t) while being in
the *Help* buffer. `org-babel-view-src-block-info' should call
org-entry-get while being in the Org Mode buffer and then switch to
the *Help* buffer once it has all the information that is then
displayed in the *Help* buffer.
In the introduced changes, we execute (org-entry-get (point)
"header-args" t) while being in the Org Mode buffer and we switch
to *Help* when we have the necessary information that is then shown in
the *Help* buffer.
TINYCHANGE
-rw-r--r-- | lisp/ob-core.el | 27 |
1 files changed, 18 insertions, 9 deletions
diff --git a/lisp/ob-core.el b/lisp/ob-core.el index 7b4ca9b5e..263d1d94a 100644 --- a/lisp/ob-core.el +++ b/lisp/ob-core.el @@ -358,18 +358,27 @@ a window into the `org-babel-get-src-block-info' function." (full (lambda (it) (> (length it) 0))) (printf (lambda (fmt &rest args) (princ (apply #'format fmt args))))) (when info - (with-help-window (help-buffer) - (let ((name (nth 4 info)) - (lang (nth 0 info)) - (switches (nth 3 info)) - (header-args (nth 2 info))) + (let* ((name (nth 4 info)) + (language (nth 0 info)) + (switches (nth 3 info)) + (header-args (nth 2 info)) + (property-header-args + (org-entry-get (point) "header-args" t)) + (property-header-args-language + (org-entry-get (point) (concat "header-args:" language) t))) + (with-help-window (help-buffer) (when name (funcall printf "Name: %s\n" name)) - (when lang (funcall printf "Lang: %s\n" lang)) + (when language (funcall printf "Language: %s\n" language)) + ;; Show header arguments that have been set through + ;; properties (i.e. in property drawers or through + ;; #+PROPERTY) (funcall printf "Properties:\n") - (funcall printf "\t:header-args \t%s\n" (org-entry-get (point) "header-args" t)) - (funcall printf "\t:header-args:%s \t%s\n" lang (org-entry-get (point) (concat "header-args:" lang) t)) - + (funcall printf "\t:header-args \t%s\n" property-header-args) + (funcall printf "\t:header-args:%s \t%s\n" language property-header-args-language) + ;; Show switches (when (funcall full switches) (funcall printf "Switches: %s\n" switches)) + ;; Show default header arguments and header arguments that + ;; have been explicitly set in the current code block. (funcall printf "Header Arguments:\n") (dolist (pair (sort header-args (lambda (a b) (string< (symbol-name (car a)) |