From mboxrd@z Thu Jan 1 00:00:00 1970 Path: news.gmane.org!.POSTED!not-for-mail From: "Garreau\, Alexandre" Newsgroups: gmane.emacs.help Subject: Re: point moved despite save-excursion, after deleting/reinserting region Date: Thu, 18 Oct 2018 11:50:40 +0200 Message-ID: <87efcnziq7.fsf@portable.galex-713.eu> References: <87r2gpic0b.fsf@portable.galex-713.eu> <835zy0sgbr.fsf@gnu.org> <87lg6w72mv.fsf@portable.galex-713.eu> <83tvlkq8rz.fsf@gnu.org> NNTP-Posting-Host: blaine.gmane.org Mime-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: quoted-printable X-Trace: blaine.gmane.org 1539856152 10097 195.159.176.226 (18 Oct 2018 09:49:12 GMT) X-Complaints-To: usenet@blaine.gmane.org NNTP-Posting-Date: Thu, 18 Oct 2018 09:49:12 +0000 (UTC) User-Agent: Gnus (5.13), GNU Emacs 25.1.1 (i686-pc-linux-gnu) Cc: help-gnu-emacs@gnu.org To: Eli Zaretskii Original-X-From: help-gnu-emacs-bounces+geh-help-gnu-emacs=m.gmane.org@gnu.org Thu Oct 18 11:49:08 2018 Return-path: Envelope-to: geh-help-gnu-emacs@m.gmane.org Original-Received: from lists.gnu.org ([208.118.235.17]) by blaine.gmane.org with esmtp (Exim 4.84_2) (envelope-from ) id 1gD4vU-0002X9-Fd for geh-help-gnu-emacs@m.gmane.org; Thu, 18 Oct 2018 11:49:08 +0200 Original-Received: from localhost ([::1]:41319 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1gD4xa-0005qs-Pb for geh-help-gnu-emacs@m.gmane.org; Thu, 18 Oct 2018 05:51:18 -0400 Original-Received: from eggs.gnu.org ([2001:4830:134:3::10]:45053) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1gD4x1-0005qS-Uv for help-gnu-emacs@gnu.org; Thu, 18 Oct 2018 05:50:44 -0400 Original-Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1gD4x1-00005Z-5Z for help-gnu-emacs@gnu.org; Thu, 18 Oct 2018 05:50:43 -0400 Original-Received: from portable.galex-713.eu ([2a00:5884:8305::1]:57588) by eggs.gnu.org with esmtps (TLS1.0:RSA_AES_256_CBC_SHA1:32) (Exim 4.71) (envelope-from ) id 1gD4x0-0008WE-T2; Thu, 18 Oct 2018 05:50:43 -0400 Original-Received: from localhost ([::1] helo=portable.galex-713.eu) by portable.galex-713.eu with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.89) (envelope-from ) id 1gD4wy-0000J3-8n; Thu, 18 Oct 2018 11:50:40 +0200 X-GPG-FINGERPRINT: E109 9988 4197 D7CB B0BC 5C23 8DEB 24BA 867D 3F7F X-Accept-Language: fr, en, it, eo In-Reply-To: <83tvlkq8rz.fsf@gnu.org> (Eli Zaretskii's message of "Thu, 18 Oct 2018 05:38:08 +0300") X-detected-operating-system: by eggs.gnu.org: Genre and OS details not recognized. X-Received-From: 2a00:5884:8305::1 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:118319 Archived-At: On 2018-10-18 at 05:38, Eli Zaretskii wrote: >> Is there something such as `restore-markers'/`save-markers' that would >> allow me to restore point after doing this operation? Or better some >> `save-buffer-content' like `save-excursion' but restoring the buffer >> afterwards? > > When you delete text, markers pointing into that text cannot follow, > they get relocated to the beginning/end of the deletion/insertion. > What else can Emacs do, given that it doesn't know your future > intentions? I thought something such as `save-excursion' would do that, or that it would be saved with the string, or something alike. > If that's what you want, why not record the position of point before > the delete/insert operation and restore it afterwards? So is that the canonical way of doing? that feels like defeating the purpose of `save-excursion' a little bit (I only wanted to produce a result for this src-block), and as this is more complex behavior than just =E2=80=9Cundoing backward=E2=80=9D or anything part of core elisp, I f= eared side-effects I wouldn=E2=80=99t be aware of: for instance tho, it means my function will have the side-effects of moving all the markers (and maybe other similar things) that were inside that portion of text: it feels somewhat hardly like =E2=80=9Crestoring as before=E2=80=9D.