emacs-orgmode@gnu.org archives
 help / color / mirror / code / Atom feed
* PATCH: Display point of code block point when confirming evaluation
@ 2019-12-07  7:26 Jarmo Hurri
  2020-09-30  4:04 ` Kyle Meyer
  0 siblings, 1 reply; 5+ messages in thread
From: Jarmo Hurri @ 2019-12-07  7:26 UTC (permalink / raw)
  To: emacs-orgmode

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


Greetings.

Please find attached a patch that adds the point of the source code
block to the message shown to user when confirming the evaluation of the
block.

In large org-files, I have often trouble figuring out which code block
Org is confirming me to evaluate when exporting. This is especially true
when I have set 'cache: yes'. When something changes in code, these
blocks need to be re-evaluated during export, but the '#results:' of
these blocks are not changed. Therefore, on the next export I will be
asked again, unless I find the block and evaluate it by hand myself.

This patch adds the 'start' element of source block info at the end of
the confirmation message. 

Jarmo


[-- Warning: decoded text below may be mangled, UTF-8 assumed --]
[-- Attachment #2: point in confirm --]
[-- Type: text/x-patch, Size: 1649 bytes --]

From aaa68af8a7710ffe2c61fc45edf2ff377438cd32 Mon Sep 17 00:00:00 2001
From: Jarmo Hurri <jarmo.hurri@iki.fi>
Date: Sat, 7 Dec 2019 09:14:34 +0200
Subject: [PATCH] ob-core.el: Display block point during evaluation
 confirmation

* lisp/ob-core.el (org-babel-confirm-evaluate): Display code block
point when querying confirmation of evaluation.

This addresses the problem of finding the block currently evaluated.
---
 lisp/ob-core.el | 11 ++++++-----
 1 file changed, 6 insertions(+), 5 deletions(-)

diff --git a/lisp/ob-core.el b/lisp/ob-core.el
index f877ff51b..7ba9894e6 100644
--- a/lisp/ob-core.el
+++ b/lisp/ob-core.el
@@ -277,7 +277,8 @@ environment, to override this check."
   (let* ((evalp (org-babel-check-confirm-evaluate info))
 	 (lang (nth 0 info))
 	 (name (nth 4 info))
-	 (name-string (if name (format " (%s) " name) " ")))
+	 (name-string (if name (format " (%s) " name) " "))
+	 (start (nth 5 info)))
     (pcase evalp
       (`nil nil)
       (`t t)
@@ -285,11 +286,11 @@ environment, to override this check."
 	       (and (not (bound-and-true-p
 			  org-babel-confirm-evaluate-answer-no))
 		    (yes-or-no-p
-		     (format "Evaluate this %s code block%son your system? "
-			     lang name-string)))
+		     (format "Evaluate this %s code block%son your system (point %d)? "
+			     lang name-string start)))
 	       (progn
-		(message "Evaluation of this %s code block%sis aborted."
-			 lang name-string)
+		(message "Evaluation of this %s code block%sis aborted (point %d)."
+			 lang name-string start)
 		nil)))
       (x (error "Unexpected value `%s' from `org-babel-check-confirm-evaluate'" x)))))
 
-- 
2.21.0


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

* Re: PATCH: Display point of code block point when confirming evaluation
  2019-12-07  7:26 PATCH: Display point of code block point when confirming evaluation Jarmo Hurri
@ 2020-09-30  4:04 ` Kyle Meyer
  2020-09-30  4:57   ` TEC
  2020-10-07  3:37   ` Kyle Meyer
  0 siblings, 2 replies; 5+ messages in thread
From: Kyle Meyer @ 2020-09-30  4:04 UTC (permalink / raw)
  To: Jarmo Hurri; +Cc: emacs-orgmode

Thanks for the patch, and sorry for the very delayed response.

Jarmo Hurri writes:

> Greetings.
>
> Please find attached a patch that adds the point of the source code
> block to the message shown to user when confirming the evaluation of the
> block.
>
> In large org-files, I have often trouble figuring out which code block
> Org is confirming me to evaluate when exporting. This is especially true
> when I have set 'cache: yes'. When something changes in code, these
> blocks need to be re-evaluated during export, but the '#results:' of
> these blocks are not changed. Therefore, on the next export I will be
> asked again, unless I find the block and evaluate it by hand myself.
>
> This patch adds the 'start' element of source block info at the end of
> the confirmation message. 

That sounds reasonable to me, and the change looks fine to me.  My only
thought is that perhaps the line number would be friendlier to report,
but I don't feel strongly about that.

I'll wait a few days for any babel users to chime in and then apply
(unless you reply that you'd like to reroll it to use line numbers).


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

* Re: PATCH: Display point of code block point when confirming evaluation
  2020-09-30  4:04 ` Kyle Meyer
@ 2020-09-30  4:57   ` TEC
  2020-09-30 16:46     ` Eric S Fraga
  2020-10-07  3:37   ` Kyle Meyer
  1 sibling, 1 reply; 5+ messages in thread
From: TEC @ 2020-09-30  4:57 UTC (permalink / raw)
  To: Kyle Meyer; +Cc: Jarmo Hurri, emacs-orgmode


Kyle Meyer <kyle@kyleam.com> writes:

> That sounds reasonable to me, and the change looks fine to me. 
> My only
> thought is that perhaps the line number would be friendlier to 
> report,
> but I don't feel strongly about that.

+1 for line numbers

Assuming the current format is something like:
  "Do you want to eval <lang> block at <pos> y/n:"
I'd be in favour of:
  "Do you want to eval <lang> block at <pos> (line <line>) y/n:"
or similar.

All the best,

Timothy.


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

* Re: PATCH: Display point of code block point when confirming evaluation
  2020-09-30  4:57   ` TEC
@ 2020-09-30 16:46     ` Eric S Fraga
  0 siblings, 0 replies; 5+ messages in thread
From: Eric S Fraga @ 2020-09-30 16:46 UTC (permalink / raw)
  To: TEC; +Cc: Jarmo Hurri, emacs-orgmode

On Wednesday, 30 Sep 2020 at 12:57, TEC wrote:
> +1 for line numbers

Likewise.

And, just to be greedy, the name of the source block as well would be
very useful (if present).  I do tend to name all of my blocks, if only
to help with navigation by being able to jump to any block from anywhere
else in the file/buffer.

-- 
: Eric S Fraga via Emacs 28.0.50, Org release_9.4-38-g16f505


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

* Re: PATCH: Display point of code block point when confirming evaluation
  2020-09-30  4:04 ` Kyle Meyer
  2020-09-30  4:57   ` TEC
@ 2020-10-07  3:37   ` Kyle Meyer
  1 sibling, 0 replies; 5+ messages in thread
From: Kyle Meyer @ 2020-10-07  3:37 UTC (permalink / raw)
  To: Jarmo Hurri; +Cc: emacs-orgmode

Kyle Meyer writes:

> That sounds reasonable to me, and the change looks fine to me.  My only
> thought is that perhaps the line number would be friendlier to report,
> but I don't feel strongly about that.
>
> I'll wait a few days for any babel users to chime in and then apply
> (unless you reply that you'd like to reroll it to use line numbers).

A couple of votes came in favor of using line numbers here, and the idea
of using the source block name was also brought up.  (Thanks, Timothy
and Eric, for the input.)

Jarmo, what do you think?


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

end of thread, other threads:[~2020-10-07  3:38 UTC | newest]

Thread overview: 5+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2019-12-07  7:26 PATCH: Display point of code block point when confirming evaluation Jarmo Hurri
2020-09-30  4:04 ` Kyle Meyer
2020-09-30  4:57   ` TEC
2020-09-30 16:46     ` Eric S Fraga
2020-10-07  3:37   ` Kyle Meyer

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).