[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
Re: save-excursion doesn't restore point with json-pretty-print
From: |
tomas |
Subject: |
Re: save-excursion doesn't restore point with json-pretty-print |
Date: |
Fri, 1 Feb 2019 10:55:16 +0100 |
User-agent: |
Mutt/1.5.21 (2010-09-15) |
On Fri, Feb 01, 2019 at 10:32:20AM +0100, Tassilo Horn wrote:
> Hi all,
>
> I have this small command in my ~/.emacs:
[...]
> For example, when point is on the 1 below,
>
> {"foo": 1, "bar":27}
>
> I'll end up with
>
> {
> "foo": 1,
> "bar": 27
> }
>
> and point is on the {. I'd expect it to still sit on the 1.
>
> Obviously, `save-excursion' works just fine in all other places. It
> seems like it's just not playing well with `json-pretty-print', and I
> don't know why.
AFAIK the mechanism for save-excursion is to set a special marker
to return to after the excursion.
Now the pretty print probably replaces the whole region in the
process: the marker can't be at the same place where it was. If
you're lucky, it'll be at one of both region's borders.
A more careful pretty-print process which is capable of "floating"
existing markers around sounds like an interesting challenge :-)
(Note that this is just armchair analysis, and I could be totally
wrong).
Cheers
-- tomás
signature.asc
Description: Digital signature
- save-excursion doesn't restore point with json-pretty-print, Tassilo Horn, 2019/02/01
- Re: save-excursion doesn't restore point with json-pretty-print,
tomas <=
- Re: save-excursion doesn't restore point with json-pretty-print, Eli Zaretskii, 2019/02/01
- Re: save-excursion doesn't restore point with json-pretty-print, Robert Pluim, 2019/02/01
- Re: save-excursion doesn't restore point with json-pretty-print, Eli Zaretskii, 2019/02/01
- Re: save-excursion doesn't restore point with json-pretty-print, Tassilo Horn, 2019/02/01
- Re: save-excursion doesn't restore point with json-pretty-print, Eli Zaretskii, 2019/02/01
- Re: save-excursion doesn't restore point with json-pretty-print, Tassilo Horn, 2019/02/01
- Re: save-excursion doesn't restore point with json-pretty-print, Tassilo Horn, 2019/02/01
- Re: save-excursion doesn't restore point with json-pretty-print, Eli Zaretskii, 2019/02/01
- Re: save-excursion doesn't restore point with json-pretty-print, Tassilo Horn, 2019/02/01