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: Eric Schulte
Subject: Re: [O] Not overwriting unchanged source code files when tangling
Date: Fri, 18 Nov 2011 13:24:00 -0700
User-agent: Gnus/5.13 (Gnus v5.13) Emacs/24.0.91 (gnu/linux)

Achim Gratz <address@hidden> writes:

> Eric Schulte <address@hidden> writes:
>> I think the best approach in this case would be to tangle each file out
>> to a temporary buffer, and then just before exiting the tangle function
>> the content of these temporary buffers could be checked against the
>> files on disk, and only those buffers which differ from disk would be
>> written.  See ob-tangle.el around line 240 for the relevant code.
>> Unfortunately this would not be trivial, as currently content is written
>> to the target files incrementally block by block.
>
> It would be wise to follow an age-old tradition and not clobber an
> existing file with before it is known that the process will finish
> without error.  A temporary file is easily trashed when something goes
> wrong and the previous result still available.  If all went well, the
> old file can be deleted (or renamed to a backup file) and the temporary
> file can be moved to where the old one was if the two SHA1 differ.
>

Agreed, it would be preferable to build up the tangled contents in
memory and not write to the file system until the tangling process is
complete.

>> Finally, it may be easiest simply to play make's game as it were and
>> break up the Org-mode file into multiple files.  These multiple files
>> could still be combined during export using #+INCLUDE lines from a
>> single master Org-mode file.
>
> Well, I've been wondering about this for some time: can one make sort of
> an "indirect buffer" from the contents of multiple other buffers in
> Emacs?  That would make such #+INCLUDEs much more seamless.
>

Hmm, this could be useful both inside and outside of Org-mode.  Emacs
does have indirect buffers [1], however they are exact copies of another
buffer, I don't know if it would be possible to combine multiple
indirect buffers into a single buffer.

Thanks -- Eric

>
>
> Regards,
> Achim.


Footnotes: 
[1]  (info "(elisp) Indirect Buffers")

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



reply via email to

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