From mboxrd@z Thu Jan 1 00:00:00 1970 From: Aaron Ecay Subject: Re: [PATCH] Add 'inline-only option to org-export-babel-evaluate Date: Thu, 18 Apr 2013 04:24:10 -0400 Message-ID: <874nf4s0ut.fsf@gmail.com> References: <1364795085-14578-1-git-send-email-aaronecay@gmail.com> <87bo9wr33z.fsf@gmail.com> Mime-Version: 1.0 Content-Type: multipart/mixed; boundary="=-=-=" Return-path: Received: from eggs.gnu.org ([208.118.235.92]:48326) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1USk8c-0005tj-3D for emacs-orgmode@gnu.org; Thu, 18 Apr 2013 04:24:16 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1USk8a-0003B9-RT for emacs-orgmode@gnu.org; Thu, 18 Apr 2013 04:24:14 -0400 Received: from mail-vc0-f179.google.com ([209.85.220.179]:36798) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1USk8a-0003B5-Ld for emacs-orgmode@gnu.org; Thu, 18 Apr 2013 04:24:12 -0400 Received: by mail-vc0-f179.google.com with SMTP id hz11so2154664vcb.38 for ; Thu, 18 Apr 2013 01:24:12 -0700 (PDT) In-Reply-To: <87bo9wr33z.fsf@gmail.com> List-Id: "General discussions about Org-mode." List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: emacs-orgmode-bounces+geo-emacs-orgmode=m.gmane.org@gnu.org Sender: emacs-orgmode-bounces+geo-emacs-orgmode=m.gmane.org@gnu.org To: Eric Schulte Cc: emacs-orgmode@gnu.org --=-=-= Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: quoted-printable Hi Eric, 2013ko apirilak 2an, Eric Schulte-ek idatzi zuen: >=20 > I'm happy to apply this patch, however please also supply a patch which > updates the corresponding documentation. By =E2=80=9Cdocumentation=E2=80=9D you mean the texinfo manual, right? Her= e is a new version of this patch which also updates the manual. --=-=-= Content-Type: text/x-patch; charset=utf-8 Content-Disposition: inline; filename=0001-Add-inline-only-option-to-org-export-babel-evaluate.patch Content-Transfer-Encoding: quoted-printable >From 62ea51f473d387137b5294705241795d1d8bc39b Mon Sep 17 00:00:00 2001 From: Aaron Ecay 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=3DUTF-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 =E2=80=98inline-only setti= ng 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} varia= ble to @code{nil} will ensure that no code blocks are evaluated as part of the export process. T= his 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{=E2=80=98inline-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 duri= ng +export, not to provide security. =20 @comment node-name, next, previous, up @comment Extracting source code, Evaluating code blocks, Exporting code b= locks, 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= ))) =20 (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) --=20 1.8.2.1 --=-=-= Content-Type: text/plain Thanks, -- Aaron Ecay --=-=-=--