GNU bug report logs -
#34160
json-pretty-print deletes everything after first JSON object
Previous Next
Full log
View this message in rfc822 format
> The user referred to
> "http://git.savannah.gnu.org/cgit/emacs.git/tree/lisp/json.el#n740",
> which doesn't look like Emacs 24?
Ah, might be.
>> Could you please reinstall the feature or describe why it is not
>> feasible to keep it?
>
> As the bug in question described -- pretty-printing a JSON region would
> silently delete everything but the first JSON object, which doesn't seem
> like optimal behaviour for a pretty-printing function.
Obviously not. :-)
> If there's a problem where point is moved unnecessarily, then that
> should be fixed, of course. Do you have a test case?
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.
The loop over all json objects in the region you've added is correct. It's
just that I beg you to drop the delete-region / insert in favor of
replace-region-contents.
json-read advances point until the end of the read json. This can be used
to give the right region (not the complete region as I did) to the repeated
replace-region-contents calls.
Feel free to give it a try. Otherwise I'll do it on the weekend.
For a test case for point keeping its position in the json: use my command
from my original mail and an arbitrary json file and invoke it while point
is somewhere inside the json object.
Bye,
Tassilo
This bug report was last modified 5 years and 353 days ago.
Previous Next
GNU bug tracking system
Copyright (C) 1999 Darren O. Benham,
1997,2003 nCipher Corporation Ltd,
1994-97 Ian Jackson.