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