From mboxrd@z Thu Jan 1 00:00:00 1970 Path: news.gmane.org!.POSTED.blaine.gmane.org!not-for-mail From: Newsgroups: gmane.emacs.help Subject: Re: save-excursion doesn't restore point with json-pretty-print Date: Fri, 1 Feb 2019 10:55:16 +0100 Message-ID: <20190201095516.GB19478@tuxteam.de> References: <87lg2z7t23.fsf@gnu.org> Mime-Version: 1.0 Content-Type: multipart/signed; micalg=pgp-sha1; protocol="application/pgp-signature"; boundary="yEPQxsgoJgBvi8ip" Injection-Info: blaine.gmane.org; posting-host="blaine.gmane.org:195.159.176.226"; logging-data="81827"; mail-complaints-to="usenet@blaine.gmane.org" User-Agent: Mutt/1.5.21 (2010-09-15) To: help-gnu-emacs@gnu.org Original-X-From: help-gnu-emacs-bounces+geh-help-gnu-emacs=m.gmane.org@gnu.org Fri Feb 01 10:56:11 2019 Return-path: Envelope-to: geh-help-gnu-emacs@m.gmane.org Original-Received: from lists.gnu.org ([209.51.188.17]) by blaine.gmane.org with esmtps (TLS1.0:RSA_AES_256_CBC_SHA1:256) (Exim 4.89) (envelope-from ) id 1gpVYQ-000LAF-2i for geh-help-gnu-emacs@m.gmane.org; Fri, 01 Feb 2019 10:56:10 +0100 Original-Received: from localhost ([127.0.0.1]:41549 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1gpVYP-0003y5-1h for geh-help-gnu-emacs@m.gmane.org; Fri, 01 Feb 2019 04:56:09 -0500 Original-Received: from eggs.gnu.org ([209.51.188.92]:56983) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1gpVXh-0003wr-5B for help-gnu-emacs@gnu.org; Fri, 01 Feb 2019 04:55:25 -0500 Original-Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1gpVXb-0006Jv-W5 for help-gnu-emacs@gnu.org; Fri, 01 Feb 2019 04:55:23 -0500 Original-Received: from mail.tuxteam.de ([5.199.139.25]:52247) by eggs.gnu.org with esmtps (TLS1.0:DHE_RSA_AES_128_CBC_SHA1:16) (Exim 4.71) (envelope-from ) id 1gpVXb-0006IX-DM for help-gnu-emacs@gnu.org; Fri, 01 Feb 2019 04:55:19 -0500 DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=tuxteam.de; s=mail; h=From:In-Reply-To:Content-Type:MIME-Version:References:Message-ID:Subject:To:Date; bh=qMn5hZCDUOXTKiNYfUBXg69d3jkC3o7wD6P6a7MG2dY=; b=CorDw051VYbPrQI3YiU6lNC8qZgHBUkNHDzUexfkOayEG0Hi2ScJFHPUHwY0kxMwZW/BPZ7QObVlPOGi8w6IK4N/Sy5xC7J8IQBhYpqPBoMt/QMMcM9uAPSjlh1XQoaSo0Cipim1/cGDgXXkCJwC5eJspOCGh/KFzz1reiVgnP2LAwiEVInLpxNZde5U0rhByF8mEA7WK4NwkZajfYkTNpAu2JtjyDqf/5bppVItZEi3hdRx8hOCN/O0WZNdYpfPy7uY9GsTiEYFQ4lJUjD9D6wKvcI/McmCzOs5pggTK94ryi32qQUS6PnigVydIe5GDNLBSG2nNvnJWRSUe/dCJQ==; Original-Received: from tomas by mail.tuxteam.de with local (Exim 4.80) (envelope-from ) id 1gpVXY-0005YH-CP for help-gnu-emacs@gnu.org; Fri, 01 Feb 2019 10:55:16 +0100 Content-Disposition: inline In-Reply-To: <87lg2z7t23.fsf@gnu.org> X-detected-operating-system: by eggs.gnu.org: GNU/Linux 3.x X-Received-From: 5.199.139.25 X-BeenThere: help-gnu-emacs@gnu.org X-Mailman-Version: 2.1.21 Precedence: list List-Id: Users list for the GNU Emacs text editor List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: help-gnu-emacs-bounces+geh-help-gnu-emacs=m.gmane.org@gnu.org Original-Sender: "help-gnu-emacs" Xref: news.gmane.org gmane.emacs.help:119186 Archived-At: --yEPQxsgoJgBvi8ip Content-Type: text/plain; charset=utf-8 Content-Disposition: inline Content-Transfer-Encoding: quoted-printable On Fri, Feb 01, 2019 at 10:32:20AM +0100, Tassilo Horn wrote: > Hi all, >=20 > I have this small command in my ~/.emacs: [...] > For example, when point is on the 1 below, >=20 > {"foo": 1, "bar":27} >=20 > I'll end up with >=20 > { > "foo": 1, > "bar": 27 > } >=20 > and point is on the {. I'd expect it to still sit on the 1. >=20 > 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=C3=A1s --yEPQxsgoJgBvi8ip Content-Type: application/pgp-signature; name="signature.asc" Content-Description: Digital signature -----BEGIN PGP SIGNATURE----- Version: GnuPG v1.4.12 (GNU/Linux) iEYEARECAAYFAlxUF4QACgkQBcgs9XrR2kb05ACfW5ePpPmDyRM/3BR2BFeMa8Sj mWcAnR/bjw8itnmYOTfrZHQbwLoBRy4r =gDDt -----END PGP SIGNATURE----- --yEPQxsgoJgBvi8ip--