From mboxrd@z Thu Jan 1 00:00:00 1970 From: Achim Gratz Subject: [PATCH] ob-core: do not ask for confirmation if cached value is current Date: Tue, 26 Feb 2013 21:28:36 +0100 Message-ID: <87mwuqvmyz.fsf@Rainer.invalid> Mime-Version: 1.0 Content-Type: multipart/mixed; boundary="=-=-=" Return-path: Received: from eggs.gnu.org ([208.118.235.92]:41666) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1UAR93-0006f3-1o for emacs-orgmode@gnu.org; Tue, 26 Feb 2013 15:29:02 -0500 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1UAR91-0007Dc-CM for emacs-orgmode@gnu.org; Tue, 26 Feb 2013 15:29:00 -0500 Received: from plane.gmane.org ([80.91.229.3]:47692) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1UAR91-0007Co-54 for emacs-orgmode@gnu.org; Tue, 26 Feb 2013 15:28:59 -0500 Received: from list by plane.gmane.org with local (Exim 4.69) (envelope-from ) id 1UAR9J-0001TF-IN for emacs-orgmode@gnu.org; Tue, 26 Feb 2013 21:29:17 +0100 Received: from pd9eb3542.dip.t-dialin.net ([217.235.53.66]) by main.gmane.org with esmtp (Gmexim 0.1 (Debian)) id 1AlnuQ-0007hv-00 for ; Tue, 26 Feb 2013 21:29:17 +0100 Received: from Stromeko by pd9eb3542.dip.t-dialin.net with local (Gmexim 0.1 (Debian)) id 1AlnuQ-0007hv-00 for ; Tue, 26 Feb 2013 21:29:17 +0100 List-Id: "General discussions about Org-mode." List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: emacs-orgmode-bounces+geo-emacs-orgmode=m.gmane.org@gnu.org Sender: emacs-orgmode-bounces+geo-emacs-orgmode=m.gmane.org@gnu.org To: emacs-orgmode@gnu.org --=-=-= Content-Type: text/plain 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). --=-=-= Content-Type: text/x-patch; charset=utf-8 Content-Disposition: inline; filename=0001-ob-core-do-not-ask-for-confirmation-if-cached-value-.patch Content-Transfer-Encoding: 8bit >From da687f5a40767921c7f3f309eeda0cadb09f7116 Mon Sep 17 00:00:00 2001 From: Achim Gratz 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 --=-=-= Content-Type: text/plain Achim. -- +<[Q+ Matrix-12 WAVE#46+305 Neuron microQkb Andromeda XTk Blofeld]>+ Waldorf MIDI Implementation & additional documentation: http://Synth.Stromeko.net/Downloads.html#WaldorfDocs --=-=-=--