all messages for Emacs-related lists mirrored at yhetil.org
 help / color / mirror / code / Atom feed
* How to override ":eval no" in call lines?
@ 2015-01-15 14:55 Sebastien Vauban
  2015-01-22  8:28 ` Sebastien Vauban
  0 siblings, 1 reply; 7+ messages in thread
From: Sebastien Vauban @ 2015-01-15 14:55 UTC (permalink / raw)
  To: emacs-orgmode-mXXj517/zsQ

Hello,

In a long document, I must have ":eval no" at file level, as this is the
common setting for most code blocks. However, how do I unset that for
some call lines.

Export this ECM (to HTML, for example) and see for yourself that it does
not seem evident...

--8<---------------cut here---------------start------------->8---
#+TITLE:     ECM to be exported

#+PROPERTY:  eval no
#+PROPERTY:  results none

* Results
  :PROPERTIES:
  :exports:  results
  :results:  replace
  :END:

** Square

Here nothing gets executed: neither the code block, nor the call lines...

#+name: square
#+begin_src emacs-lisp :tangle no :var x=1
(* x x)
#+end_src

2 x 2 = call_square(x=2).

3 x 3 = call_square[:eval yes](x=3).

** Plus

Here, ":eval yes" (or even ":eval foo" FWIW) allows the code block to get
executed at export:

#+name: plus
#+begin_src emacs-lisp :tangle no :var x=4 :eval foo
(+ x x)
#+end_src

But none of the call lines gets executed...

5 + 5 = call_plus(x=5).

6 + 6 = call_plus[:eval yes](x=6).

So, how do I override the ":eval no" specified at the file level?
--8<---------------cut here---------------end--------------->8---

Any idea?

Best regards,
  Seb

-- 
Sebastien Vauban

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

* Re: How to override ":eval no" in call lines?
  2015-01-15 14:55 How to override ":eval no" in call lines? Sebastien Vauban
@ 2015-01-22  8:28 ` Sebastien Vauban
  2015-01-22 16:50   ` Charles C. Berry
  0 siblings, 1 reply; 7+ messages in thread
From: Sebastien Vauban @ 2015-01-22  8:28 UTC (permalink / raw)
  To: emacs-orgmode-mXXj517/zsQ

Hello,

May I bump up this thread?

Sebastien Vauban wrote:
> In a long document, I must have ":eval no" at file level, as this is the
> common setting for most code blocks. However, how do I unset that for
> some call lines.
>
> Export this ECM (to HTML, for example) and see for yourself that it does
> not seem evident...
>
> #+TITLE:     ECM to be exported
>
> #+PROPERTY:  eval no
> #+PROPERTY:  results none
>
> * Results
>   :PROPERTIES:
>   :exports:  results
>   :results:  replace
>   :END:
>
> ** Square
>
> Here nothing gets executed: neither the code block, nor the call lines...
>
> #+name: square
> #+begin_src emacs-lisp :tangle no :var x=1
> (* x x)
> #+end_src
>
> 2 x 2 = call_square(x=2).
>
> 3 x 3 = call_square[:eval yes](x=3).
>
> ** Plus
>
> Here, ":eval yes" (or even ":eval foo" FWIW) allows the code block to get
> executed at export:
>
> #+name: plus
> #+begin_src emacs-lisp :tangle no :var x=4 :eval foo
> (+ x x)
> #+end_src
>
> But none of the call lines gets executed...
>
> 5 + 5 = call_plus(x=5).
>
> 6 + 6 = call_plus[:eval yes](x=6).
>
> So, how do I override the ":eval no" specified at the file level?
>
> Any idea?

Best regards,
  Seb

-- 
Sebastien Vauban

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

* Re: How to override ":eval no" in call lines?
  2015-01-22  8:28 ` Sebastien Vauban
@ 2015-01-22 16:50   ` Charles C. Berry
  2015-01-23 11:44     ` Sebastien Vauban
  0 siblings, 1 reply; 7+ messages in thread
From: Charles C. Berry @ 2015-01-22 16:50 UTC (permalink / raw)
  To: Sebastien Vauban; +Cc: emacs-orgmode

On Thu, 22 Jan 2015, Sebastien Vauban wrote:

> Hello,
>
> May I bump up this thread?
>
> Sebastien Vauban wrote:
>> In a long document, I must have ":eval no" at file level, as this is the
>> common setting for most code blocks. However, how do I unset that for
>> some call lines.

See (info "(org) Evaluating code blocks")

Note what it says about 'inside' and 'outside' header arguments. You need 
*both* set to `:eval yes'.

The inside arg will allow execution of `plus' while the `outside' will 
allow execution of call_plus(...).

Try this:

6 + 6 = call_plus[:eval yes](x=6)[:eval yes].


HTH,

Chuck

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

* Re: How to override ":eval no" in call lines?
  2015-01-22 16:50   ` Charles C. Berry
@ 2015-01-23 11:44     ` Sebastien Vauban
  2015-01-23 19:53       ` Charles C. Berry
  0 siblings, 1 reply; 7+ messages in thread
From: Sebastien Vauban @ 2015-01-23 11:44 UTC (permalink / raw)
  To: emacs-orgmode-mXXj517/zsQ

"Charles C. Berry" wrote:
> Sebastien Vauban wrote:
>> In a long document, I must have ":eval no" at file level, as this is
>> the common setting for most code blocks. However, how do I unset that
>> for some call lines.
>
> See (info "(org) Evaluating code blocks")
>
> Note what it says about 'inside' and 'outside' header arguments. You
> need *both* set to `:eval yes'.
>
> The inside arg will allow execution of `plus' while the `outside' will
> allow execution of call_plus(...).
>
> Try this:
>
> 6 + 6 = call_plus[:eval yes](x=6)[:eval yes].

That works, thanks!

However, I really have trouble understanding what are inside and outside
header arguments for.  I still don't get it properly.

Summarizing the above doc:

- "inside" header arguments are applied to the *evaluation of the code
  block*.  They /affect how the code block is evaluated/.

- "end" header arguments do not affect evaluation of the named code
  block; instead, they /affect how the results are incorporated/ into
  the Org mode buffer.

I don't get why one has to add ":eval yes" for both types of headers
arguments.

Moreover, I once read that when evaluating a call line, it is converted
into an ephemeral Emacs Lisp code block equivalent to the call line (and
created at the point of the call line):

  #+begin_src emacs-lisp :var result=<NAME>(<ARGUMENTS>) <INSIDE-HEADER-ARGS>
    result
  #+end_src

which is evaluated in place.

Where do <END-HEADER-ARGS> fit into that picture?

Best regards,
  Seb

-- 
Sebastien Vauban

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

* Re: How to override ":eval no" in call lines?
  2015-01-23 11:44     ` Sebastien Vauban
@ 2015-01-23 19:53       ` Charles C. Berry
       [not found]         ` <alpine.OSX.2.00.1501231149060.528-iDQ3frm8jJiryYnjg5slPZa4wMfmKMrbhPhL2mjWHbk@public.gmane.org>
  0 siblings, 1 reply; 7+ messages in thread
From: Charles C. Berry @ 2015-01-23 19:53 UTC (permalink / raw)
  To: Sebastien Vauban; +Cc: Org-Mode mailing list

On Fri, 23 Jan 2015, Sebastien Vauban wrote:

> "Charles C. Berry" wrote:
>> Sebastien Vauban wrote:
>>> In a long document, I must have ":eval no" at file level, as this is
>>> the common setting for most code blocks. However, how do I unset that
>>> for some call lines.
>>
[snip]
>
> I don't get why one has to add ":eval yes" for both types of headers
> arguments.
>
> Moreover, I once read that when evaluating a call line, it is converted
> into an ephemeral Emacs Lisp code block equivalent to the call line (and
> created at the point of the call line):
>
>  #+begin_src emacs-lisp :var result=<NAME>(<ARGUMENTS>) <INSIDE-HEADER-ARGS>
>    result
>  #+end_src
>
> which is evaluated in place.
>

No, like this:

#+begin_src emacs-lisp :var result=<NAME>[<INSIDE-HEADER-ARGS>](<ARGUMENTS>)


> Where do <END-HEADER-ARGS> fit into that picture?

Either before or after the :var ...

HTH,

Chuck

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

* Re: How to override ":eval no" in call lines?
       [not found]         ` <alpine.OSX.2.00.1501231149060.528-iDQ3frm8jJiryYnjg5slPZa4wMfmKMrbhPhL2mjWHbk@public.gmane.org>
@ 2015-02-09 14:43           ` Sebastien Vauban
  2015-02-09 17:54             ` Charles C. Berry
  0 siblings, 1 reply; 7+ messages in thread
From: Sebastien Vauban @ 2015-02-09 14:43 UTC (permalink / raw)
  To: Charles C. Berry; +Cc: Org-Mode mailing list

"Charles C. Berry" wrote:
> On Fri, 23 Jan 2015, Sebastien Vauban wrote:
>> "Charles C. Berry" wrote:
>>> Sebastien Vauban wrote:
>>>> In a long document, I must have ":eval no" at file level, as this
>>>> is the common setting for most code blocks. However, how do I unset
>>>> that for some call lines.
>>
>> I don't get why one has to add ":eval yes" for both types of headers
>> arguments.

I still don't get that: why do I need to add *twice* ":eval yes", in
both the "inside header args" and the "end header args"?

The documentation [1] states:

  ┌────
  │ END HEADER ARGUMENTS are applied to the calling instance and DO NOT
  │ AFFECT EVALUATION OF THE NAMED CODE BLOCK. They affect how the
  │ results are incorporated into the Org mode buffer and how the call
  │ line is exported.
  └────

If end header args don't affect the evaluation of the name code block,
why do we have to set ":eval" to "yes", then?

>> Moreover, I once read that when evaluating a call line, it is
>> converted into an ephemeral Emacs Lisp code block equivalent to the
>> call line (and created at the point of the call line):
>>
>>  #+begin_src emacs-lisp :var result=<NAME>(<ARGUMENTS>) <INSIDE-HEADER-ARGS>
>>    result
>>  #+end_src
>>
>> which is evaluated in place.
>
> No, like this:
>
> #+begin_src emacs-lisp :var result=<NAME>[<INSIDE-HEADER-ARGS>](<ARGUMENTS>)
                                     ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^

What's that syntax?  The one described for "header arguments in function
calls"?  Aren't we recursive here: describing syntax equivalent to
a call via the ephemeral code block, reusing syntax for a call?

>> Where do <END-HEADER-ARGS> fit into that picture?
>
> Either before or after the :var ...
>
> HTH,

Not completely yet, no.

Best regards,
  Seb

[1] http://orgmode.org/manual/Evaluating-code-blocks.html#Evaluating-code-blocks

-- 
Sebastien Vauban

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

* Re: How to override ":eval no" in call lines?
  2015-02-09 14:43           ` Sebastien Vauban
@ 2015-02-09 17:54             ` Charles C. Berry
  0 siblings, 0 replies; 7+ messages in thread
From: Charles C. Berry @ 2015-02-09 17:54 UTC (permalink / raw)
  To: Sebastien Vauban; +Cc: Org-Mode mailing list

[-- Attachment #1: Type: TEXT/PLAIN, Size: 3387 bytes --]

On Mon, 9 Feb 2015, Sebastien Vauban wrote:

> "Charles C. Berry" wrote:
>> On Fri, 23 Jan 2015, Sebastien Vauban wrote:
>>> "Charles C. Berry" wrote:
>>>> Sebastien Vauban wrote:
>>>>> In a long document, I must have ":eval no" at file level, as this
>>>>> is the common setting for most code blocks. However, how do I unset
>>>>> that for some call lines.
>>>
>>> I don't get why one has to add ":eval yes" for both types of headers
>>> arguments.
>
> I still don't get that: why do I need to add *twice* ":eval yes", in
> both the "inside header args" and the "end header args"?
>
> The documentation [1] states:
>
>  ┌────
>  │ END HEADER ARGUMENTS are applied to the calling instance and DO NOT
>  │ AFFECT EVALUATION OF THE NAMED CODE BLOCK. They affect how the
>  │ results are incorporated into the Org mode buffer and how the call
>  │ line is exported.
>  └────
>
> If end header args don't affect the evaluation of the name code block,
> why do we have to set ":eval" to "yes", then?
>

Because there are two evaluations to be made of a call_abc() instance or a
`#BEGIN_SRC lang :var x=abc() ...' instance:

1. one of abc()

2. one of the instance.

They can be made in any of the four combinations of `:eval yes' and `:eval 
no'. See below for an example of a src block calling another using the 
`:var x=abc()' idiom.


>>> Moreover, I once read that when evaluating a call line, it is
>>> converted into an ephemeral Emacs Lisp code block equivalent to the
>>> call line (and created at the point of the call line):
>>>
>>>  #+begin_src emacs-lisp :var result=<NAME>(<ARGUMENTS>) <INSIDE-HEADER-ARGS>
>>>    result
>>>  #+end_src
>>>
>>> which is evaluated in place.
>>
>> No, like this:
>>
>> #+begin_src emacs-lisp :var result=<NAME>[<INSIDE-HEADER-ARGS>](<ARGUMENTS>)
>                                     ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
>
> What's that syntax?  The one described for "header arguments in function
> calls"?  Aren't we recursive here: describing syntax equivalent to
> a call via the ephemeral code block, reusing syntax for a call?
>

Not sure how best to answer. Maybe try out all combos to demo what
happens:

A simple src block:

#+NAME: up
#+BEGIN_SRC emacs-lisp :var x="CbA" 
(upcase x)
#+END_SRC


Eval this src block and `up' - prompted twice for evalution upon
execution.  Note RESULTS == 'C B A':

#+BEGIN_SRC emacs-lisp :eval yes :var x=up[:eval yes](x="c b a") 
x
#+END_SRC

#+RESULTS:
: C B A

Do not eval this src block but eval `up' - prompted to evaluate `up'
and message that evaluation is disabled appears for current src
block. No RESULTS:

#+BEGIN_SRC emacs-lisp :eval no :var x=up[:eval yes](x="c b a") 
x
#+END_SRC


Eval this src block and not `up' - prompted once for evaluation.  Note
RESULTS == 'nil', as x did not get a value assigned to it:


#+BEGIN_SRC emacs-lisp :eval yes :var x=up[:eval no](x="c b a") 
x
#+END_SRC

#+RESULTS:
: nil

Eval neither. No prompts. No result.

#+BEGIN_SRC emacs-lisp :eval no :var x=up[:eval no](x="c b a") 
x
#+END_SRC


>>> Where do <END-HEADER-ARGS> fit into that picture?
>>
>> Either before or after the :var ...
>>

Maybe better to say:

In this context the equivalent of <END-HEADER-ARGS> is the `:eval'
header for the src block, which can go anywhere on the line. The
<END-HEADER-ARGS> if supplied in this context seem to be ignored.

HTH,

Chuck

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

end of thread, other threads:[~2015-02-09 17:54 UTC | newest]

Thread overview: 7+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2015-01-15 14:55 How to override ":eval no" in call lines? Sebastien Vauban
2015-01-22  8:28 ` Sebastien Vauban
2015-01-22 16:50   ` Charles C. Berry
2015-01-23 11:44     ` Sebastien Vauban
2015-01-23 19:53       ` Charles C. Berry
     [not found]         ` <alpine.OSX.2.00.1501231149060.528-iDQ3frm8jJiryYnjg5slPZa4wMfmKMrbhPhL2mjWHbk@public.gmane.org>
2015-02-09 14:43           ` Sebastien Vauban
2015-02-09 17:54             ` Charles C. Berry

Code repositories for project(s) associated with this external index

	https://git.savannah.gnu.org/cgit/emacs.git
	https://git.savannah.gnu.org/cgit/emacs/org-mode.git

This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.