emacs-devel
[Top][All Lists]
Advanced

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

Re: Missing `with' macro?


From: Stuart D. Herring
Subject: Re: Missing `with' macro?
Date: Tue, 8 Aug 2006 11:32:30 -0700 (PDT)
User-agent: SquirrelMail/1.4.6-7.el3.7lanl

>     Is it completely unacceptable even if the file in question is
> principally
>     "owned" by code anyway?
>
> Yes, I think so.  If it is unlikely that users will edit the file by
> hand, that means there is unlikely to be a buffer to reuse.  But IF
> there is a buffer to reuse, it means the user edited the file by hand.
> When he does so, you should not save his changes without his ok!

It means the user -visited- the file explicitly.  He may or may not have
been interested in changing it by hand.  I don't know, however, if this
distinction is important.

>     I see other possibilities:
>     1. (and REUSE WRITE (buffer-modified-p #<buffer extant-buffer>) (error
>     "Attempt to co-opt user's unsaved changes")) - that is, only allow
> REUSE
>     and WRITE on an unmodified buffer.
>
> It is better to go ahead not reusing the buffer than to signal an
> error.

Aha -- perhaps there's a good "compromise" here.  What if REUSE is treated
as nil if the extant buffer is modified and WRITE is non-nil?  Since the
file may be visited using the wrong literality, there is already no
guarantee that REUSE "does anything", so it's not drastically different. 
There is still the problem of the user's unsaved changes clashing, but
client code can always detect this eventuality if it's important, and it
can happen anyway (the user could intend to C-x C-w another buffer into
the file, or the literality condition could apply to a modified buffer,
or...).

It would be more consistent to categorically only reuse unmodified buffers
-- but for just reading the file, it can make sense to see the user's
changes (if any), and any program which wanted to avoid "unstable" file
contents can just pass REUSE as nil anyway.

The relevant section of the doc string would then read

REUSE non-nil means to use an existing buffer if it is visiting FILE. 
(The value of `find-file-existing-other-name' affects this determination.)
 The buffer will only be re-used if its literal status (see
`find-file-literally') corresponds to RAW.  To avoid interacting with a
user's unsaved changes, the buffer will be ignored if it is modified and
WRITE is non-nil.  Note that reusing a buffer may mean that the text on
which BODY operates differs from the actual contents of FILE.

Should I add a note that the user's buffer can become outdated as a result
of failed or unattempted reuse of it?

Davis

-- 
This product is sold by volume, not by mass.  If it appears too dense or
too sparse, it is because mass-energy conversion has occurred during
shipping.




reply via email to

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