* [PATCH] Add 'inline-only option to org-export-babel-evaluate @ 2013-04-01 5:44 Aaron Ecay 2013-04-01 7:45 ` Nicolas Goaziou 2013-04-02 22:14 ` Eric Schulte 0 siblings, 2 replies; 9+ messages in thread From: Aaron Ecay @ 2013-04-01 5:44 UTC (permalink / raw) To: emacs-orgmode * 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 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. --- lisp/ob-exp.el | 11 ++++++++--- 1 file changed, 8 insertions(+), 3 deletions(-) diff --git a/lisp/ob-exp.el b/lisp/ob-exp.el index 0d98690..6783bd5 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 ^ permalink raw reply related [flat|nested] 9+ messages in thread
* Re: [PATCH] Add 'inline-only option to org-export-babel-evaluate 2013-04-01 5:44 [PATCH] Add 'inline-only option to org-export-babel-evaluate Aaron Ecay @ 2013-04-01 7:45 ` Nicolas Goaziou 2013-04-01 15:10 ` Aaron Ecay 2013-04-02 22:14 ` Eric Schulte 1 sibling, 1 reply; 9+ messages in thread From: Nicolas Goaziou @ 2013-04-01 7:45 UTC (permalink / raw) To: Aaron Ecay; +Cc: emacs-orgmode Hello, Aaron Ecay <aaronecay@gmail.com> writes: > * 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 > > 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. I'll let Eric decide about the usefulness of this. > Inline blocks, however, must be evaluated during export, or they will > be simply deleted by the exporter. This sentence is wrong. Look, for example at `org-latex-inline-src-block'. The exporter doesn't delete anything, Babel does. Regards, -- Nicolas Goaziou ^ permalink raw reply [flat|nested] 9+ messages in thread
* Re: [PATCH] Add 'inline-only option to org-export-babel-evaluate 2013-04-01 7:45 ` Nicolas Goaziou @ 2013-04-01 15:10 ` Aaron Ecay 0 siblings, 0 replies; 9+ messages in thread From: Aaron Ecay @ 2013-04-01 15:10 UTC (permalink / raw) To: Nicolas Goaziou; +Cc: emacs-orgmode Hi Nicolas, 2013ko apirilak 1an, Nicolas Goaziou-ek idatzi zuen: > > This sentence is wrong. Look, for example at > `org-latex-inline-src-block'. The exporter doesn't delete anything, > Babel does. You’re right – I meant (and should have said) “the process of exporting” more broadly, not the exporter in particular. Sorry, -- Aaron Ecay ^ permalink raw reply [flat|nested] 9+ messages in thread
* Re: [PATCH] Add 'inline-only option to org-export-babel-evaluate 2013-04-01 5:44 [PATCH] Add 'inline-only option to org-export-babel-evaluate Aaron Ecay 2013-04-01 7:45 ` Nicolas Goaziou @ 2013-04-02 22:14 ` Eric Schulte 2013-04-18 8:24 ` Aaron Ecay 1 sibling, 1 reply; 9+ messages in thread From: Eric Schulte @ 2013-04-02 22:14 UTC (permalink / raw) To: Aaron Ecay; +Cc: emacs-orgmode I'm happy to apply this patch, however please also supply a patch which updates the corresponding documentation. Thanks! Aaron Ecay <aaronecay@gmail.com> writes: > * 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 > > 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. > --- > lisp/ob-exp.el | 11 ++++++++--- > 1 file changed, 8 insertions(+), 3 deletions(-) > > diff --git a/lisp/ob-exp.el b/lisp/ob-exp.el > index 0d98690..6783bd5 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) -- Eric Schulte http://cs.unm.edu/~eschulte ^ permalink raw reply [flat|nested] 9+ messages in thread
* Re: [PATCH] Add 'inline-only option to org-export-babel-evaluate 2013-04-02 22:14 ` Eric Schulte @ 2013-04-18 8:24 ` Aaron Ecay 2013-04-18 8:44 ` Bastien 0 siblings, 1 reply; 9+ messages in thread From: Aaron Ecay @ 2013-04-18 8:24 UTC (permalink / raw) To: Eric Schulte; +Cc: emacs-orgmode [-- Attachment #1: Type: text/plain, Size: 317 bytes --] 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. [-- Attachment #2: 0001-Add-inline-only-option-to-org-export-babel-evaluate.patch --] [-- Type: text/x-patch, Size: 3383 bytes --] From 62ea51f473d387137b5294705241795d1d8bc39b Mon Sep 17 00:00:00 2001 From: Aaron Ecay <aaronecay@gmail.com> 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 +@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 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 [-- Attachment #3: Type: text/plain, Size: 25 bytes --] Thanks, -- Aaron Ecay ^ permalink raw reply related [flat|nested] 9+ messages in thread
* Re: [PATCH] Add 'inline-only option to org-export-babel-evaluate 2013-04-18 8:24 ` Aaron Ecay @ 2013-04-18 8:44 ` Bastien 2013-04-18 9:19 ` Sebastien Vauban 0 siblings, 1 reply; 9+ messages in thread From: Bastien @ 2013-04-18 8:44 UTC (permalink / raw) To: Aaron Ecay; +Cc: emacs-orgmode, Eric Schulte Hi Aaron, I applied this patch, thanks a lot. Please see the small changes I made to the ChangeLog entry for next commit messages: http://orgmode.org/cgit.cgi/org-mode.git/commit/?id=25869e Sorry, I know this sounds nitpicking and perhaps pedantic, but the more careful we are about this upstream, the less pain it is for the one who merges Org into Emacs... Thanks! -- Bastien ^ permalink raw reply [flat|nested] 9+ messages in thread
* Re: [PATCH] Add 'inline-only option to org-export-babel-evaluate 2013-04-18 8:44 ` Bastien @ 2013-04-18 9:19 ` Sebastien Vauban 2013-04-18 9:42 ` Aaron Ecay 0 siblings, 1 reply; 9+ messages in thread From: Sebastien Vauban @ 2013-04-18 9:19 UTC (permalink / raw) To: emacs-orgmode-mXXj517/zsQ Hello, Bastien wrote: > I applied this patch, thanks a lot. Please see the small changes > I made to the ChangeLog entry for next commit messages: > > http://orgmode.org/cgit.cgi/org-mode.git/commit/?id=25869e How is that suppose to cooperate with ":eval never-export" (which avoids all the evaluations during export)? I'm not sure to understand why this change is implemented as a variable which we would have to set up in our .emacs or bind in the file, instead of an header argument which we could set wherever we want (system-wide, language-specific, buffer-wide, subtree-wide, or code block-specific)... Best regards, Seb -- Sebastien Vauban ^ permalink raw reply [flat|nested] 9+ messages in thread
* Re: [PATCH] Add 'inline-only option to org-export-babel-evaluate 2013-04-18 9:19 ` Sebastien Vauban @ 2013-04-18 9:42 ` Aaron Ecay 2013-04-18 10:19 ` Sebastien Vauban 0 siblings, 1 reply; 9+ messages in thread From: Aaron Ecay @ 2013-04-18 9:42 UTC (permalink / raw) To: Sebastien Vauban; +Cc: emacs-orgmode Hi Sebastien, 2013ko apirilak 18an, Sebastien Vauban-ek idatzi zuen: > > Hello, > > Bastien wrote: >> I applied this patch, thanks a lot. Please see the small changes >> I made to the ChangeLog entry for next commit messages: >> >> http://orgmode.org/cgit.cgi/org-mode.git/commit/?id=25869e > > How is that suppose to cooperate with ":eval never-export" (which avoids all > the evaluations during export)? I could be wrong, but I don’t seem to see a convenient way to set this header arg for both inline source blocks and #+call lines. These both have no way of storing their results in a buffer, so in order to have them be present in the export they must be evaluated every time. On the other hand, it is not always desirable to call code blocks on every export. They could be very time-consuming to compute. So, a way to pick out the non-results-storing blocks is needed. > > I'm not sure to understand why this change is implemented as a variable which > we would have to set up in our .emacs or bind in the file, instead of an > header argument which we could set wherever we want (system-wide, > language-specific, buffer-wide, subtree-wide, or code > block-specific)... What form would this take? Would we have a value of :eval which is never-export-unless-inline? -- Aaron Ecay ^ permalink raw reply [flat|nested] 9+ messages in thread
* Re: [PATCH] Add 'inline-only option to org-export-babel-evaluate 2013-04-18 9:42 ` Aaron Ecay @ 2013-04-18 10:19 ` Sebastien Vauban 0 siblings, 0 replies; 9+ messages in thread From: Sebastien Vauban @ 2013-04-18 10:19 UTC (permalink / raw) To: emacs-orgmode-mXXj517/zsQ Hi Aaron, Aaron Ecay wrote: > 2013ko apirilak 18an, Sebastien Vauban-ek idatzi zuen: >> Bastien wrote: >>> I applied this patch, thanks a lot. Please see the small changes >>> I made to the ChangeLog entry for next commit messages: >>> >>> http://orgmode.org/cgit.cgi/org-mode.git/commit/?id=25869e >> >> How is that suppose to cooperate with ":eval never-export" (which avoids all >> the evaluations during export)? > > I could be wrong, but I don’t seem to see a convenient way to set this > header arg for both inline source blocks and #+call lines. These both > have no way of storing their results in a buffer, so in order to have > them be present in the export they must be evaluated every time. > > On the other hand, it is not always desirable to call code blocks on > every export. They could be very time-consuming to compute. So, a way > to pick out the non-results-storing blocks is needed. > >> I'm not sure to understand why this change is implemented as a variable which >> we would have to set up in our .emacs or bind in the file, instead of an >> header argument which we could set wherever we want (system-wide, >> language-specific, buffer-wide, subtree-wide, or code >> block-specific)... > > What form would this take? Would we have a value of :eval which is > never-export-unless-inline? As we're talking of evaluation, and as there is already an ":eval" header argument (with lots of options), I think it'd better to try to add your requirement as a new option, yes, instead of having complex rules for knowing what happens depending on every option of ":eval" times 2 (with or without your new value). I'm not sure what ":eval never-export" currently does with inline blocks, but (depending on that) I'd rather add the new value "never-export-except-inline" (or "never-export-nor-inline"). Note -- The option names are not correct, just to carry what I mean... That way, you can impose your new behavior wherever you want, as well in parts of your Org document. Best regards, Seb -- Sebastien Vauban ^ permalink raw reply [flat|nested] 9+ messages in thread
end of thread, other threads:[~2013-04-18 10:19 UTC | newest] Thread overview: 9+ messages (download: mbox.gz follow: Atom feed -- links below jump to the message on this page -- 2013-04-01 5:44 [PATCH] Add 'inline-only option to org-export-babel-evaluate Aaron Ecay 2013-04-01 7:45 ` Nicolas Goaziou 2013-04-01 15:10 ` Aaron Ecay 2013-04-02 22:14 ` Eric Schulte 2013-04-18 8:24 ` Aaron Ecay 2013-04-18 8:44 ` Bastien 2013-04-18 9:19 ` Sebastien Vauban 2013-04-18 9:42 ` Aaron Ecay 2013-04-18 10:19 ` Sebastien Vauban
Code repositories for project(s) associated with this public inbox https://git.savannah.gnu.org/cgit/emacs/org-mode.git This is a public inbox, see mirroring instructions for how to clone and mirror all data and code used for this inbox; as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).