GNU bug report logs - #4655
23.1.50; buffer-swap-text oddity

Previous Next

Package: emacs;

Reported by: Markus Rost <rost <at> math.uni-bielefeld.de>

Date: Tue, 6 Oct 2009 18:55:07 UTC

Severity: minor

Tags: patch

Done: npostavs <at> users.sourceforge.net

Bug is archived. No further changes may be made.

Full log


Message #43 received at 4655 <at> debbugs.gnu.org (full text, mbox):

From: npostavs <at> users.sourceforge.net
To: Lars Magne Ingebrigtsen <larsi <at> gnus.org>
Cc: Markus Rost <rost <at> math.uni-bielefeld.de>,
 Juanma Barranquero <lekktu <at> gmail.com>, 4655 <at> debbugs.gnu.org,
 Stefan Monnier <monnier <at> iro.umontreal.ca>
Subject: Re: bug#4655: 23.1.50; buffer-swap-text oddity
Date: Sun, 10 Jul 2016 21:58:36 -0400
[Message part 1 (text/plain, inline)]
tags 4655 patch
quit

Lars Magne Ingebrigtsen <larsi <at> gnus.org> writes:

> Stefan Monnier <monnier <at> iro.umontreal.ca> writes:
>
>>>> 2- save-excursion saves the "position and current buffer" as a marker.
>>>> Combine 1 and 2 together, and you'll see that save-excursion ends up
>>>> changing the current buffer.
>>
>>> Oops. Yes, I see.
>>> Well, we could document it, but from my POV it looks more like a bug
>>> than a "feature".
>>
>> Agreed.  This said, we have a problem.
>
> Has this been fixed?  I seem to be unable to reproduce this bug in Emacs
> 24...

Reproduces for me with 23.4 up through 25.0.95.  So here's a patch to
mention it in the manual:

[v1-0001-Document-buffer-swap-text-save-excursion-interact.patch (text/x-diff, inline)]
From 7c79e2f1aef7e59d80d7b46533a93f2f23ad6759 Mon Sep 17 00:00:00 2001
From: Noam Postavsky <npostavs <at> gmail.com>
Date: Sun, 10 Jul 2016 21:52:23 -0400
Subject: [PATCH v1] Document buffer-swap-text+save-excursion interaction

* doc/lispref/buffers.texi (Swapping Text): Add warning about
interaction of `buffer-swap-text' and `save-excursion' (Bug #4655).
---
 doc/lispref/buffers.texi | 5 +++++
 1 file changed, 5 insertions(+)

diff --git a/doc/lispref/buffers.texi b/doc/lispref/buffers.texi
index 1f7f263..22c6726 100644
--- a/doc/lispref/buffers.texi
+++ b/doc/lispref/buffers.texi
@@ -1211,6 +1211,11 @@ Swapping Text
 overlays, the text properties, the undo list, the value of the
 @code{enable-multibyte-characters} flag (@pxref{Text Representations,
 enable-multibyte-characters}), etc.
+
+@strong{Warning:} The current buffer will be set to @var{buffer} if
+this function is called from within @code{save-excursion}, since the
+marker used by @code{save-excursion} to save the position and buffer
+will be swapped as well.
 @end defun
 
   If you use @code{buffer-swap-text} on a file-visiting buffer, you
-- 
2.8.0


This bug report was last modified 9 years and 28 days ago.

Previous Next


GNU bug tracking system
Copyright (C) 1999 Darren O. Benham, 1997,2003 nCipher Corporation Ltd, 1994-97 Ian Jackson.