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