emacs-orgmode@gnu.org archives
 help / color / mirror / code / Atom feed
* Don't ask, don't run
@ 2011-07-08 19:19 Ken.Williams
  2011-07-08 20:14 ` Eric S Fraga
  0 siblings, 1 reply; 5+ messages in thread
From: Ken.Williams @ 2011-07-08 19:19 UTC (permalink / raw)
  To: emacs-orgmode

Hi,

I know from the manual that I can set 'org-confirm-babel-evaluate' to t,
or nil, or a function, to control whether I'm asked permission to run a
code block.

However, that only gives me two choices - ask the user, or pretend the
user said "yes".  Sometimes I'd like to pretend the user said "no",
without asking.

Specifically, I'd like to always manually control when code blocks are
executed.  When exporting, I don't want them executed (and I don't want to
be asked about my dozens of blocks each time).  When hitting C-c C-c
manually, I just want it to run (and I don't want to be asked whether I'm
sure).

Is there a similar variable, or perhaps an export option, that will give
me this kind of workflow?

Thanks.

--
Ken Williams
Senior Research Scientist
Thomson Reuters
http://labs.thomsonreuters.com

^ permalink raw reply	[flat|nested] 5+ messages in thread

* Re: Don't ask, don't run
  2011-07-08 19:19 Don't ask, don't run Ken.Williams
@ 2011-07-08 20:14 ` Eric S Fraga
  2011-07-10 15:08   ` Eric Schulte
  0 siblings, 1 reply; 5+ messages in thread
From: Eric S Fraga @ 2011-07-08 20:14 UTC (permalink / raw)
  To: emacs-orgmode

<Ken.Williams@thomsonreuters.com> writes:

> Hi,
>
> I know from the manual that I can set 'org-confirm-babel-evaluate' to t,
> or nil, or a function, to control whether I'm asked permission to run a
> code block.
>
> However, that only gives me two choices - ask the user, or pretend the
> user said "yes".  Sometimes I'd like to pretend the user said "no",
> without asking.
>
> Specifically, I'd like to always manually control when code blocks are
> executed.  When exporting, I don't want them executed (and I don't want to
> be asked about my dozens of blocks each time).  When hitting C-c C-c
> manually, I just want it to run (and I don't want to be asked whether I'm
> sure).
>
> Is there a similar variable, or perhaps an export option, that will give
> me this kind of workflow?
>
> Thanks.

I can't help you directly although I also often want the behaviour you
are describing.  One workaround that should give you what you want is to
enable evaluation without prompting (org-confirm-babel-evaluate: nil)
and to have the results from runs cached so that, when exporting, the
source code blocks shouldn't have to execute; see [[info:org#cache]].

-- 
: Eric S Fraga (GnuPG: 0xC89193D8FFFCF67D) in Emacs 24.0.50.1
: using Org-mode version 7.6 (release_7.6.4.gf305a)

^ permalink raw reply	[flat|nested] 5+ messages in thread

* Re: Don't ask, don't run
  2011-07-08 20:14 ` Eric S Fraga
@ 2011-07-10 15:08   ` Eric Schulte
  2011-07-11 15:19     ` Ken Williams
  0 siblings, 1 reply; 5+ messages in thread
From: Eric Schulte @ 2011-07-10 15:08 UTC (permalink / raw)
  To: emacs-orgmode

Eric S Fraga <e.fraga@ucl.ac.uk> writes:

> <Ken.Williams@thomsonreuters.com> writes:
>
>> Hi,
>>
>> I know from the manual that I can set 'org-confirm-babel-evaluate' to t,
>> or nil, or a function, to control whether I'm asked permission to run a
>> code block.
>>
>> However, that only gives me two choices - ask the user, or pretend the
>> user said "yes".  Sometimes I'd like to pretend the user said "no",
>> without asking.
>>
>> Specifically, I'd like to always manually control when code blocks are
>> executed.  When exporting, I don't want them executed (and I don't want to
>> be asked about my dozens of blocks each time).  When hitting C-c C-c
>> manually, I just want it to run (and I don't want to be asked whether I'm
>> sure).
>>
>> Is there a similar variable, or perhaps an export option, that will give
>> me this kind of workflow?
>>
>> Thanks.
>
> I can't help you directly although I also often want the behaviour you
> are describing.  One workaround that should give you what you want is to
> enable evaluation without prompting (org-confirm-babel-evaluate: nil)
> and to have the results from runs cached so that, when exporting, the
> source code blocks shouldn't have to execute; see [[info:org#cache]].

There is no way to customize `org-confirm-evaluate' to achieve this
behavior, however it can be accomplished through creative use of the
:eval header argument, by using the `org-export-current-backend'
variable to inhibit evaluation during export.

#+begin_src emacs-lisp :eval (if org-export-current-backend "never" "yes") :exports results
  (message "launch missles")
#+end_src

Best -- Eric

-- 
Eric Schulte
http://cs.unm.edu/~eschulte/

^ permalink raw reply	[flat|nested] 5+ messages in thread

* Re: Don't ask, don't run
  2011-07-10 15:08   ` Eric Schulte
@ 2011-07-11 15:19     ` Ken Williams
  2011-07-11 17:51       ` Eric Schulte
  0 siblings, 1 reply; 5+ messages in thread
From: Ken Williams @ 2011-07-11 15:19 UTC (permalink / raw)
  To: emacs-orgmode

Eric Schulte <schulte.eric <at> gmail.com> writes:

> There is no way to customize `org-confirm-evaluate' to achieve this
> behavior, however it can be accomplished through creative use of the
> :eval header argument, by using the `org-export-current-backend'
> variable to inhibit evaluation during export.
> 
> #+begin_src emacs-lisp :eval (if org-export-current-backend "never"
>  "yes") :exports results
>   (message "launch missles")
> #+end_src

I see, thanks.  Since I'm new to this, can I confirm my understanding 
here?  It tests whether the 'org-export-current-backend' variable is
set, which means we're currently exporting, and if so, we set the 
:eval argument to "never".  Otherwise we set it to "yes", which means
evaluate it without asking.

Assuming that understanding is correct, I have a couple of followup
questions.

1) http://orgmode.org/manual/eval.html doesn't list the "yes" option, 

2) Is there a similar variable I might test to check whether it's currently
doing an explicit C-c C-c action?  If there were, I might prefer 
something like :eval (if org-export-current-backend "never" (if 
org-doing-c-c-c-c "yes" "query")), so that I cover some other
scenario besides export or C-c C-c.

3) Finally, is there a way to add this argument fanciness implicitly
to *all* the source blocks in my file?  Or will it have to go on 
all of them?

Thanks much.

 -Ken

^ permalink raw reply	[flat|nested] 5+ messages in thread

* Re: Don't ask, don't run
  2011-07-11 15:19     ` Ken Williams
@ 2011-07-11 17:51       ` Eric Schulte
  0 siblings, 0 replies; 5+ messages in thread
From: Eric Schulte @ 2011-07-11 17:51 UTC (permalink / raw)
  To: Ken Williams; +Cc: emacs-orgmode

Ken Williams <ken.williams@thomsonreuters.com> writes:

> Eric Schulte <schulte.eric <at> gmail.com> writes:
>
>> There is no way to customize `org-confirm-evaluate' to achieve this
>> behavior, however it can be accomplished through creative use of the
>> :eval header argument, by using the `org-export-current-backend'
>> variable to inhibit evaluation during export.
>> 
>> #+begin_src emacs-lisp :eval (if org-export-current-backend "never"
>>  "yes") :exports results
>>   (message "launch missles")
>> #+end_src
>
> I see, thanks.  Since I'm new to this, can I confirm my understanding 
> here?  It tests whether the 'org-export-current-backend' variable is
> set, which means we're currently exporting, and if so, we set the 
> :eval argument to "never".  Otherwise we set it to "yes", which means
> evaluate it without asking.
>
> Assuming that understanding is correct, I have a couple of followup
> questions.
>
> 1) http://orgmode.org/manual/eval.html doesn't list the "yes" option, 
>

OK, I've just updated this documentation.  There actually is no "yes"
option, a more clear version of my snippet above would have set :eval to
nil when not in export.  Any value of :eval which is no "never" or "no"
will result in the default behavior as determined by
org-confirm-babel-evaluate.

>
> 2) Is there a similar variable I might test to check whether it's currently
> doing an explicit C-c C-c action?  If there were, I might prefer 
> something like :eval (if org-export-current-backend "never" (if 
> org-doing-c-c-c-c "yes" "query")), so that I cover some other
> scenario besides export or C-c C-c.
>

hmm, I'm not sure... you could try `called-interactively-p' e.g.,

  (if (called-interactively-p 'interactive) "yes" "query")

>
> 3) Finally, is there a way to add this argument fanciness implicitly
> to *all* the source blocks in my file?  Or will it have to go on 
> all of them?
>

Yes, place it in a #+Babel: line at the top of the file, see
http://orgmode.org/manual/Using-header-arguments.html

Best -- Eric

>
> Thanks much.
>
>  -Ken
>
>

-- 
Eric Schulte
http://cs.unm.edu/~eschulte/

^ permalink raw reply	[flat|nested] 5+ messages in thread

end of thread, other threads:[~2011-07-11 17:51 UTC | newest]

Thread overview: 5+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2011-07-08 19:19 Don't ask, don't run Ken.Williams
2011-07-08 20:14 ` Eric S Fraga
2011-07-10 15:08   ` Eric Schulte
2011-07-11 15:19     ` Ken Williams
2011-07-11 17:51       ` Eric Schulte

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).