浏览代码

Revert "ob-core.el: Do not ask for confirmation if cached value is current"

Reverting "Fix a typo I introduced while editing Achim's commit 091bf0"
Reverting "ob-core.el: Do not ask for confirmation if cached value is current"

This reverts commit 091bf0251454d4a9e00fd7054a25b0097822253a.
Achim Gratz 12 年之前
父节点
当前提交
eee580c8b3
共有 1 个文件被更改,包括 35 次插入36 次删除
  1. 35 36
      lisp/ob-core.el

+ 35 - 36
lisp/ob-core.el

@@ -521,23 +521,21 @@ Optionally supply a value for PARAMS which will be merged with
 the header arguments specified at the front of the source code
 the header arguments specified at the front of the source code
 block."
 block."
   (interactive)
   (interactive)
-  (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-p (and (not arg) (cdr (assoc :cache params))
-		       (string= "yes" (cdr (assoc :cache params)))))
-	 (new-hash (when cache-p (org-babel-sha1-hash info)))
-	 (old-hash (when cache-p (org-babel-current-result-hash)))
-	 (cache-current-p (and (not arg) new-hash (equal new-hash old-hash))))
-    (when (or cache-current-p
-	      (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))))
+    (when (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))
       (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)))
 	     (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)
 	     (body (setf (nth 1 info)
 			 (if (org-babel-noweb-p params :eval)
 			 (if (org-babel-noweb-p params :eval)
 			     (org-babel-expand-noweb-references info)
 			     (org-babel-expand-noweb-references info)
@@ -564,7 +562,7 @@ block."
 			  (funcall lang-check (symbol-name
 			  (funcall lang-check (symbol-name
 					       (cdr (assoc lang org-src-lang-modes))))
 					       (cdr (assoc lang org-src-lang-modes))))
 			  (error "No org-babel-execute function for %s!" lang))))
 			  (error "No org-babel-execute function for %s!" lang))))
-	      (if cache-current-p
+	      (if (and (not arg) new-hash (equal new-hash old-hash))
 		  (save-excursion ;; return cached result
 		  (save-excursion ;; return cached result
 		    (goto-char (org-babel-where-is-src-block-result nil info))
 		    (goto-char (org-babel-where-is-src-block-result nil info))
 		    (end-of-line 1) (forward-char 1)
 		    (end-of-line 1) (forward-char 1)
@@ -578,26 +576,27 @@ block."
 		    (progn
 		    (progn
 		      (funcall cmd body params)
 		      (funcall cmd body params)
 		      (message "result silenced"))
 		      (message "result silenced"))
-		  (setq result
-			((lambda (result)
-			   (if (and (eq (cdr (assoc :result-type params)) 'value)
-				    (or (member "vector" result-params)
-					(member "table" result-params))
-				    (not (listp result)))
-			       (list (list result)) result))
-			 (funcall cmd body params)))
-		  ;; if non-empty result and :file then write to :file
-		  (when (cdr (assoc :file params))
-		    (when result
-		      (with-temp-file (cdr (assoc :file params))
-			(insert
-			 (org-babel-format-result
-			  result (cdr (assoc :sep (nth 2 info)))))))
-		    (setq result (cdr (assoc :file params))))
-		  (org-babel-insert-result
-		   result result-params info new-hash indent lang)
-		  (run-hooks 'org-babel-after-execute-hook)
-		  result)))
+		(setq result
+		      ((lambda (result)
+			 (if (and (eq (cdr (assoc :result-type params)) 'value)
+				  (or (member "vector" result-params)
+				      (member "table" result-params))
+				  (not (listp result)))
+			     (list (list result)) result))
+		       (funcall cmd body params)))
+		;; if non-empty result and :file then write to :file
+		(when (cdr (assoc :file params))
+		  (when result
+		    (with-temp-file (cdr (assoc :file params))
+		      (insert
+		       (org-babel-format-result
+			result (cdr (assoc :sep (nth 2 info)))))))
+		  (setq result (cdr (assoc :file params))))
+		(org-babel-insert-result
+		 result result-params info new-hash indent lang)
+		(run-hooks 'org-babel-after-execute-hook)
+		result
+		)))
 	  (setq call-process-region 'org-babel-call-process-region-original))))))
 	  (setq call-process-region 'org-babel-call-process-region-original))))))
 
 
 (defun org-babel-expand-body:generic (body params &optional var-lines)
 (defun org-babel-expand-body:generic (body params &optional var-lines)