From: Alan Mackenzie <acm@muc.de>
To: Eli Zaretskii <eliz@gnu.org>
Cc: monnier@iro.umontreal.ca, emacs-devel@gnu.org
Subject: Re: Lisp primitives and their calling of the change hooks
Date: Mon, 8 Jan 2018 19:24:15 +0000 [thread overview]
Message-ID: <20180108192415.GA5531@ACM> (raw)
In-Reply-To: <837est81bl.fsf@gnu.org>
Hello, Eli.
On Mon, Jan 08, 2018 at 05:41:02 +0200, Eli Zaretskii wrote:
> > Date: Sun, 7 Jan 2018 21:10:55 +0000
> > Cc: monnier@iro.umontreal.ca, emacs-devel@gnu.org
> > From: Alan Mackenzie <acm@muc.de>
> > > Like I said, I think we should have only one pair of hooks, like we
> > > have in replace_range.
> > OK. This is slightly more awkward: del_range needs to be replaced by
> > del_range_2, so as not to get an extra call to signal_after_change.
> You need a call to update_compositions after del_range_2, to mimic
> what del_range does, I think.
Yes, I think so to (though I'm only vaguely aware of what compositions
are ;-). See below.
> > There is also no a-c-f call if the decompression exits with an error.
> You mean, if the user quits? That throws to top level, so it would be
> wrong to invoke any after-change hooks, and unwind_decompress will
> call the hooks for the partially uncompressed data. Do we need more?
I was thinking more of when the compressed text is corrupt and the
decompression routines report an error. With the current version (see
below), I simulate an error with
(zlib-decompress-region (point-min) (1- (point-max)))
, i.e. chopping the last byte off the buffer. (I am using my Linux
configuration from /proc/config.gz for all this.)
This produces these hook calls:
(1 22016) (22016 118057) (22016 22016 96041)
, the first being the opening modify_text(), and the last two being the
deletion of the incomplete decompressed region by a call to del_range()
from an unwind-protect. The (1 22016) b-c-f is thus unbalanced when this
happens.
I'm asking you to consider again having two pairs of hook calls in this
primitive (as, for example, base64-decode-region does). That way we need
only signal the b-c-f for the deletion after the decompression has
worked, and we know we are going to follow through with the deleteion. I
think an aborted decompression operation would also be easier to close
off with an a-c-f with this strategy.
Here's the amended patch from last night with update_compositions in:
diff --git a/src/decompress.c b/src/decompress.c
index 41de6da1dd..eebaa2eb30 100644
--- a/src/decompress.c
+++ b/src/decompress.c
@@ -24,6 +24,7 @@ along with GNU Emacs. If not, see <https://www.gnu.org/licenses/>. */
#include "lisp.h"
#include "buffer.h"
+#include "composite.h"
#include <verify.h>
@@ -141,6 +142,10 @@ This function can be called only in unibyte buffers. */)
the same. */
istart = XINT (start);
iend = XINT (end);
+
+ /* Do the following before manipulating the gap. */
+ modify_text (istart, iend);
+
move_gap_both (iend, iend);
stream.zalloc = Z_NULL;
@@ -196,7 +201,11 @@ This function can be called only in unibyte buffers. */)
unwind_data.start = 0;
/* Delete the compressed data. */
- del_range (istart, iend);
+ del_range_2 (istart, istart, /* byte and char offsets are the same. */
+ iend, iend, 0);
+
+ signal_after_change (istart, iend - istart, unwind_data.nbytes);
+ update_compositions (istart, istart, CHECK_HEAD);
return unbind_to (count, Qt);
}
> Thanks.
--
Alan Mackenzie (Nuremberg, Germany).
next prev parent reply other threads:[~2018-01-08 19:24 UTC|newest]
Thread overview: 66+ messages / expand[flat|nested] mbox.gz Atom feed top
2018-01-03 12:45 Lisp primitives and their calling of the change hooks Alan Mackenzie
2018-01-03 21:51 ` Stefan Monnier
2018-01-04 15:51 ` Alan Mackenzie
2018-01-04 18:16 ` Stefan Monnier
2018-01-04 21:11 ` Alan Mackenzie
2018-01-04 21:36 ` Stefan Monnier
2018-01-06 15:18 ` Alan Mackenzie
2018-01-06 15:51 ` Stefan Monnier
2018-01-06 16:18 ` Eli Zaretskii
2018-01-06 19:06 ` Alan Mackenzie
2018-01-06 20:24 ` Alan Mackenzie
2018-01-07 11:36 ` Alan Mackenzie
2018-01-07 11:49 ` Eli Zaretskii
2018-01-07 12:08 ` Alan Mackenzie
2018-01-07 13:56 ` Alan Mackenzie
2018-01-07 15:21 ` [SUSPECTED SPAM] " Stefan Monnier
2018-01-07 16:47 ` Eli Zaretskii
2018-01-07 17:50 ` Stefan Monnier
2018-01-07 17:58 ` Eli Zaretskii
2018-01-07 19:04 ` Stefan Monnier
2018-01-07 19:48 ` Alan Mackenzie
2018-01-07 19:58 ` Eli Zaretskii
2018-01-07 21:10 ` Alan Mackenzie
2018-01-08 3:41 ` Eli Zaretskii
2018-01-08 19:24 ` Alan Mackenzie [this message]
2018-01-08 21:15 ` Eli Zaretskii
2018-01-08 22:24 ` Stefan Monnier
2018-01-09 3:55 ` Eli Zaretskii
2018-01-09 13:30 ` Stefan Monnier
2018-01-09 18:50 ` Eli Zaretskii
2018-01-09 19:53 ` Alan Mackenzie
2018-01-09 20:05 ` Eli Zaretskii
2018-01-10 18:29 ` Alan Mackenzie
2018-01-12 16:40 ` Alan Mackenzie
2018-01-09 20:07 ` Stefan Monnier
2018-01-10 18:45 ` Alan Mackenzie
2018-01-10 19:30 ` Stefan Monnier
2018-01-10 19:48 ` Alan Mackenzie
2018-01-10 20:33 ` Stefan Monnier
2018-01-10 21:03 ` Alan Mackenzie
2018-01-11 13:36 ` Stefan Monnier
2018-01-11 17:39 ` Alan Mackenzie
2018-01-11 19:35 ` Stefan Monnier
2018-01-11 19:46 ` Alan Mackenzie
2018-01-11 20:15 ` Stefan Monnier
2018-01-11 21:20 ` Alan Mackenzie
2018-01-11 23:42 ` Stefan Monnier
2018-01-12 16:14 ` Alan Mackenzie
2018-01-10 22:06 ` Clément Pit-Claudel
2018-01-10 22:20 ` Alan Mackenzie
2018-01-08 4:29 ` Stefan Monnier
2018-01-07 17:54 ` Alan Mackenzie
2018-01-07 18:05 ` Eli Zaretskii
2018-01-05 6:55 ` Eli Zaretskii
2018-01-05 11:41 ` Alan Mackenzie
2018-01-05 13:00 ` Eli Zaretskii
2018-01-05 13:34 ` Alan Mackenzie
2018-01-05 14:08 ` Eli Zaretskii
2018-01-05 15:54 ` Alan Mackenzie
2018-01-05 16:50 ` Stefan Monnier
2018-01-05 17:38 ` Alan Mackenzie
2018-01-05 18:09 ` Stefan Monnier
2018-01-05 19:53 ` Eli Zaretskii
2018-01-05 22:28 ` Stefan Monnier
2018-01-06 9:05 ` Eli Zaretskii
2018-01-06 15:26 ` Stefan Monnier
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
List information: https://www.gnu.org/software/emacs/
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=20180108192415.GA5531@ACM \
--to=acm@muc.de \
--cc=eliz@gnu.org \
--cc=emacs-devel@gnu.org \
--cc=monnier@iro.umontreal.ca \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
Code repositories for project(s) associated with this public inbox
https://git.savannah.gnu.org/cgit/emacs.git
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).