diff options
author | Achim Gratz <Stromeko@Stromeko.DE> | 2013-03-09 00:37:50 +0100 |
---|---|---|
committer | Achim Gratz <Stromeko@Stromeko.DE> | 2013-03-09 21:31:01 +0100 |
commit | 5fe486807e618029dda041300855ef6e3c6a7626 (patch) | |
tree | bba36f47cf9cd5119679281dc3f50b7c29435bbc | |
parent | 9dd13b2e1ec7ca6293d428b6cde2f35c369bf4db (diff) | |
download | org-mode-5fe486807e618029dda041300855ef6e3c6a7626.tar.gz |
ob-core: reimplement org-babel-confirm-evaluate
* lisp/ob-core.el (org-babel-confirm-evaluate): Re-implement using
bindings for common subexpressions.
There was a minor bug in the reporting of an aborted evaluation as
"disabled" when no export was happening and eval-no-export was t since
the state of the export was not checked again.
-rw-r--r-- | lisp/ob-core.el | 50 |
1 files changed, 25 insertions, 25 deletions
diff --git a/lisp/ob-core.el b/lisp/ob-core.el index fcec405..f8ca04f 100644 --- a/lisp/ob-core.el +++ b/lisp/ob-core.el @@ -294,32 +294,32 @@ confirmation from the user. Note disabling confirmation may result in accidental evaluation 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 (boundp 'org-current-export-file) - 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 (boundp 'org-current-export-file) - org-current-export-file - (or (equal eval "no-export") - (equal eval "never-export"))) + (let* ((info0th (nth 0 info)) + (info1st (nth 1 info)) + (info2nd (nth 2 info)) + (info4th (nth 4 info)) + (eval (or (cdr (assoc :eval info2nd)) + (when (assoc :noeval info2nd) "no"))) + (eval-no (or (equal eval "no") + (equal eval "never"))) + (export (org-bound-and-true-p org-current-export-file)) + (eval-no-export (and export (or (equal eval "no-export") + (equal eval "never-export")))) + (noeval (or eval-no eval-no-export)) + (query (or (equal eval "query") + (and export (equal eval "query-export")) + (when (functionp org-confirm-babel-evaluate) + (funcall org-confirm-babel-evaluate info0th info1st)) + org-confirm-babel-evaluate)) + (code-block (if info (format " %s " info0th) " ")) + (block-name (if info4th (format " (%s) " info4th) " "))) + (if (or noeval (and query - (not (yes-or-no-p - (format "Evaluate this%scode block%son your system? " - (if info (format " %s " (nth 0 info)) " ") - (if (nth 4 info) - (format " (%s) " (nth 4 info)) " ")))))) - (prog1 nil (message "Evaluation %s" - (if (or (equal eval "never") (equal eval "no") - (equal eval "no-export") - (equal eval "never-export")) - "Disabled" "Aborted"))) + (not (yes-or-no-p (format "Evaluate this%scode block%son your system? " + code-block block-name))))) + (prog1 nil + (message (format "Evaluation of this%scode-block%sis %s." + code-block block-name (if noeval "disabled" "aborted")))) t))) ;;;###autoload |