瀏覽代碼

ob-core: allow auto-denial of source block evaluation

* lisp/ob-core.el (org-babel-confirm-evaluate-answer-no): Dynamically
  scoped variable, if bound non-nil the confirmation dialog will not
  be initiated and denial of evaluation is assumed.

  The new variable `org-babel-confirm-evaluate-answer-no´ can be bound
  to suppress the user interaction as is needed for async export, as
  discussed in http://thread.gmane.org/gmane.emacs.orgmode/67719
Achim Gratz 12 年之前
父節點
當前提交
4f7d514f13
共有 1 個文件被更改,包括 14 次插入4 次删除
  1. 14 4
      lisp/ob-core.el

+ 14 - 4
lisp/ob-core.el

@@ -325,9 +325,16 @@ Do not query the user."
 	   (message (format "Evaluation of this%scode-block%sis disabled."
 			    code-block block-name))))))
 
+ ;; dynamically scoped for asynchroneous export
+(defvar org-babel-confirm-evaluate-answer-no)
+
 (defsubst org-babel-confirm-evaluate (info)
   "Confirm evaluation of the code block INFO.
-This behavior can be suppressed by setting the value of
+
+If the variable `org-babel-confirm-evaluate-answer-no´ is bound
+to a non-nil value, auto-answer with \"no\".
+
+This query can also be suppressed by setting the value of
 `org-confirm-babel-evaluate' to nil, in which case all future
 interactive code block evaluations will proceed without any
 confirmation from the user.
@@ -336,9 +343,12 @@ Note disabling confirmation may result in accidental evaluation
 of potentially harmful code."
   (org-babel-check-confirm-evaluate info
     (not (when query
-	   (unless (yes-or-no-p (format
-				 "Evaluate this%scode block%son your system? "
-				 code-block block-name))
+	   (unless
+	       (and (not (org-bound-and-true-p
+			  org-babel-confirm-evaluate-answer-no))
+		    (yes-or-no-p
+		     (format "Evaluate this%scode block%son your system? "
+			     code-block block-name)))
 	     (message (format "Evaluation of this%scode-block%sis aborted."
 			      code-block block-name)))))))