emacs-orgmode
[Top][All Lists]
Advanced

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

Re: [O] Not overwriting unchanged source code files when tangling


From: cberry
Subject: Re: [O] Not overwriting unchanged source code files when tangling
Date: Sat, 19 Nov 2011 10:06:47 -0800
User-agent: Gnus/5.13 (Gnus v5.13) Emacs/23.3 (gnu/linux)

Holger Hoefling <address@hidden> writes:

> Hi Carsten, thanks for the suggestion, but as I agree with Brian. If
> there is more than one source file in the org-file, then the whole
> project would still be recompiled, not just the updated file.To be
> more exact, I actually don&#39;t want to compile things, but run R
> scripts using make. 

There are caching tools in R that might handle this. packages weaver and
cacheSweave come to mind.

For example, tangling your *.org file to produce a trivial Sweave
document consisting of a single code chunk with the 'cache=T' argument,
then Sweaving it using the 'weaver' driver from the weaver package will
cache all the computations. Subsequent changes to the code followed by a
new weave will result in cached values being used when possible and
fresh computations being done as needed. I believe this is done on an
expression by expression basis so adding a bit of whitespace or a
comment will not trigger recomputation.

So you can overwrite the document and making trivial changes to
expressions without having to recompute expressions that have not
changed (and have no dependencies that are changed).


HTH,

Chuck



> So the waiting time if a computationally intensive step is repeated
> although it is not necessary can be substantial.

> I wonder how difficult the following change would be (no emacs lisp
> experience, also do not know the org source code):- would it be
> possible to write out the source files when tangling into a temporary
> directory, then compare to the actual target files and overwrite only
> if something has changed? Then the time stamps would stay
> fixed. Hopefully, this would not involve too much work:


> - creating temporary files and remembering the mapping to true files-
> tangling out as usual into temporary files (so probably little change
> there)- compare temporary file to true file (does emacs already have a
> diff utility that could be used?)

> - overwrite true file if any changes- delete temporary
> filesEspecially, with this method no dependencies would be necessary
> and it would not be necessary to keep track in the org files which
> source blocks have been changed since the last tangling

> Thank you for your suggestionHolger

> On Fri, Nov 18, 2011 at 6:02 PM, Carsten Dominik <span 
> dir="ltr"><mailto:address@hidden></span> wrote:

>
> On 18.11.2011, at 14:17, Holger Hoefling wrote:
>
>> Hi,
>>

>> I have a problem/request for org-mode and was looking for help. I am
>> using org-mode to write source code files and tangle them out. I want
>> to compile them using make. My problem now is that org-mode
>> overwrites the old files every time I tangle them out, therefore also
>> updating the time stamp - even if nothing has changed. Subsequently,
>> when I run make, everything gets recompiled, not just the changed
>> source code files as all time stamps have changed.
>
>>
>> Is there an option for org-mode to only overwrite source code files
>> that get tangled out if they have truly changed?
>
> How about changing the make file so that the dependence is on the Org file, 
> not on the source file?
> You could then arrange for make to call emacs in batch-mode to tangle the 
> source file and then compile it?
>
> Something along the lines of.... (untested, and probably wrong in this way...)
>
> file.o: http://somefile.org
>    emacs -batch --eval &#39;(org-babel-tangle-file "http://somefile.org";)&#39;
>    cc file.o ....
>
> - Carsten

-- 
Charles C. Berry                            Dept of Family/Preventive Medicine
address@hidden                      UC San Diego
http://famprevmed.ucsd.edu/faculty/cberry/  La Jolla, San Diego 92093-0901




reply via email to

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