emacs-orgmode@gnu.org archives
 help / color / mirror / code / Atom feed
* including the result of a block in several places?
@ 2012-12-07 16:16 Alan Schmitt
  2012-12-07 18:26 ` Sebastien Vauban
  0 siblings, 1 reply; 12+ messages in thread
From: Alan Schmitt @ 2012-12-07 16:16 UTC (permalink / raw)
  To: emacs-orgmode

Hello,

I tried including the result of evaluation a block in several slides,
but the second time it was not included. Here is the code I ran:

#+begin_src org
** Prototype-based objects

#+name: object_example
#+begin_src js :results code output :exports both
var f = function(a) {
	this.x = a
}

f.prototype = {y : 1}

var o = new f (42)

console.log("o.x = " + o.x + ", o.y = " + o.y)
#+end_src

Results

#+results: object_example

** Prototype-based objects

#+begin_src js
var f = function(a) {
	this.x = a
}

f.prototype = {y : 1}

var o = new f (42)

console.log("o.x = " + o.x + ", o.y = " + o.y)
#+end_src

Results

#+results: object_example

(Some additional images added)
#+end_src

I cannot do a "\pause" because a slide will be inserted in the middle.

Is it possible to have the results of the evaluation of a block in
several places?

Thanks,

Alan

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

* Re: including the result of a block in several places?
  2012-12-07 16:16 including the result of a block in several places? Alan Schmitt
@ 2012-12-07 18:26 ` Sebastien Vauban
  2012-12-08 10:13   ` Alan Schmitt
  0 siblings, 1 reply; 12+ messages in thread
From: Sebastien Vauban @ 2012-12-07 18:26 UTC (permalink / raw)
  To: emacs-orgmode-mXXj517/zsQ

Hi Alan,

Alan Schmitt wrote:
> I tried including the result of evaluation a block in several slides,
> but the second time it was not included.
>
> Is it possible to have the results of the evaluation of a block in
> several places?

OOTB, I don't think so. However, you could have a code block which simply
copies the results.

See `echo' in the `library-of-babel.org'.

Best regards,
Seb

-- 
Sebastien Vauban

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

* Re: including the result of a block in several places?
  2012-12-07 18:26 ` Sebastien Vauban
@ 2012-12-08 10:13   ` Alan Schmitt
  2012-12-08 16:57     ` Thomas S. Dye
  0 siblings, 1 reply; 12+ messages in thread
From: Alan Schmitt @ 2012-12-08 10:13 UTC (permalink / raw)
  To: emacs-orgmode

"Sebastien Vauban" <wxhgmqzgwmuf@spammotel.com> writes:

> Hi Alan,
>
> Alan Schmitt wrote:
>> I tried including the result of evaluation a block in several slides,
>> but the second time it was not included.
>>
>> Is it possible to have the results of the evaluation of a block in
>> several places?
>
> OOTB, I don't think so. However, you could have a code block which simply
> copies the results.
>
> See `echo' in the `library-of-babel.org'.

Nice suggestion, thanks a lot. According to the documentation, I can
"call" functions from the library of babel from anywhere, but when I try
this:

#+begin_src org
#+name: test
#+begin_src perl
   for (my $i = 0; $i != 10; ++i) {
        print "hello, world!\n";
   }
#+end_src

#+call: echo(test)
#+end_src

I get a "org-babel-ref-resolve: Reference 'echo' not found in this
buffer".

Do I need to do something special to load the library?

Alan

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

* Re: including the result of a block in several places?
  2012-12-08 10:13   ` Alan Schmitt
@ 2012-12-08 16:57     ` Thomas S. Dye
  2012-12-10  8:57       ` Alan Schmitt
  0 siblings, 1 reply; 12+ messages in thread
From: Thomas S. Dye @ 2012-12-08 16:57 UTC (permalink / raw)
  To: Alan Schmitt; +Cc: emacs-orgmode

Aloha Alan,

Alan Schmitt <alan.schmitt@polytechnique.org> writes:

> "Sebastien Vauban" <wxhgmqzgwmuf@spammotel.com> writes:
>
>> Hi Alan,
>>
>> Alan Schmitt wrote:
>>> I tried including the result of evaluation a block in several slides,
>>> but the second time it was not included.
>>>
>>> Is it possible to have the results of the evaluation of a block in
>>> several places?
>>
>> OOTB, I don't think so. However, you could have a code block which simply
>> copies the results.
>>
>> See `echo' in the `library-of-babel.org'.
>
> Nice suggestion, thanks a lot. According to the documentation, I can
> "call" functions from the library of babel from anywhere, but when I try
> this:
>
> #+begin_src org
> #+name: test
> #+begin_src perl
>    for (my $i = 0; $i != 10; ++i) {
>         print "hello, world!\n";
>    }
> #+end_src
> #+call: echo(test)
> #+end_src
>
> I get a "org-babel-ref-resolve: Reference 'echo' not found in this
> buffer".
>
> Do I need to do something special to load the library?

I've had these in my .emacs for quite a while and they seem to work:

** ON Load Standard Library of Babel
#+begin_src emacs-lisp :tangle yes
  (org-babel-lob-ingest "~/.emacs.d/src/org-mode/contrib/babel/library-of-babel.org")
#+end_src

** ON Load Local Library of Babel
#+begin_src emacs-lisp :tangle yes
  (org-babel-lob-ingest "~/org/td-lob.org")
#+end_src

hth,
Tom

-- 
Thomas S. Dye
http://www.tsdye.com

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

* Re: including the result of a block in several places?
  2012-12-08 16:57     ` Thomas S. Dye
@ 2012-12-10  8:57       ` Alan Schmitt
  2012-12-10  9:57         ` Sebastien Vauban
  0 siblings, 1 reply; 12+ messages in thread
From: Alan Schmitt @ 2012-12-10  8:57 UTC (permalink / raw)
  To: Thomas S. Dye; +Cc: emacs-orgmode

tsd@tsdye.com (Thomas S. Dye) writes:

> I've had these in my .emacs for quite a while and they seem to work:
>
> ** ON Load Standard Library of Babel
> #+begin_src emacs-lisp :tangle yes
>   (org-babel-lob-ingest "~/.emacs.d/src/org-mode/contrib/babel/library-of-babel.org")
> #+end_src

Thanks a lot, I'm now able to call the "echo" function.

Unfortunately it does not exactly do what I want (but I was not really
clear about what I wanted first). Here is the code I have (don't worry
about the code inside the blocks, the idea is that I want a source block
and its results on two different slides, without having to duplicate
them):

#+begin_src org
** Prototype-based objects

#+name: object_example
#+begin_src js :results code output :exports both
var f = function(a) {
	this.x = a
}

f.prototype = {y : 1}

var o = new f (42)

console.log("o.x = " + o.x + ", o.y = " + o.y)
#+end_src

Results

#+results: object_example

** Prototypes resolution

#+BEGIN_SRC coq
Inductive proto : heap -> field -> loc -> loc -> Prop :=
  | proto_null : forall h f,
      proto h f loc_null loc_null
  | proto_here : forall h l f,
      indom h l f ->
      proto h f l l
  | proto_next : forall h l f l' l'',
      ~ indom h l f ->
      binds h l field_proto l' ->
      proto h f l' l'' ->
      proto h f l l''.
#+END_SRC

** Prototype-based objects

#+call: echo(object_example) :results code output :exports both
#+end_src

My problem is twofold.
- The code from "object_example" is not repeated. I guess that here what
I want is to be able to export a source code block in several places. Is
it possible?
- The highlighting of the results in the "#+call:" line is not in
javascript syntax, and I don't know how to tell the call that the result
will be javascript.

Thanks again,

Alan

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

* Re: including the result of a block in several places?
  2012-12-10  8:57       ` Alan Schmitt
@ 2012-12-10  9:57         ` Sebastien Vauban
  2012-12-10 10:17           ` Alan Schmitt
  0 siblings, 1 reply; 12+ messages in thread
From: Sebastien Vauban @ 2012-12-10  9:57 UTC (permalink / raw)
  To: emacs-orgmode-mXXj517/zsQ

Alan Schmitt,

Alan Schmitt wrote:
> tsd-P0awH739Ni4AvxtiuMwx3w@public.gmane.org (Thomas S. Dye) writes:
>
>> I've had these in my .emacs for quite a while and they seem to work:
>>
>> ** ON Load Standard Library of Babel
>> #+begin_src emacs-lisp :tangle yes
>>   (org-babel-lob-ingest "~/.emacs.d/src/org-mode/contrib/babel/library-of-babel.org")
>> #+end_src
>
> Thanks a lot, I'm now able to call the "echo" function.
>
> Unfortunately it does not exactly do what I want (but I was not really
> clear about what I wanted first). Here is the code I have (don't worry
> about the code inside the blocks, the idea is that I want a source block
> and its results on two different slides, without having to duplicate
> them):
>
> #+begin_src org
> ** Prototype-based objects
>
> #+name: object_example
> #+begin_src js :results code output :exports both
> var f = function(a) {
> 	this.x = a
> }
>
> f.prototype = {y : 1}
>
> var o = new f (42)
>
> console.log("o.x = " + o.x + ", o.y = " + o.y)
> #+end_src
>
> Results
>
> #+results: object_example
>
> ** Prototypes resolution
>
> #+BEGIN_SRC coq
> Inductive proto : heap -> field -> loc -> loc -> Prop :=
>   | proto_null : forall h f,
>       proto h f loc_null loc_null
>   | proto_here : forall h l f,
>       indom h l f ->
>       proto h f l l
>   | proto_next : forall h l f l' l'',
>       ~ indom h l f ->
>       binds h l field_proto l' ->
>       proto h f l' l'' ->
>       proto h f l l''.
> #+END_SRC
>
> ** Prototype-based objects
>
> #+call: echo(object_example) :results code output :exports both
> #+end_src
>
> My problem is twofold.
> - The code from "object_example" is not repeated. I guess that here what
> I want is to be able to export a source code block in several places. Is
> it possible?
> - The highlighting of the results in the "#+call:" line is not in
> javascript syntax, and I don't know how to tell the call that the result
> will be javascript.

In a hurry, to repeat the code:

- use named blocks
- use Noweb expansion

That is:

#+name: mycode
#+begin_src coq
...
#+end_src

Inserted a first time here:

#+begin_src coq :noweb yes
<<mycode>>
#+end_src

and another one here:

#+begin_src coq :noweb yes
<<mycode>>
#+end_src

Best regards,
  Seb

-- 
Sebastien Vauban

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

* Re: including the result of a block in several places?
  2012-12-10  9:57         ` Sebastien Vauban
@ 2012-12-10 10:17           ` Alan Schmitt
  2012-12-10 14:58             ` Eric Schulte
  0 siblings, 1 reply; 12+ messages in thread
From: Alan Schmitt @ 2012-12-10 10:17 UTC (permalink / raw)
  To: Sebastien Vauban; +Cc: emacs-orgmode

"Sebastien Vauban" <wxhgmqzgwmuf@spammotel.com> writes:

> In a hurry, to repeat the code:
>
> - use named blocks
> - use Noweb expansion
>
> That is:
>
> #+name: mycode
> #+begin_src coq
> ...
> #+end_src
>
> Inserted a first time here:
>
> #+begin_src coq :noweb yes
> <<mycode>>
> #+end_src
>
> and another one here:
>
> #+begin_src coq :noweb yes
> <<mycode>>
> #+end_src

Thanks a lot, that worked perfectly.

Alan

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

* Re: including the result of a block in several places?
  2012-12-10 10:17           ` Alan Schmitt
@ 2012-12-10 14:58             ` Eric Schulte
  2012-12-10 16:14               ` Alan Schmitt
  2012-12-10 19:32               ` Alan Schmitt
  0 siblings, 2 replies; 12+ messages in thread
From: Eric Schulte @ 2012-12-10 14:58 UTC (permalink / raw)
  To: Alan Schmitt; +Cc: Sebastien Vauban, emacs-orgmode

Alan Schmitt <alan.schmitt@polytechnique.org> writes:

> "Sebastien Vauban" <wxhgmqzgwmuf@spammotel.com> writes:
>
>> In a hurry, to repeat the code:
>>
>> - use named blocks
>> - use Noweb expansion
>>

Another option would be,

1. use named blocks
2. use call lines

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

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

* Re: including the result of a block in several places?
  2012-12-10 14:58             ` Eric Schulte
@ 2012-12-10 16:14               ` Alan Schmitt
  2012-12-10 19:32               ` Alan Schmitt
  1 sibling, 0 replies; 12+ messages in thread
From: Alan Schmitt @ 2012-12-10 16:14 UTC (permalink / raw)
  To: Eric Schulte; +Cc: Sebastien Vauban, Alan Schmitt, emacs-orgmode


Eric Schulte writes:

> Alan Schmitt <alan.schmitt@polytechnique.org> writes:
>
>> "Sebastien Vauban" <wxhgmqzgwmuf@spammotel.com> writes:
>>
>>> In a hurry, to repeat the code:
>>>
>>> - use named blocks
>>> - use Noweb expansion
>>>
>
> Another option would be,
>
> 1. use named blocks
> 2. use call lines

Thanks for the suggestion. I tried using a call line, but it does not
allow me to include the source code again (it's great to re-run the code
once more, though).

Alan

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

* Re: including the result of a block in several places?
  2012-12-10 14:58             ` Eric Schulte
  2012-12-10 16:14               ` Alan Schmitt
@ 2012-12-10 19:32               ` Alan Schmitt
  2012-12-10 19:43                 ` Thomas S. Dye
  1 sibling, 1 reply; 12+ messages in thread
From: Alan Schmitt @ 2012-12-10 19:32 UTC (permalink / raw)
  To: Org Mode

Eric Schulte writes:

> Alan Schmitt <alan.schmitt@polytechnique.org> writes:
>
>> "Sebastien Vauban" <wxhgmqzgwmuf@spammotel.com> writes:
>>
>>> In a hurry, to repeat the code:
>>>
>>> - use named blocks
>>> - use Noweb expansion
>>>
>
> Another option would be,
>
> 1. use named blocks
> 2. use call lines

Thanks for the suggestion. I tried using a call line, but it does not
allow me to include the source code again (it's great to re-run the code
once more, though).

Alan

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

* Re: including the result of a block in several places?
  2012-12-10 19:32               ` Alan Schmitt
@ 2012-12-10 19:43                 ` Thomas S. Dye
  2012-12-11  7:48                   ` Alan Schmitt
  0 siblings, 1 reply; 12+ messages in thread
From: Thomas S. Dye @ 2012-12-10 19:43 UTC (permalink / raw)
  To: Alan Schmitt; +Cc: Org Mode

Alan Schmitt <alan.schmitt@polytechnique.org> writes:

> Eric Schulte writes:
>
>> Alan Schmitt <alan.schmitt@polytechnique.org> writes:
>>
>>> "Sebastien Vauban" <wxhgmqzgwmuf@spammotel.com> writes:
>>>
>>>> In a hurry, to repeat the code:
>>>>
>>>> - use named blocks
>>>> - use Noweb expansion
>>>>
>>
>> Another option would be,
>>
>> 1. use named blocks
>> 2. use call lines
>
> Thanks for the suggestion. I tried using a call line, but it does not
> allow me to include the source code again (it's great to re-run the code
> once more, though).

What call line did you try?

All the best,
Tom

-- 
Thomas S. Dye
http://www.tsdye.com

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

* Re: including the result of a block in several places?
  2012-12-10 19:43                 ` Thomas S. Dye
@ 2012-12-11  7:48                   ` Alan Schmitt
  0 siblings, 0 replies; 12+ messages in thread
From: Alan Schmitt @ 2012-12-11  7:48 UTC (permalink / raw)
  To: Org Mode


Thomas S. Dye writes:

> Alan Schmitt <alan.schmitt@polytechnique.org> writes:
>
>> Eric Schulte writes:
>>
>>> Alan Schmitt <alan.schmitt@polytechnique.org> writes:
>>>
>>>> "Sebastien Vauban" <wxhgmqzgwmuf@spammotel.com> writes:
>>>>
>>>>> In a hurry, to repeat the code:
>>>>>
>>>>> - use named blocks
>>>>> - use Noweb expansion
>>>>>
>>>
>>> Another option would be,
>>>
>>> 1. use named blocks
>>> 2. use call lines
>>
>> Thanks for the suggestion. I tried using a call line, but it does not
>> allow me to include the source code again (it's great to re-run the code
>> once more, though).
>
> What call line did you try?

This is what I tried

#+begin_src org
** Prototype-based objects

#+name: object_example
#+begin_src js :results code output :exports both
var f = function(a) {
	this.x = a
}

f.prototype = {y : 1}

var o = new f (42)

console.log("o.x = " + o.x + ", o.y = " + o.y)
#+end_src

Results

#+results: object_example

** Prototypes resolution

Some other slide

** Prototype-based objects

#+call: echo(object_example) :results code output :exports both
#+end_src

My problem with this was twofold: the code from "object_example" is
not repeated, and the highlighting of the results in the "#+call:"
line is not in javascript syntax.

Using a "noweb" approach solves both issues.

Alan

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

end of thread, other threads:[~2012-12-11  7:48 UTC | newest]

Thread overview: 12+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2012-12-07 16:16 including the result of a block in several places? Alan Schmitt
2012-12-07 18:26 ` Sebastien Vauban
2012-12-08 10:13   ` Alan Schmitt
2012-12-08 16:57     ` Thomas S. Dye
2012-12-10  8:57       ` Alan Schmitt
2012-12-10  9:57         ` Sebastien Vauban
2012-12-10 10:17           ` Alan Schmitt
2012-12-10 14:58             ` Eric Schulte
2012-12-10 16:14               ` Alan Schmitt
2012-12-10 19:32               ` Alan Schmitt
2012-12-10 19:43                 ` Thomas S. Dye
2012-12-11  7:48                   ` Alan Schmitt

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