[Top][All Lists]

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

Re: gratuitous changes

From: Miles Bader
Subject: Re: gratuitous changes
Date: Thu, 6 Feb 2003 12:22:31 -0500
User-agent: Mutt/1.3.28i

On Thu, Feb 06, 2003 at 05:34:03PM +0100, Martin Stjernholm wrote:
> > Me too, but I'm a bit fearful of how it's implemented -- is it
> > yet-another-entry in post-command-hook, or is it more clever?
> It uses after-change-functions, post-command-hook, first-change-hook
> and write-contents-hooks. What's the problem with that?

It slows down editing.  post-command-hook is especially bad because it
happens after _every_ command, even all those little cursor-movement commands
that people expect to be _fast_.  While this is acceptable for localized and
special uses, I think it's good to avoid global (or widespread) use of these
hooks unless it's absolutely possible to do otherwise.  Remember, other
packages could be using them too, and the time adds up!

> Is there a more "clever" way?

I don't know, I haven't really thought about it.

Here's an off-the-top-of-my-head idea though:

Suppose some hook wrapped all the text in a visited file with an appropriate
`modification-hooks' property, which would simply remove itself from any
lines that were modified.  Then the file-write-time hook could scan through
and only remove line-ending whitespace from lines that aren't wrapped by that

This method has the advantage that it only affects text modification, not
cursor movement etc., and it only causes slowdown the first time a particular
piece of text is modified; since most editing is localized, this means it
probably wouldn't have much speed impact at all.

Of course it probably has disadvantages too, but they don't come to mind...

Quidquid latine dictum sit, altum viditur.

reply via email to

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