refactor `org-babel-check-confirm-evaluate' macro
- meaningful variable names - don't overly pollute the name space of the macro body * lisp/ob-core.el (org-babel-check-confirm-evaluate): Refactoring.
This commit is contained in:
parent
bc6564ab48
commit
d7758f565c
|
@ -286,29 +286,36 @@ Returns a list
|
||||||
|
|
||||||
(defvar org-current-export-file) ; dynamically bound
|
(defvar org-current-export-file) ; dynamically bound
|
||||||
(defmacro org-babel-check-confirm-evaluate (info &rest body)
|
(defmacro org-babel-check-confirm-evaluate (info &rest body)
|
||||||
"Pull some information from code block INFO and evaluate BODY."
|
"Evaluate BODY with special execution confirmation variables set.
|
||||||
|
|
||||||
|
Specifically; NOEVAL will indicate if evaluation is allowed,
|
||||||
|
QUERY will indicate if a user query is required, CODE-BLOCK will
|
||||||
|
hold the language of the code block, and BLOCK-NAME will hold the
|
||||||
|
name of the code block."
|
||||||
(declare (indent defun))
|
(declare (indent defun))
|
||||||
`(let* ((info0th (nth 0 ,info))
|
(org-with-gensyms
|
||||||
(info1st (nth 1 ,info))
|
(lang block-body headers name eval eval-no export eval-no-export)
|
||||||
(info2nd (nth 2 ,info))
|
`(let* ((,lang (nth 0 ,info))
|
||||||
(info4th (nth 4 ,info))
|
(,block-body (nth 1 ,info))
|
||||||
(eval (or (cdr (assoc :eval info2nd))
|
(,headers (nth 2 ,info))
|
||||||
(when (assoc :noeval info2nd) "no")))
|
(,name (nth 4 ,info))
|
||||||
(eval-no (or (equal eval "no")
|
(,eval (or (cdr (assoc :eval ,headers))
|
||||||
(equal eval "never")))
|
(when (assoc :noeval ,headers) "no")))
|
||||||
(export (org-bound-and-true-p org-current-export-file))
|
(,eval-no (or (equal ,eval "no")
|
||||||
(eval-no-export (and export (or (equal eval "no-export")
|
(equal ,eval "never")))
|
||||||
(equal eval "never-export"))))
|
(,export (org-bound-and-true-p org-current-export-file))
|
||||||
(noeval (or eval-no eval-no-export))
|
(,eval-no-export (and ,export (or (equal ,eval "no-export")
|
||||||
(query (or (equal eval "query")
|
(equal ,eval "never-export"))))
|
||||||
(and export (equal eval "query-export"))
|
(noeval (or ,eval-no ,eval-no-export))
|
||||||
(when (functionp org-confirm-babel-evaluate)
|
(query (or (equal ,eval "query")
|
||||||
(funcall org-confirm-babel-evaluate
|
(and ,export (equal ,eval "query-export"))
|
||||||
info0th info1st))
|
(when (functionp org-confirm-babel-evaluate)
|
||||||
org-confirm-babel-evaluate))
|
(funcall org-confirm-babel-evaluate
|
||||||
(code-block (if info (format " %s " info0th) " "))
|
,lang ,block-body))
|
||||||
(block-name (if info4th (format " (%s) " info4th) " ")))
|
org-confirm-babel-evaluate))
|
||||||
,@body))
|
(code-block (if ,info (format " %s " ,lang) " "))
|
||||||
|
(block-name (if ,name (format " (%s) " ,name) " ")))
|
||||||
|
,@body)))
|
||||||
|
|
||||||
(defsubst org-babel-check-evaluate (info)
|
(defsubst org-babel-check-evaluate (info)
|
||||||
"Check if code block INFO should be evaluated.
|
"Check if code block INFO should be evaluated.
|
||||||
|
|
Loading…
Reference in New Issue