* [PATCH] ob-core: do not ask for confirmation if cached value is current
@ 2013-02-26 20:28 Achim Gratz
2013-02-27 8:46 ` Bastien
2013-03-09 22:32 ` Achim Gratz
0 siblings, 2 replies; 7+ messages in thread
From: Achim Gratz @ 2013-02-26 20:28 UTC (permalink / raw)
To: emacs-orgmode
[-- Attachment #1: Type: text/plain, Size: 219 bytes --]
Babel asks for confirmation to evaluate a source block even when it is
going to use the cached value. This patch skips the superfluous
confirmation in that case (no evaluation takes place, the cached value
is used).
[-- Attachment #2: 0001-ob-core-do-not-ask-for-confirmation-if-cached-value-.patch --]
[-- Type: text/x-patch, Size: 2857 bytes --]
From da687f5a40767921c7f3f309eeda0cadb09f7116 Mon Sep 17 00:00:00 2001
From: Achim Gratz <Stromeko@Stromeko.DE>
Date: Tue, 26 Feb 2013 21:23:37 +0100
Subject: [PATCH] ob-core: do not ask for confirmation if cached value is
current
MIME-Version: 1.0
Content-Type: text/plain; charset=UTF-8
Content-Transfer-Encoding: 8bit
* lisp/ob-core.el (org-babel-execute-src-block): Do not run
`org-babel-confirm-evaluate´ if source block has a cache and the
cache value is current (there is no evaluation involved in this
case).
---
lisp/ob-core.el | 30 ++++++++++++++++--------------
1 file changed, 16 insertions(+), 14 deletions(-)
diff --git a/lisp/ob-core.el b/lisp/ob-core.el
index 3278bf9..573fa20 100644
--- a/lisp/ob-core.el
+++ b/lisp/ob-core.el
@@ -521,21 +521,23 @@ (defun org-babel-execute-src-block (&optional arg info params)
the header arguments specified at the front of the source code
block."
(interactive)
- (let ((info (or info (org-babel-get-src-block-info))))
- (when (org-babel-confirm-evaluate
- (let ((i info))
- (setf (nth 2 i) (org-babel-merge-params (nth 2 info) params))
- i))
+ (let* ((info (or info (org-babel-get-src-block-info)))
+ (params (if params
+ (org-babel-process-params
+ (org-babel-merge-params (nth 2 info) params))
+ (nth 2 info)))
+ (cache? (and (not arg) (cdr (assoc :cache params))
+ (string= "yes" (cdr (assoc :cache params)))))
+ (new-hash (when cache? (org-babel-sha1-hash info)))
+ (old-hash (when cache? (org-babel-current-result-hash)))
+ (cache-current? (and (not arg) new-hash (equal new-hash old-hash))))
+ (when (or cache-current?
+ (org-babel-confirm-evaluate
+ (let ((i info))
+ (setf (nth 2 i) (org-babel-merge-params (nth 2 info) params))
+ i)))
(let* ((lang (nth 0 info))
- (params (if params
- (org-babel-process-params
- (org-babel-merge-params (nth 2 info) params))
- (nth 2 info)))
- (cache? (and (not arg) (cdr (assoc :cache params))
- (string= "yes" (cdr (assoc :cache params)))))
(result-params (cdr (assoc :result-params params)))
- (new-hash (when cache? (org-babel-sha1-hash info)))
- (old-hash (when cache? (org-babel-current-result-hash)))
(body (setf (nth 1 info)
(if (org-babel-noweb-p params :eval)
(org-babel-expand-noweb-references info)
@@ -562,7 +564,7 @@ (defun org-babel-execute-src-block (&optional arg info params)
(funcall lang-check (symbol-name
(cdr (assoc lang org-src-lang-modes))))
(error "No org-babel-execute function for %s!" lang))))
- (if (and (not arg) new-hash (equal new-hash old-hash))
+ (if cache-current?
(save-excursion ;; return cached result
(goto-char (org-babel-where-is-src-block-result nil info))
(end-of-line 1) (forward-char 1)
--
1.8.1.4
[-- Attachment #3: Type: text/plain, Size: 192 bytes --]
Achim.
--
+<[Q+ Matrix-12 WAVE#46+305 Neuron microQkb Andromeda XTk Blofeld]>+
Waldorf MIDI Implementation & additional documentation:
http://Synth.Stromeko.net/Downloads.html#WaldorfDocs
^ permalink raw reply related [flat|nested] 7+ messages in thread
* Re: [PATCH] ob-core: do not ask for confirmation if cached value is current
2013-02-26 20:28 [PATCH] ob-core: do not ask for confirmation if cached value is current Achim Gratz
@ 2013-02-27 8:46 ` Bastien
2013-02-27 9:20 ` Achim Gratz
2013-02-27 10:39 ` Achim Gratz
2013-03-09 22:32 ` Achim Gratz
1 sibling, 2 replies; 7+ messages in thread
From: Bastien @ 2013-02-27 8:46 UTC (permalink / raw)
To: Achim Gratz; +Cc: emacs-orgmode
Hi Achim,
Achim Gratz <Stromeko@nexgo.de> writes:
> Babel asks for confirmation to evaluate a source block even when it is
> going to use the cached value. This patch skips the superfluous
> confirmation in that case (no evaluation takes place, the cached value
> is used).
thanks for the patch. I applied it but renamed cache? and
cache-current? to cache-p and cache-current-p.
Let's avoid the ? character in variables and functions, as
this character is not self-inserted when in the prompt of
C-h v and C-h f, you have to use C-q ? to insert it.
--
Bastien
^ permalink raw reply [flat|nested] 7+ messages in thread
* Re: [PATCH] ob-core: do not ask for confirmation if cached value is current
2013-02-27 8:46 ` Bastien
@ 2013-02-27 9:20 ` Achim Gratz
2013-02-27 9:24 ` Bastien
2013-02-27 10:39 ` Achim Gratz
1 sibling, 1 reply; 7+ messages in thread
From: Achim Gratz @ 2013-02-27 9:20 UTC (permalink / raw)
To: emacs-orgmode
Bastien <bzg <at> altern.org> writes:
> thanks for the patch. I applied it but renamed cache? and
> cache-current? to cache-p and cache-current-p.
Thanks. I have no preference either way regarding the names, I was just
following the example of cache?, which I copied from the original code. There's
another "cache?" in ob-lob, IIRC.
Regards,
Achim.
^ permalink raw reply [flat|nested] 7+ messages in thread
* Re: [PATCH] ob-core: do not ask for confirmation if cached value is current
2013-02-27 8:46 ` Bastien
2013-02-27 9:20 ` Achim Gratz
@ 2013-02-27 10:39 ` Achim Gratz
2013-02-27 12:29 ` Bastien
1 sibling, 1 reply; 7+ messages in thread
From: Achim Gratz @ 2013-02-27 10:39 UTC (permalink / raw)
To: emacs-orgmode
Bastien <bzg <at> altern.org> writes:
> thanks for the patch. I applied it but renamed cache? and
> cache-current? to cache-p and cache-current-p.
That patch needs amending. You let-bind cache-current, but then try to use
cache-current-p.
Regards,
Achim.
^ permalink raw reply [flat|nested] 7+ messages in thread
* Re: [PATCH] ob-core: do not ask for confirmation if cached value is current
2013-02-27 10:39 ` Achim Gratz
@ 2013-02-27 12:29 ` Bastien
0 siblings, 0 replies; 7+ messages in thread
From: Bastien @ 2013-02-27 12:29 UTC (permalink / raw)
To: Achim Gratz; +Cc: emacs-orgmode
Achim Gratz <Stromeko@NexGo.DE> writes:
> Bastien <bzg <at> altern.org> writes:
>
>> thanks for the patch. I applied it but renamed cache? and
>> cache-current? to cache-p and cache-current-p.
>
> That patch needs amending. You let-bind cache-current, but then try to use
> cache-current-p.
Er... fixed, thanks for double-checking!
--
Bastien
^ permalink raw reply [flat|nested] 7+ messages in thread
* Re: [PATCH] ob-core: do not ask for confirmation if cached value is current
2013-02-26 20:28 [PATCH] ob-core: do not ask for confirmation if cached value is current Achim Gratz
2013-02-27 8:46 ` Bastien
@ 2013-03-09 22:32 ` Achim Gratz
1 sibling, 0 replies; 7+ messages in thread
From: Achim Gratz @ 2013-03-09 22:32 UTC (permalink / raw)
To: emacs-orgmode
Based on discussion with Nicolas Goaziou and Eric Schulte, this patch
has been refactored and reimplemented as a patch series. Eric Schulte
has contributed additional improvements. The functionality is now in
Org.
Regards,
Achim.
--
+<[Q+ Matrix-12 WAVE#46+305 Neuron microQkb Andromeda XTk Blofeld]>+
Wavetables for the Waldorf Blofeld:
http://Synth.Stromeko.net/Downloads.html#BlofeldUserWavetables
^ permalink raw reply [flat|nested] 7+ messages in thread
end of thread, other threads:[~2013-03-09 22:33 UTC | newest]
Thread overview: 7+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2013-02-26 20:28 [PATCH] ob-core: do not ask for confirmation if cached value is current Achim Gratz
2013-02-27 8:46 ` Bastien
2013-02-27 9:20 ` Achim Gratz
2013-02-27 9:24 ` Bastien
2013-02-27 10:39 ` Achim Gratz
2013-02-27 12:29 ` Bastien
2013-03-09 22:32 ` Achim Gratz
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).