emacs-devel
[Top][All Lists]
Advanced

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

Re: Lisp primitives and their calling of the change hooks


From: Alan Mackenzie
Subject: Re: Lisp primitives and their calling of the change hooks
Date: Sun, 7 Jan 2018 17:54:18 +0000
User-agent: Mutt/1.7.2 (2016-11-26)

Hello, Eli.

On Sun, Jan 07, 2018 at 18:47:41 +0200, Eli Zaretskii wrote:
> > Date: Sun, 7 Jan 2018 13:56:29 +0000
> > From: Alan Mackenzie <address@hidden>
> > Cc: address@hidden, address@hidden

> > > > zlib-decompress-region calls del_range, which calls the hooks.  Or am
> > > > I missing something?

> > > Yes, you're right, sorry.  There are change-hook calls for the second,
> > > deletion, part of the operation.  No hooks are called for the first
> > > part, the insertion of the decompressed text into the buffer.  So
> > > zlib-decompress-region is still not right.

> > > I'm going to take a careful look for any more such primitives, which
> > > have one balanced pair of change hook calls, yet these calls only cover
> > > part of the operation.

> > There appear to be no more such primitives.

> > Should I try to fix zlib-decompress-region?

> How do you want to fix it?  That function inserts the decompressed
> stuff, then deletes the original compressed stuff.  What do you want
> that to produce in terms of the change hooks?

IIUC, zlib-decompress-region decompresses in chunks into the gap,
expanding the gap after each chunk.

The strategy of one overarching before-change-functions followed by lots
of little after-change-functions can't really work here, since we don't
know in advance how big the region being written to is.  In fact, I think
this strategy is used only when the individual changes don't change the
buffer's size, e.g. when doing upcase-region, or
translate-region-internal.  We don't have this here.

One way of doing it would be to have a balanced pair of b/a-c-f for each
chunk of text inserted.  The other way would be having a single b/a-c-f
pair.

For reasons I can't articulate, I think the single pair of hooks would be
better; less "noisy", perhaps.  But either strategy would work well.

-- 
Alan Mackenzie (Nuremberg, Germany).



reply via email to

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