all messages for Emacs-related lists mirrored at yhetil.org
 help / color / mirror / code / Atom feed
* [PATCH] fix org-babel-view-src-block-info
@ 2024-09-22  0:25 Rodrigo Morales
  2024-09-22 10:38 ` Ihor Radchenko
  0 siblings, 1 reply; 4+ messages in thread
From: Rodrigo Morales @ 2024-09-22  0:25 UTC (permalink / raw)
  To: emacs-orgmode

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


This is one of the first patches that I sent to the Org Mode
project. Please let me know if I have done something wrong, so
that I don't make the same mistake in the future.


[-- Attachment #2: 0001-lisp-ob-core.el-fix-org-babel-view-src-block-info.patch --]
[-- Type: text/x-diff, Size: 3486 bytes --]

From 4453277ee0d9aa6318008a21c4f3f9b16d29c901 Mon Sep 17 00:00:00 2001
From: Rodrigo Morales <rodrigo@morales.pe>
Date: Sat, 21 Sep 2024 19:04:55 -0500
Subject: [PATCH] lisp/ob-core.el: fix org-babel-view-src-block-info
MIME-Version: 1.0
Content-Type: text/plain; charset=UTF-8
Content-Transfer-Encoding: 8bit

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.
---
 lisp/ob-core.el | 27 ++++++++++++++++++---------
 1 file changed, 18 insertions(+), 9 deletions(-)

diff --git a/lisp/ob-core.el b/lisp/ob-core.el
index c61f2d400..90c52f8b7 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))
-- 
2.34.1


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

* Re: [PATCH] fix org-babel-view-src-block-info
  2024-09-22  0:25 [PATCH] fix org-babel-view-src-block-info Rodrigo Morales
@ 2024-09-22 10:38 ` Ihor Radchenko
  2024-09-23  1:24   ` Rodrigo Morales
  0 siblings, 1 reply; 4+ messages in thread
From: Ihor Radchenko @ 2024-09-22 10:38 UTC (permalink / raw)
  To: Rodrigo Morales; +Cc: emacs-orgmode

Rodrigo Morales <rodrigo-mailing-lists@morales.pe> writes:

> This is one of the first patches that I sent to the Org Mode
> project. Please let me know if I have done something wrong, so
> that I don't make the same mistake in the future.
>
> From 4453277ee0d9aa6318008a21c4f3f9b16d29c901 Mon Sep 17 00:00:00 2001
> From: Rodrigo Morales <rodrigo@morales.pe>
> Date: Sat, 21 Sep 2024 19:04:55 -0500
> Subject: [PATCH] lisp/ob-core.el: fix org-babel-view-src-block-info

Thanks!
Applied, onto bugfix.
I changed the commit message a little, clarifying the purpose of the
patch (rather than generic "fix"), adding a proper changelog entry (see
https://orgmode.org/worg/org-contribute.html#commit-messages), quoting
symbols as `symbols', and adding double space between sentences.

I also added TINYCHANGE cookie as I do not see your name in our records
of contributors with copyright assignment.

https://git.savannah.gnu.org/cgit/emacs/org-mode.git/commit/?id=d8fc26aefa

Note that we had another patch from Rodrigo Morales in 2021:
https://git.savannah.gnu.org/cgit/emacs/org-mode.git/commit/?id=e0535fa2d8215ba9a9f96058807648df72e2d99d
Is it yours? (it is under different email)

-- 
Ihor Radchenko // yantar92,
Org mode contributor,
Learn more about Org mode at <https://orgmode.org/>.
Support Org development at <https://liberapay.com/org-mode>,
or support my work at <https://liberapay.com/yantar92>


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

* Re: [PATCH] fix org-babel-view-src-block-info
  2024-09-22 10:38 ` Ihor Radchenko
@ 2024-09-23  1:24   ` Rodrigo Morales
  2024-09-23 18:01     ` Ihor Radchenko
  0 siblings, 1 reply; 4+ messages in thread
From: Rodrigo Morales @ 2024-09-23  1:24 UTC (permalink / raw)
  To: Ihor Radchenko, Rodrigo Morales; +Cc: emacs-orgmode

Ihor Radchenko <yantar92@posteo.net> writes:

> I changed the commit message a little, clarifying the purpose of the
> patch (rather than generic "fix"), adding a proper changelog entry (see
> https://orgmode.org/worg/org-contribute.html#commit-messages), quoting
> symbols as `symbols', and adding double space between sentences.
>
> I also added TINYCHANGE cookie as I do not see your name in our records
> of contributors with copyright assignment.

Thanks for the recommendations. I'll consider them in future
contributions.

> Note that we had another patch from Rodrigo Morales in 2021:
> https://git.savannah.gnu.org/cgit/emacs/org-mode.git/commit/?id=e0535fa2d8215ba9a9f96058807648df72e2d99d
> Is it yours? (it is under different email)

Yes, it was me. I used that e-mail address while studying at the
university. I am not currently studying at the same university, so I
don't have access to that e-mail address anymore.


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

* Re: [PATCH] fix org-babel-view-src-block-info
  2024-09-23  1:24   ` Rodrigo Morales
@ 2024-09-23 18:01     ` Ihor Radchenko
  0 siblings, 0 replies; 4+ messages in thread
From: Ihor Radchenko @ 2024-09-23 18:01 UTC (permalink / raw)
  To: Rodrigo Morales; +Cc: Rodrigo Morales, emacs-orgmode

Rodrigo Morales <rodrigo@morales.pe> writes:

>> Note that we had another patch from Rodrigo Morales in 2021:
>> https://git.savannah.gnu.org/cgit/emacs/org-mode.git/commit/?id=e0535fa2d8215ba9a9f96058807648df72e2d99d
>> Is it yours? (it is under different email)
>
> Yes, it was me. I used that e-mail address while studying at the
> university. I am not currently studying at the same university, so I
> don't have access to that e-mail address anymore.

Good to know.
For a moment, I thought that we got two contributors with the same name :)

-- 
Ihor Radchenko // yantar92,
Org mode contributor,
Learn more about Org mode at <https://orgmode.org/>.
Support Org development at <https://liberapay.com/org-mode>,
or support my work at <https://liberapay.com/yantar92>


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

end of thread, other threads:[~2024-09-24  8:34 UTC | newest]

Thread overview: 4+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2024-09-22  0:25 [PATCH] fix org-babel-view-src-block-info Rodrigo Morales
2024-09-22 10:38 ` Ihor Radchenko
2024-09-23  1:24   ` Rodrigo Morales
2024-09-23 18:01     ` Ihor Radchenko

Code repositories for project(s) associated with this external index

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

This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.