[Top][All Lists]

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

Re: Thinking about changed buffers

From: Phillip Lord
Subject: Re: Thinking about changed buffers
Date: Tue, 29 Mar 2016 14:14:08 +0100
User-agent: SquirrelMail/1.5.2 [SVN]

On Mon, March 28, 2016 6:31 pm, Lars Magne Ingebrigtsen wrote:
> One idea that popped up is that whenever we mark a buffer as unchanged
> (that is, `(set-buffer-modified-p nil)', we save the byte size of the
> buffer and a cryptographic hash of the buffer.  Then `buffer-modified-p'
> would simply see whether either the size had changed, and if not, whether
> the hash had changed.  If both are identical, then the buffer hasn't
> changed.

Rather than doing this in general, why not have a
"with-potentially-unmodified" macro, which calculates this hash and
restores buffer-modified-p if no changes have happened. This would solve
the "fill-paragraph" problem.

Although, I would worry about the implications for the before and
after-change hooks. fill-paragraph is already problematic here because
before and after changes hooks are not necessarily consistent. In the case
where no changes happen, would we expect before and after change hook to
run? Because they would have to, as we do not know whether the buffer will
change before we change.

The only solution I can see for fill-paragraph is to copy the paragraph to
a temp buffer, fill that, check whether it has changed, then if it has,
signal before-change, copy the changed paragraph back, signal after
change. If it has not changed, then fill-paragraph becomes a no-op.


reply via email to

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