emacs-orgmode
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: [O] [PATCH] Add 'inline-only option to org-export-babel-evaluate


From: Aaron Ecay
Subject: Re: [O] [PATCH] Add 'inline-only option to org-export-babel-evaluate
Date: Thu, 18 Apr 2013 04:24:10 -0400
User-agent: Notmuch/0.15.2+43~ge848af8 (http://notmuchmail.org) Emacs/24.3.50.1 (x86_64-unknown-linux-gnu)

Hi Eric,

2013ko apirilak 2an, Eric Schulte-ek idatzi zuen:
> 
> I'm happy to apply this patch, however please also supply a patch which
> updates the corresponding documentation.

By “documentation” you mean the texinfo manual, right?  Here is a new
version of this patch which also updates the manual.
>From 62ea51f473d387137b5294705241795d1d8bc39b Mon Sep 17 00:00:00 2001
From: Aaron Ecay <address@hidden>
Date: Sun, 31 Mar 2013 18:47:44 -0400
Subject: [PATCH] Add 'inline-only option to org-export-babel-evaluate
MIME-Version: 1.0
Content-Type: text/plain; charset=UTF-8
Content-Transfer-Encoding: 8bit

* lisp/ob-exp.el (org-export-babel-evaluate): Update defcustom to
  provide 'inline-only option
  (org-babel-exp-results): Implement 'inline-only for
  org-export-babel-evaluate
* doc/org.texi (Exporting code blocks): Document ‘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.
---
 doc/org.texi   |  7 ++++++-
 lisp/ob-exp.el | 11 ++++++++---
 2 files changed, 14 insertions(+), 4 deletions(-)

diff --git a/doc/org.texi b/doc/org.texi
index b4a9d8f..f8f9c31 100644
--- a/doc/org.texi
+++ b/doc/org.texi
@@ -12928,7 +12928,12 @@ Setting the @code{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
address@hidden  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
diff --git a/lisp/ob-exp.el b/lisp/ob-exp.el
index e74b803..aa496d3 100644
--- a/lisp/ob-exp.el
+++ b/lisp/ob-exp.el
@@ -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)
-- 
1.8.2.1

Thanks,

-- 
Aaron Ecay

reply via email to

[Prev in Thread] Current Thread [Next in Thread]