From: Tassilo Horn <tsdh@gnu.org>
To: Lars Ingebrigtsen <larsi@gnus.org>
Cc: 34160@debbugs.gnu.org, emacs-devel@gnu.org
Subject: Re: bug#34160: About commit bff64115a0ad081282e0f99305f41c8dd1917d67, bug#34160, json.el
Date: Thu, 01 Aug 2019 06:54:08 +0200 [thread overview]
Message-ID: <877e7xjxjj.fsf@gnu.org> (raw)
In-Reply-To: <87v9vinefd.fsf@mouse.gnus.org> (Lars Ingebrigtsen's message of "Wed, 31 Jul 2019 22:21:10 +0200")
Lars Ingebrigtsen <larsi@gnus.org> writes:
Hi Lars,
>> It's not just moving point. replace-region-contents also keeps marks,
>> text properties and fontification intact. So we should definitely be
>> using it here.
>
> Ah, I see. I only gave that function a cursory look-over when fixing
> this bug and I didn't quite understand what it was doing here, since I
> couldn't recall any other pretty-printer doing anything similar.
No worries! You probably didn't see it more often because it's quite
new. But pretty-printing is definitely a very good use-case for it.
> Sorry for the confusion here; I've now restored the
> replace-region-contents logic. Or at least I think so; it works with
> the test cases in this bug report, at least.
Yes, it works again. Thanks!
It can still be a bit improved in understandability and efficiency.
1. The function passed to replace-region-contents runs on the narrowed
buffer anyway, so no need to narrow it yourself.
2. It would be better to create a temporary buffer, json-read repeatedly
from the original buffer, json-encode/insert to the temp one, and
then return the temp buffer.
The reason for point 2 is that if the function passed to
replace-region-contents returns a string, it'll put that in a temporary
buffer anyhow so that it can use replace-buffer-contents to perform the
actual replacement (replace-region-contents is just a wrapper around
that).
And we might want to cater for the situation where the region starts or
ends inside a json object by copying the buffer substring from (point)
to end to the temp buffer in case json-read fails. I think right now,
we'd lose such half json objects and everything which follows them.
Bye,
Tassilo
next prev parent reply other threads:[~2019-08-01 4:54 UTC|newest]
Thread overview: 11+ messages / expand[flat|nested] mbox.gz Atom feed top
[not found] <CABOyWhcidWYNa+aEqFjtHd4TFrOf3Lx8PUHRy9ZvsCFtNPUJGQ@mail.gmail.com>
2019-07-31 7:39 ` About commit bff64115a0ad081282e0f99305f41c8dd1917d67, bug#34160, json.el Tassilo Horn
2019-07-31 15:38 ` bug#34160: " Eli Zaretskii
2019-07-31 18:40 ` Tassilo Horn
2019-07-31 18:48 ` Eli Zaretskii
2019-07-31 18:41 ` Lars Ingebrigtsen
2019-07-31 19:30 ` Tassilo Horn
2019-07-31 20:21 ` Lars Ingebrigtsen
2019-08-01 4:54 ` Tassilo Horn [this message]
2019-08-01 11:11 ` Lars Ingebrigtsen
2019-08-01 12:16 ` Tassilo Horn
2019-08-02 16:16 ` Tassilo Horn
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=877e7xjxjj.fsf@gnu.org \
--to=tsdh@gnu.org \
--cc=34160@debbugs.gnu.org \
--cc=emacs-devel@gnu.org \
--cc=larsi@gnus.org \
/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).