From mboxrd@z Thu Jan 1 00:00:00 1970 Path: news.gmane.org!.POSTED!not-for-mail From: Eli Zaretskii Newsgroups: gmane.emacs.help Subject: Re: point moved despite save-excursion, after deleting/reinserting region Date: Thu, 18 Oct 2018 05:38:08 +0300 Message-ID: <83tvlkq8rz.fsf@gnu.org> References: <87r2gpic0b.fsf@portable.galex-713.eu> <835zy0sgbr.fsf@gnu.org> <87lg6w72mv.fsf@portable.galex-713.eu> NNTP-Posting-Host: blaine.gmane.org Mime-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: 8bit X-Trace: blaine.gmane.org 1539830214 23384 195.159.176.226 (18 Oct 2018 02:36:54 GMT) X-Complaints-To: usenet@blaine.gmane.org NNTP-Posting-Date: Thu, 18 Oct 2018 02:36:54 +0000 (UTC) To: help-gnu-emacs@gnu.org Original-X-From: help-gnu-emacs-bounces+geh-help-gnu-emacs=m.gmane.org@gnu.org Thu Oct 18 04:36:50 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 1gCyB8-0005yn-HF for geh-help-gnu-emacs@m.gmane.org; Thu, 18 Oct 2018 04:36:50 +0200 Original-Received: from localhost ([::1]:39916 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1gCyDF-0005Ek-0k for geh-help-gnu-emacs@m.gmane.org; Wed, 17 Oct 2018 22:39:01 -0400 Original-Received: from eggs.gnu.org ([2001:4830:134:3::10]:36836) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1gCyCr-0005EU-Mk for help-gnu-emacs@gnu.org; Wed, 17 Oct 2018 22:38:38 -0400 Original-Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1gCyCo-0008Fj-Ih for help-gnu-emacs@gnu.org; Wed, 17 Oct 2018 22:38:37 -0400 Original-Received: from fencepost.gnu.org ([2001:4830:134:3::e]:51264) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1gCyCm-0008Bw-2g for help-gnu-emacs@gnu.org; Wed, 17 Oct 2018 22:38:33 -0400 Original-Received: from [176.228.60.248] (port=4209 helo=home-c4e4a596f7) by fencepost.gnu.org with esmtpsa (TLS1.2:RSA_AES_256_CBC_SHA1:256) (Exim 4.82) (envelope-from ) id 1gCyCi-0005rj-HU for help-gnu-emacs@gnu.org; Wed, 17 Oct 2018 22:38:30 -0400 In-reply-to: <87lg6w72mv.fsf@portable.galex-713.eu> X-detected-operating-system: by eggs.gnu.org: GNU/Linux 2.2.x-3.x [generic] X-Received-From: 2001:4830:134:3::e 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:118316 Archived-At: > From: "Garreau\, Alexandre" > Cc: help-gnu-emacs@gnu.org > Date: Wed, 17 Oct 2018 22:13:28 +0200 > > The point was, say, in the middle of the SRC block, and (as I said in > the subject) after the operation, was moved: at the end of the block. > > This must be because I deleted a region of text (the whole SRC block) > then reinserted it (or rather, its original content, so that to restore > buffer as before), so the point is after the insertion. > > However, I’d have expected save-excursion to put the point again where > it was inside the block. If that's what you want, why not record the position of point before the delete/insert operation and restore it afterwards? > 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?