Re: [O] "user-error: No language for src block: (unnamed)" when running `org-icalendar-combine-agenda-files`

2015-08-21 Thread Charles C. Berry

On Fri, 21 Aug 2015, Andreas Leha wrote:


Hi,

Just a small comment.

[ ... discussion of :caching of evaluation results ... ]


For purely R-based work, Charles Berry’s ox-ravel package

is a very interesting approach, since it relies on the cache feature of
knitr, which is capable of automatically detecting cross-block
dependencies like the example above under some circumstances
.  It would be interesting to see
if that approach could be used to override :cache handling for ob-R,
while falling back on org-babel’s less intelligent features for other
languages (or in R environments that don’t have knitr available).


That would be just awesome!


I think I understand what Aaron is suggesting, but...

In ox-ravel exports, non-R src blocks get executed as usual, while R 
blocks get converted to `chunks' for later processing by knitr or Sweave 
or whatever. Anything that needs to be communicated from other languages 
to R via noweb `<>' or `:var rvar=elisp-block()' headers 
should work. That is, the resulting chunks will have code put into them 
as usual in R src block execution. (And this is useful for passing latex 
code to R, for example.)


But when the R code is run under knitr or some other engine outside of org 
mode, it cannot communicate values back to src blocks using other 
languages. Or even other R src blocks using `:var rvar=r-src-block()', 
say. And it cannot use `:post' header args. I agree it would be 
interesting to adapt knitr or some other dependency-aware caching engine 
to run under babel control to allow R to push results to other src blocks. 
I don't know how hard it would be to make it work well.


Chuck

p.s. I just pushed an org mode translation of auto-dependson.Rnw from 
https://github.com/yihui/knitr-examples to the ravel-lang branch at

https://github.com/chasberry/orgmode-accessories/blob/ravel-lang/autodep.org
It illustrates automatic dependency-aware caching of R src blocks.

p.p.s. I expect to move the `ravel-lang' branch to `master' soon, so I 
encourage users to try that branch.


Re: [O] "user-error: No language for src block: (unnamed)" when running `org-icalendar-combine-agenda-files`

2015-08-21 Thread Andreas Leha
Hi,

Just a small comment.

[ ... discussion of :caching of evaluation results ... ]

> For purely R-based work, Charles Berry’s ox-ravel package
> 
> is a very interesting approach, since it relies on the cache feature of
> knitr, which is capable of automatically detecting cross-block
> dependencies like the example above under some circumstances
> .  It would be interesting to see
> if that approach could be used to override :cache handling for ob-R,
> while falling back on org-babel’s less intelligent features for other
> languages (or in R environments that don’t have knitr available). 

That would be just awesome!

Regards,
Andreas




Re: [O] "user-error: No language for src block: (unnamed)" when running `org-icalendar-combine-agenda-files`

2015-08-21 Thread Charles C. Berry

On Fri, 21 Aug 2015, Ista Zahn wrote:


On Fri, Aug 21, 2015 at 11:04 AM, Nicolas Goaziou
 wrote:

Ista Zahn  writes:


I agree that it is safer. In my case its safer like a 10 MPH speed
limit. Safe yes, but too slow!


Doesn't Babel :cache property help here?


It does actually, to my surprise. I have not been using :cache because
the documentation says

"Note that the :cache header argument will not attempt to cache
results when the :session header argument is used"

and since I almost always use :session I didn't expect this to work.
To my surprise it does (at least with R source blocks, I haven't
tested yet with others). Can I now rely on this to work even with
:session?



AFAICS, (reading `org-babel-exp-do-export') if you do not 
use `:results silent' it will work.


Where this does not work is when `:results silent' is used.

This does not execute a second time:

#+BEGIN_SRC R :results output :session :cache yes
date()
#+END_SRC

but changing to `:results silent' will run without updating the cached 
RESULTS (if any) every time.


HTH,

Chuck





Re: [O] "user-error: No language for src block: (unnamed)" when running `org-icalendar-combine-agenda-files`

2015-08-21 Thread Aaron Ecay
Hi Ista,

2015ko abuztuak 21an, Ista Zahn-ek idatzi zuen:
> 
> On Fri, Aug 21, 2015 at 11:04 AM, Nicolas Goaziou
>  wrote:
>> Ista Zahn  writes:
>> 
>>> I agree that it is safer. In my case its safer like a 10 MPH speed
>>> limit. Safe yes, but too slow!
>> 
>> Doesn't Babel :cache property help here?
> 
> It does actually, to my surprise. I have not been using :cache because
> the documentation says
> 
> "Note that the :cache header argument will not attempt to cache
> results when the :session header argument is used"
> 
> and since I almost always use :session I didn't expect this to work.
> To my surprise it does (at least with R source blocks, I haven't
> tested yet with others). Can I now rely on this to work even with
> :session?

I think it depends on what you mean by “work.”  Specifically, :cache
doesn’t understand dependencies across source blocks when run in a
session.  So in the following document, if you edit the definition of
myvar, the subsequent usage will retain the old value on subsequent
exports:

==

#+begin_src R :session *foo* :cache yes
myvar <- 1
myvar
#+end_src

#+RESULTS[8310fa64b89f36a383660d14779e88d9aa90834a]:
: 1

#+begin_src R :session *foo* :cache yes
myvar
#+end_src

#+RESULTS[5c241816868f6400ccfb54ceb6ef15dbeea16de1]:
: 1

==

There are also subtle issues related to the fact that in order to export
a document, org:
1) makes a copy of the buffer
2) executes the babel blocks in this copy, destructively modifying the
   buffer as it goes
3) exports the result

In my experience, sometimes the header arguments, and thus the hash
that the cache depends on, can change.  So in addition to the cache not
re-evaluating when it should as above, it might needlessly re-evaluate
a computationally expensive block in the middle of export.

I tried to fix this about 2 years ago by getting the relevant code to
not do any buffer modifications as it goes but rather first evaluate
all the blocks then do all the needed modifications.  However, the
resultant patch was too big, and I ran out of time to work on it.
Since I made that attempt, a second, unmodified copy of the buffer has
been introduced to the process to help with some (nominally different
but related) aspects of babel processing.  This might have solved the
problem, but I’m not sure.

When the cache has not worked as I expected it to in the past, it’s been
in the middle of actually trying to do something with org, usually under
deadline pressure.  Thus, I’ve adopted the conservative approach of
evaluating blocks manually in all circumstances, and not trying to get
caching to work.  So, you might find that these problems have all gone
away as a consequence of other changes.

For purely R-based work, Charles Berry’s ox-ravel package

is a very interesting approach, since it relies on the cache feature of
knitr, which is capable of automatically detecting cross-block
dependencies like the example above under some circumstances
.  It would be interesting to see
if that approach could be used to override :cache handling for ob-R,
while falling back on org-babel’s less intelligent features for other
languages (or in R environments that don’t have knitr available).  But
that’s a(nother) big project.  (I’ve also never used ox-ravel in a
serious project, so my impressions are just based on reading the code
and documentation – which is a really excellent example of literate
elisp programming).

TLDR: If the standard of reliance is working as well as other cache-capable
literate programming libraries for R like knitr, in my (possibly out of
date) experience :cache + :session is not up to scratch.

-- 
Aaron Ecay



Re: [O] "user-error: No language for src block: (unnamed)" when running `org-icalendar-combine-agenda-files`

2015-08-21 Thread Ista Zahn
On Fri, Aug 21, 2015 at 11:04 AM, Nicolas Goaziou
 wrote:
> Ista Zahn  writes:
>
>> I agree that it is safer. In my case its safer like a 10 MPH speed
>> limit. Safe yes, but too slow!
>
> Doesn't Babel :cache property help here?

It does actually, to my surprise. I have not been using :cache because
the documentation says

"Note that the :cache header argument will not attempt to cache
results when the :session header argument is used"

and since I almost always use :session I didn't expect this to work.
To my surprise it does (at least with R source blocks, I haven't
tested yet with others). Can I now rely on this to work even with
:session?

Best,
Ista

>
> Regards,



Re: [O] "user-error: No language for src block: (unnamed)" when running `org-icalendar-combine-agenda-files`

2015-08-21 Thread Nicolas Goaziou
Ista Zahn  writes:

> I agree that it is safer. In my case its safer like a 10 MPH speed
> limit. Safe yes, but too slow!

Doesn't Babel :cache property help here?

Regards,



Re: [O] "user-error: No language for src block: (unnamed)" when running `org-icalendar-combine-agenda-files`

2015-08-21 Thread Ista Zahn
On Fri, Aug 21, 2015 at 10:43 AM, Andreas Leha
 wrote:
> Hi,
>
> Ista Zahn  writes:
>> On Fri, Aug 21, 2015 at 10:20 AM, Nicolas Goaziou
>>  wrote:
>>> Ista Zahn  writes:
>>>
 Unless you've restored sanity by setting org-export-babel-evaluate to
 nil. Personally I think this is not a good default. Source block
 evaluation and export are distinct actions, and I don't see why they
 should be linked by default.
>>>
>>> Wild guess:
>>>
>>> Principle of least surprise: setting it to nil means results from Babel
>>> code are not refreshed before export, without user realizing about it.
>>> I think most users would like them to be up-to-date before export. It
>>> seems sane to me.
>>
>> The problem is that if the code blocks are non-trivial it slows down
>> the export. Changing one line of documentation and exporting
>> re-evaluates all the code blocks, which for me often takes several
>> minutes. The defaults work for trivial examples, but not my real-world
>> use. Since it's easy to make it work how I want it to via
>> org-export-babel-evaluate I don't mean to complain too much. I posted
>> mostly to make sure the OP knows about org-export-babel-evaluate, in
>> case disabling code block evaluation on export makes sense for them.
>>
>
> I know that problem...
>
> Decoupling code block evaluation and export has the problem of
> decoupling code block evaluation and export ;-), though.  If you export
> your document without evaluating first, how can you be sure that the
> resulting document is based on the latest version of the code contained
> in the code blocks?

By calling org-babel-execute-buffer before exporting ;-)

The advantage of doing it this way is that you don't have to do that
if you haven't changed a code block.

  So, from my point of view the default is the safe
> option and, thus, fine.

I agree that it is safer. In my case its safer like a 10 MPH speed
limit. Safe yes, but too slow!

>
>
> Regards,
> Andreas
>
>



Re: [O] "user-error: No language for src block: (unnamed)" when running `org-icalendar-combine-agenda-files`

2015-08-21 Thread Andreas Leha
Hi, 

Ista Zahn  writes:
> On Fri, Aug 21, 2015 at 10:20 AM, Nicolas Goaziou
>  wrote:
>> Ista Zahn  writes:
>>
>>> Unless you've restored sanity by setting org-export-babel-evaluate to
>>> nil. Personally I think this is not a good default. Source block
>>> evaluation and export are distinct actions, and I don't see why they
>>> should be linked by default.
>>
>> Wild guess:
>>
>> Principle of least surprise: setting it to nil means results from Babel
>> code are not refreshed before export, without user realizing about it.
>> I think most users would like them to be up-to-date before export. It
>> seems sane to me.
>
> The problem is that if the code blocks are non-trivial it slows down
> the export. Changing one line of documentation and exporting
> re-evaluates all the code blocks, which for me often takes several
> minutes. The defaults work for trivial examples, but not my real-world
> use. Since it's easy to make it work how I want it to via
> org-export-babel-evaluate I don't mean to complain too much. I posted
> mostly to make sure the OP knows about org-export-babel-evaluate, in
> case disabling code block evaluation on export makes sense for them.
>

I know that problem...

Decoupling code block evaluation and export has the problem of
decoupling code block evaluation and export ;-), though.  If you export
your document without evaluating first, how can you be sure that the
resulting document is based on the latest version of the code contained
in the code blocks?  So, from my point of view the default is the safe
option and, thus, fine.


Regards,
Andreas




Re: [O] "user-error: No language for src block: (unnamed)" when running `org-icalendar-combine-agenda-files`

2015-08-21 Thread Ista Zahn
On Fri, Aug 21, 2015 at 10:20 AM, Nicolas Goaziou
 wrote:
> Ista Zahn  writes:
>
>> Unless you've restored sanity by setting org-export-babel-evaluate to
>> nil. Personally I think this is not a good default. Source block
>> evaluation and export are distinct actions, and I don't see why they
>> should be linked by default.
>
> Wild guess:
>
> Principle of least surprise: setting it to nil means results from Babel
> code are not refreshed before export, without user realizing about it.
> I think most users would like them to be up-to-date before export. It
> seems sane to me.

The problem is that if the code blocks are non-trivial it slows down
the export. Changing one line of documentation and exporting
re-evaluates all the code blocks, which for me often takes several
minutes. The defaults work for trivial examples, but not my real-world
use. Since it's easy to make it work how I want it to via
org-export-babel-evaluate I don't mean to complain too much. I posted
mostly to make sure the OP knows about org-export-babel-evaluate, in
case disabling code block evaluation on export makes sense for them.

>
> In any case, I don't see the harm here. OP uses invalid syntax and is
> warned about that. I think it's a decent way to proceed.

Yes, I agree about that.

Best,
Ista

>
> Regards,



Re: [O] "user-error: No language for src block: (unnamed)" when running `org-icalendar-combine-agenda-files`

2015-08-21 Thread Nicolas Goaziou
Ista Zahn  writes:

> Unless you've restored sanity by setting org-export-babel-evaluate to
> nil. Personally I think this is not a good default. Source block
> evaluation and export are distinct actions, and I don't see why they
> should be linked by default.

Wild guess:

Principle of least surprise: setting it to nil means results from Babel
code are not refreshed before export, without user realizing about it.
I think most users would like them to be up-to-date before export. It
seems sane to me.

In any case, I don't see the harm here. OP uses invalid syntax and is
warned about that. I think it's a decent way to proceed.

Regards,



Re: [O] "user-error: No language for src block: (unnamed)" when running `org-icalendar-combine-agenda-files`

2015-08-21 Thread Ista Zahn
On Fri, Aug 21, 2015 at 7:50 AM, Nicolas Goaziou  wrote:
> Hello,
>
> "JI, Xiang"  writes:
>
>> Well actually I think the error shows because of another block below
>> the emacs-lisp blocks. In this header I just wrote #+BEGIN_SRC without
>> any language name. Is it actually wrong and maybe I should have
>> written #+BEGIN_EXAMPLE instead?
>
> Correct.
>
>> Though I’d still say it probably shouldn’t have failed the export?…
>
> Babel blocks are executed prior to any export process, no matter what
> you want to include in the output.

Unless you've restored sanity by setting org-export-babel-evaluate to
nil. Personally I think this is not a good default. Source block
evaluation and export are distinct actions, and I don't see why they
should be linked by default.

Best,
Ista



Re: [O] "user-error: No language for src block: (unnamed)" when running `org-icalendar-combine-agenda-files`

2015-08-21 Thread Nicolas Goaziou
Hello,

"JI, Xiang"  writes:

> Well actually I think the error shows because of another block below
> the emacs-lisp blocks. In this header I just wrote #+BEGIN_SRC without
> any language name. Is it actually wrong and maybe I should have
> written #+BEGIN_EXAMPLE instead?

Correct.

> Though I’d still say it probably shouldn’t have failed the export?…

Babel blocks are executed prior to any export process, no matter what
you want to include in the output. For example, some blocks could set-up
export.

Therefore, a wrong Babel block always fails an export process.

Regards,

-- 
Nicolas Goaziou



Re: [O] "user-error: No language for src block: (unnamed)" when running `org-icalendar-combine-agenda-files`

2015-08-20 Thread JI , Xiang
Well actually I think the error shows because of another block below the 
emacs-lisp blocks. In this header I just wrote #+BEGIN_SRC without any language 
name. Is it actually wrong and maybe I should have written #+BEGIN_EXAMPLE 
instead? Though I’d still say it probably shouldn’t have failed the export?…


On 20. August 2015 at 17:38:36, JI, Xiang (h...@xiangji.me) wrote:

I’m trying to export all my agenda files into an ics file via 
org-icalendar-combine-agenda-files. However, the export process stops halfway 
through. The following are shown in Messages:

org-babel-exp process emacs-lisp at line 72...
org-babel-exp process emacs-lisp at line 208...
user-error: No language for src block: (unnamed)

which is weird because

I already set org-calendar-include-body to nil. I don’t think a code block in 
the middle of a org file should impact iCalendar export.
The code block begins with #BEGIN_SRC emacs-lisp and is highlighted correctly. 
I’m not sure why it says “no language for src block”.
Regards,

JI, Xiang



[O] "user-error: No language for src block: (unnamed)" when running `org-icalendar-combine-agenda-files`

2015-08-20 Thread JI , Xiang
I’m trying to export all my agenda files into an ics file via 
org-icalendar-combine-agenda-files. However, the export process stops halfway 
through. The following are shown in Messages:

org-babel-exp process emacs-lisp at line 72...
org-babel-exp process emacs-lisp at line 208...
user-error: No language for src block: (unnamed)
which is weird because

I already set org-calendar-include-body to nil. I don’t think a code block in 
the middle of a org file should impact iCalendar export.
The code block begins with #BEGIN_SRC emacs-lisp and is highlighted correctly. 
I’m not sure why it says “no language for src block”.
Regards,

JI, Xiang