mirror of
https://git.savannah.gnu.org/git/emacs/org-mode.git
synced 2024-11-25 07:27:57 +00:00
now possible to abort code block evaluation without throwing errors
this makes it possible to export while not evaluating some code blocks * lisp/ob-exp.el (org-babel-exp-do-export): removing hacky ":noeval", which is now an alias to ":eval no" * lisp/ob.el (org-babel-confirm-evaluate): ":noeval" is an alias for ":eval no", also no longer throwing errors (org-babel-header-arg-names): adding both eval and noeval as general header arguments (org-babel-execute-src-block): now using the new non-error confirmation functionality
This commit is contained in:
parent
2c33b2eb66
commit
e52909d902
@ -195,8 +195,7 @@ options are taken from `org-babel-default-header-args'."
|
||||
The function respects the value of the :exports header argument."
|
||||
(flet ((silently () (let ((session (cdr (assoc :session (nth 2 info)))))
|
||||
(when (and session
|
||||
(not (equal "none" session))
|
||||
(not (assoc :noeval (nth 2 info))))
|
||||
(not (equal "none" session)))
|
||||
(org-babel-exp-results info type 'silent))))
|
||||
(clean () (org-babel-remove-result info)))
|
||||
(case (intern (or (cdr (assoc :exports (nth 2 info))) "code"))
|
||||
|
31
lisp/ob.el
31
lisp/ob.el
@ -182,18 +182,20 @@ confirmation from the user.
|
||||
|
||||
Note disabling confirmation may result in accidental evaluation
|
||||
of potentially harmful code."
|
||||
(let* ((eval (cdr (assoc :eval (nth 2 info))))
|
||||
(let* ((eval (or (cdr (assoc :eval (nth 2 info)))
|
||||
(when (assoc :noeval (nth 2 info)) "no")))
|
||||
(query (or (equal eval "query")
|
||||
(and (functionp org-confirm-babel-evaluate)
|
||||
(funcall org-confirm-babel-evaluate
|
||||
(nth 0 info) (nth 1 info)))
|
||||
org-confirm-babel-evaluate)))
|
||||
(when (or (equal eval "never")
|
||||
(if (or (equal eval "never") (equal eval "no")
|
||||
(and query
|
||||
(not (yes-or-no-p
|
||||
(format "Evaluate this%scode on your system? "
|
||||
(if info (format " %s " (nth 0 info)) " "))))))
|
||||
(error "evaluation aborted"))))
|
||||
(prog1 nil (message "evaluation aborted"))
|
||||
t)))
|
||||
|
||||
;;;###autoload
|
||||
(defun org-babel-execute-safely-maybe ()
|
||||
@ -254,7 +256,7 @@ then run `org-babel-pop-to-session'."
|
||||
|
||||
(defconst org-babel-header-arg-names
|
||||
'(cache cmdline colnames dir exports file noweb results
|
||||
session tangle var noeval comments)
|
||||
session tangle var eval noeval comments)
|
||||
"Common header arguments used by org-babel.
|
||||
Note that individual languages may define their own language
|
||||
specific header arguments as well.")
|
||||
@ -322,13 +324,11 @@ Optionally supply a value for PARAMS which will be merged with
|
||||
the header arguments specified at the front of the source code
|
||||
block."
|
||||
(interactive)
|
||||
(let* ((info (or info (org-babel-get-src-block-info)))
|
||||
;; note the `evaluation-confirmed' variable is currently not
|
||||
;; used, but could be used later to avoid the need for
|
||||
;; chaining confirmations
|
||||
(evaluation-confirmed (org-babel-confirm-evaluate info))
|
||||
(lang (nth 0 info))
|
||||
(params (setf (nth 2 info)
|
||||
(let ((info (or info (org-babel-get-src-block-info))))
|
||||
(when (org-babel-confirm-evaluate info)
|
||||
(let* ((lang (nth 0 info))
|
||||
(params (setf
|
||||
(nth 2 info)
|
||||
(sort (org-babel-merge-params (nth 2 info) params)
|
||||
(lambda (el1 el2) (string< (symbol-name (car el1))
|
||||
(symbol-name (car el2)))))))
|
||||
@ -351,7 +351,8 @@ block."
|
||||
(default-directory
|
||||
(or (and dir (file-name-as-directory dir)) default-directory))
|
||||
(org-babel-call-process-region-original
|
||||
(if (boundp 'org-babel-call-process-region-original) org-babel-call-process-region-original
|
||||
(if (boundp 'org-babel-call-process-region-original)
|
||||
org-babel-call-process-region-original
|
||||
(symbol-function 'call-process-region)))
|
||||
(indent (car (last info)))
|
||||
result)
|
||||
@ -365,8 +366,8 @@ block."
|
||||
(goto-char (org-babel-where-is-src-block-result nil info))
|
||||
(end-of-line 1) (forward-char 1)
|
||||
(setq result (org-babel-read-result))
|
||||
(message (replace-regexp-in-string "%" "%%"
|
||||
(format "%S" result))) result)
|
||||
(message (replace-regexp-in-string
|
||||
"%" "%%" (format "%S" result))) result)
|
||||
(message "executing %s code block%s..."
|
||||
(capitalize lang)
|
||||
(if (nth 4 info) (format " (%s)" (nth 4 info)) ""))
|
||||
@ -381,7 +382,7 @@ block."
|
||||
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 processed-params)
|
||||
"Expand BODY with PARAMS.
|
||||
|
Loading…
Reference in New Issue
Block a user