From mboxrd@z Thu Jan 1 00:00:00 1970 From: Eric Schulte Subject: Re: Not overwriting unchanged source code files when tangling Date: Fri, 18 Nov 2011 13:24:00 -0700 Message-ID: <878vndgowv.fsf@gmail.com> References: <87pqgpgqtt.fsf@gmail.com> <87wrax8a5h.fsf@Rainer.invalid> Mime-Version: 1.0 Content-Type: text/plain Return-path: Received: from eggs.gnu.org ([140.186.70.92]:58842) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1RRUyo-0002x7-SF for emacs-orgmode@gnu.org; Fri, 18 Nov 2011 15:24:15 -0500 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1RRUyk-0006ob-Ki for emacs-orgmode@gnu.org; Fri, 18 Nov 2011 15:24:10 -0500 Received: from mail-iy0-f169.google.com ([209.85.210.169]:65002) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1RRUyk-0006oB-H8 for emacs-orgmode@gnu.org; Fri, 18 Nov 2011 15:24:06 -0500 Received: by iaek3 with SMTP id k3so5177866iae.0 for ; Fri, 18 Nov 2011 12:24:05 -0800 (PST) In-Reply-To: <87wrax8a5h.fsf@Rainer.invalid> (Achim Gratz's message of "Fri, 18 Nov 2011 21:10:02 +0100") List-Id: "General discussions about Org-mode." List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: emacs-orgmode-bounces+geo-emacs-orgmode=m.gmane.org@gnu.org Sender: emacs-orgmode-bounces+geo-emacs-orgmode=m.gmane.org@gnu.org To: Achim Gratz Cc: emacs-orgmode@gnu.org Achim Gratz writes: > Eric Schulte 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/