help-gnu-emacs
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: save-excursion doesn't restore point with json-pretty-print


From: Robert Pluim
Subject: Re: save-excursion doesn't restore point with json-pretty-print
Date: Fri, 01 Feb 2019 11:33:23 +0100

Eli Zaretskii <eliz@gnu.org> writes:

>> Date: Fri, 1 Feb 2019 10:55:16 +0100
>> From: <tomas@tuxteam.de>
>> 
>> 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.
>
> Yes, erasing the buffer makes all the markers point to BOB, and then
> save-excursion won't work as expected.
>
> Perhaps json-pretty-print could use the new replace-buffer-contents
> function?  Although I'm not sure this will cure the problem, at least
> not in all cases.

replace-buffer-contents would be a lot easier to use in this context
if it could take a string. Otherwise you have to create a buffer,
select it, insert a string, then pass that buffer to
replace-buffer-contents, delete the buffer.

Robert



reply via email to

[Prev in Thread] Current Thread [Next in Thread]