bug-gnu-emacs
[Top][All Lists]
Advanced

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

bug#12507: [debbugs-tracker] Processed: severity 12507 wishlist


From: Drew Adams
Subject: bug#12507: [debbugs-tracker] Processed: severity 12507 wishlist
Date: Thu, 27 Sep 2012 11:37:02 -0700

> >>   ;; Don't use write-file; we don't want this buffer to visit it.
> >
> > After write-file, the buffer is marked as visiting that file, which
> > affects the behavior of C-x C-f and a lot more (e.g. asks the user
> > for confirmation if the file was modified by some other process, ...).
>
> What about improving write-region to use backup when needed?
> Possibly writing a new write-region-something function that handle
> backup, or a write-file-noselect function.

+1

And please let us know how best to accomplish that (in the doc perhaps, but also
in this thread).

It's not clear to me how to make a backup copy of a file without visiting that
file in some buffer, however temporarily.

For example, I can imagine this as a way to append the region to a file and back
it up:

 (write-region (point-min) (point-max) FILE 'append)
 (with-current-buffer (find-file-noselect FILE) (backup-buffer))

But IIUC `find-file-noselect' visits the buffer (and so "asks the user for
confirmation if the file was modified by some other process").  So that's
apparently not the way to go.  What is?

Leaving the question of visiting aside for the moment, what about
`backup-buffer' here?  Should it be `save-buffer' instead, so that the modes of
FILE get updated properly?  Should it be just `basic-save-buffer-1' instead of
`save-buffer'?

And should any such code take what Juri mentioned wrt vc into account?  If so,
how?

It's not clear to me how best to handle this
write-stuff-to-a-file-and-back-it-up-when-appropriate, but I (and perhaps
others) would like to learn.  I haven't found the answer by looking at the
manuals or perusing the source code.  Can you help?

Thx.






reply via email to

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