emacs-orgmode
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: [Orgmode] [babel] Is ":results output inline" possible


From: emailorama
Subject: Re: [Orgmode] [babel] Is ":results output inline" possible
Date: Mon, 19 Oct 2009 23:12:10 -0700 (PDT)

Thanks very much for your reply Eric.

    So the ":results org" feature was there all along.
    Searching for "raw" in "org-babel.el" shows it's nicely
    explained in the doc-string for "org-babel-insert-result".
    (maybe I should have done that sooner)

    I also noticed the ":results html" and ":results latex"
    options which look very useful.

    The latex option encloses the output in a
    #+BEGIN_LaTeX ... #+END_LaTeX block, which is nice because
    when the source block is re-executed, the new results
    replace the old results.

 -- Would it be possible to have something like that for "raw"
    or "org" mode?  
    (Maybe that would need a #+BEGIN_org ... #+END_org kind
    of construct.)

    Also, I've been looking at #+lob: which looks like another
    really useful idea, and there are two things I am wondering
    about.

 -- Is it possible to use #+lob: with ":results output org" ?

 -- Is it possible for #+lob: to take a string argument ?
    
    The 4 examples below show things I have tried.
      1. and 2. work fine.  
      3. and 4. are what I can't work out.


Thanks for any ideas you have about these things.

al

--------------------------------------------------
1.  :results output org -> works
--------------------------------------------------
#+srcname: randone
#+begin_src ruby :results output org
description = "lucky"
number = 3
maximum = 100
puts "* Random numbers\n" +
"Here are some #{description} numbers: " +
(1..number).collect {|x| (rand * maximum).ceil }.join(", ") +
"."
#+end_src

#+resname: randone
* Random numbers
Here are some lucky numbers: 48, 69, 6.


--------------------------------------------------
2. :results value  -> works with #+lob:
--------------------------------------------------
#+srcname: randtwo(n,max)
#+begin_src ruby :results value
number = n
maximum = max
"* Random numbers\n" +
"Here are some random numbers: " +
(1..number).collect {|x| (rand * maximum).ceil }.join(", ") +
"."
#+end_src

#+lob: randtwo(n=3,max=100)

#+resname: randtwo(n=3,max=100)
: * Random numbers
: Here are some random numbers: 14, 77, 75.


--------------------------------------------------
3. :results output org -> doesn't work with #+lob:
--------------------------------------------------
#+srcname: randthree(n,max)
#+begin_src ruby :results output org
number = n
maximum = max
puts "* Random numbers\n" +
"Here are some random numbers: " +
(1..number).collect {|x| (rand * maximum).ceil }.join(", ") +
"."
#+end_src

#+lob: randthree(n=3,max=10)

#+resname: randthree(n=3,max=10)
: nil


--------------------------------------------------
4. Not sure how to use string argument with #+lob:
--------------------------------------------------
#+srcname: randfour(n,max,desc)
#+begin_src ruby :results value
description = desc
number = n
maximum = max
"* Random numbers\n" +
"Here are some #{description} numbers: " +
(1..number).collect {|x| (rand * maximum).ceil }.join(", ") +
"."
#+end_src

#+lob: randfour(n=3,max=100,desc="lucky")

#+resname: randfour(n=3,max=100,desc="lucky")
: randfour








reply via email to

[Prev in Thread] Current Thread [Next in Thread]