diff options
author | Eric Schulte <schulte.eric@gmail.com> | 2011-11-22 07:32:39 -0700 |
---|---|---|
committer | Eric Schulte <schulte.eric@gmail.com> | 2011-11-22 07:32:39 -0700 |
commit | a998cae72214ae5feb04c654d48f1acba66d11f4 (patch) | |
tree | 26aaa7caf2168e2563a85f78c6d485d45f773aaa | |
parent | c166760fcc2788953d60f52c7883df9331cc9954 (diff) | |
download | org-mode-a998cae72214ae5feb04c654d48f1acba66d11f4.tar.gz |
the :eval header argument now takes 4(6) possible values
* doc/org.texi (eval): Documenting the full range of :eval header
argument values.
* lisp/ob.el (org-babel-confirm-evaluate): Adding support for new
range of :eval header arguments.
* testing/lisp/test-ob.el (test-ob/eval-header-argument): Testing the
:eval header argument.
-rw-r--r-- | doc/org.texi | 25 | ||||
-rw-r--r-- | lisp/ob.el | 8 | ||||
-rw-r--r-- | testing/lisp/test-ob.el | 21 |
3 files changed, 44 insertions, 10 deletions
diff --git a/doc/org.texi b/doc/org.texi index 9bf5a9e..baa0dca 100644 --- a/doc/org.texi +++ b/doc/org.texi @@ -13112,14 +13112,23 @@ permissions of the tangled file are set to make it executable. @node eval, , shebang, Specific header arguments @subsubsection @code{:eval} The @code{:eval} header argument can be used to limit the evaluation of -specific code blocks. @code{:eval} accepts three arguments ``never'', -``query'' and ``non-export''. @code{:eval never} (or @code{:eval no}) will -ensure that a code block is never evaluated, this can be useful for -protecting against the evaluation of dangerous code blocks. @code{:eval -query} will require a query for every execution of a code block regardless of -the value of the @code{org-confirm-babel-evaluate} variable and @code{:eval -non-export} will inhibit the evaluation of code blocks during export but will -still allow interactive evaluation. +specific code blocks. The @code{:eval} header argument can be useful for +protecting against the evaluation of dangerous code blocks or to ensure that +evaluation will require a query regardless of the value of the +@code{org-confirm-babel-evaluate} variable. The possible values of +@code{:eval} and their effects are shown below. + +@table @code +@item never or no +The code block will not be evaluated under any circumstances. +@item query +Evaluation of the code block will require a query. +@item never-export or no-export +The code block will not be evaluated during export but may still be called +interactively. +@item query-export +Evaluation of the code block during export will require a query. +@end table If this header argument is not set then evaluation is determined by the value of the @code{org-confirm-babel-evaluate} variable see @ref{Code evaluation @@ -252,12 +252,15 @@ of potentially harmful code." (let* ((eval (or (cdr (assoc :eval (nth 2 info))) (when (assoc :noeval (nth 2 info)) "no"))) (query (cond ((equal eval "query") t) + ((and org-current-export-file + (equal eval "query-export")) t) ((functionp org-confirm-babel-evaluate) (funcall org-confirm-babel-evaluate (nth 0 info) (nth 1 info))) (t org-confirm-babel-evaluate)))) (if (or (equal eval "never") (equal eval "no") - (and (equal eval "non-export") org-current-export-file) + (and org-current-export-file (or (equal eval "no-export") + (equal eval "never-export"))) (and query (not (yes-or-no-p (format "Evaluate this%scode block%son your system? " @@ -266,7 +269,8 @@ of potentially harmful code." (format " (%s) " (nth 4 info)) " ")))))) (prog1 nil (message "Evaluation %s" (if (or (equal eval "never") (equal eval "no") - (equal eval "non-export")) + (equal eval "no-export") + (equal eval "never-export")) "Disabled" "Aborted"))) t))) diff --git a/testing/lisp/test-ob.el b/testing/lisp/test-ob.el index de66a97..5d673c4 100644 --- a/testing/lisp/test-ob.el +++ b/testing/lisp/test-ob.el @@ -531,6 +531,27 @@ on two lines (forward-line 6) (should (looking-at ": 2"))))) +(ert-deftest test-ob/eval-header-argument () + (flet ((check-eval (eval runp) + (org-test-with-temp-text (format "#+begin_src emacs-lisp :eval %s + (setq foo :evald) +#+end_src" eval) + (let ((foo :not-run)) + (if runp + (progn (should (org-babel-execute-src-block)) + (should (eq foo :evald))) + (progn (should-not (org-babel-execute-src-block)) + (should-not (eq foo :evald)))))))) + (check-eval "never" nil) + (check-eval "no" nil) + (check-eval "never-export" t) + (check-eval "no-export" t) + (let ((org-current-export-file "something")) + (check-eval "never" nil) + (check-eval "no" nil) + (check-eval "never-export" nil) + (check-eval "no-export" nil)))) + (provide 'test-ob) ;;; test-ob ends here |