1
0
mirror of https://git.savannah.gnu.org/git/emacs/org-mode.git synced 2024-12-25 10:47:12 +00:00

Add 'inline-only option to org-export-babel-evaluate

* lisp/ob-exp.el (org-export-babel-evaluate): Add a 'inline-only option.
  (org-babel-exp-results): Implement 'inline-only for
  `org-export-babel-evaluate'.
* doc/org.texi (Exporting code blocks): Document the 'inline-only setting
  for `org-export-babel-evaluate'.

This is useful because there is no way for inline results to be stored.
The imagined usecase is that all non-inline source blocks will be
evaluated manually by the user.  Inline blocks, however, must be
evaluated during export, or they will be simply deleted by the exporter.
This commit is contained in:
Aaron Ecay 2013-03-31 18:47:44 -04:00 committed by Bastien Guerry
parent 4757c5c8dd
commit 25869e5670
2 changed files with 14 additions and 4 deletions

View File

@ -13582,7 +13582,12 @@ Setting the @var{org-export-babel-evaluate} variable to @code{nil} will
ensure that no code blocks are evaluated as part of the export process. This
can be useful in situations where potentially untrusted Org mode files are
exported in an automated fashion, for example when Org mode is used as the
markup language for a wiki.
markup language for a wiki. It is also possible to set this variable to
@code{inline-only}. In that case, only inline code blocks will be
evaluated, in order to insert their results. Non-inline code blocks are
assumed to have their results already inserted in the buffer by manual
evaluation. This setting is useful to avoid expensive recalculations during
export, not to provide security.
@comment node-name, next, previous, up
@comment Extracting source code, Evaluating code blocks, Exporting code blocks, Working With Source Code

View File

@ -52,10 +52,13 @@
(defcustom org-export-babel-evaluate t
"Switch controlling code evaluation during export.
When set to nil no code will be evaluated as part of the export
process."
process. When set to 'inline-only, only inline code blocks will
be executed."
:group 'org-babel
:version "24.1"
:type 'boolean)
:type '(choice (const :tag "Never" nil)
(const :tag "Only inline code" inline-only)
(const :tag "Always" t)))
(put 'org-export-babel-evaluate 'safe-local-variable (lambda (x) (eq x nil)))
(defun org-babel-exp-get-export-buffer ()
@ -378,7 +381,9 @@ Results are prepared in a manner suitable for export by org-mode.
This function is called by `org-babel-exp-do-export'. The code
block will be evaluated. Optional argument SILENT can be used to
inhibit insertion of results into the buffer."
(when (and org-export-babel-evaluate
(when (and (or (eq org-export-babel-evaluate t)
(and (eq type 'inline)
(eq org-export-babel-evaluate 'inline-only)))
(not (and hash (equal hash (org-babel-current-result-hash)))))
(let ((lang (nth 0 info))
(body (if (org-babel-noweb-p (nth 2 info) :eval)