[Top][All Lists]

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

bug#4655: 23.1.50; buffer-swap-text oddity

From: npostavs
Subject: bug#4655: 23.1.50; buffer-swap-text oddity
Date: Sun, 10 Jul 2016 21:58:36 -0400
User-agent: Gnus/5.13 (Gnus v5.13) Emacs/25.0.93 (gnu/linux)

tags 4655 patch

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

> Stefan Monnier <monnier@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:

>From 7c79e2f1aef7e59d80d7b46533a93f2f23ad6759 Mon Sep 17 00:00:00 2001
From: Noam Postavsky <npostavs@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

reply via email to

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