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


View this message in rfc822 format

From: Eli Zaretskii <eliz <at> gnu.org>
To: npostavs <at> users.sourceforge.net
Cc: lekktu <at> gmail.com, monnier <at> iro.umontreal.ca, dgutov <at> yandex.ru, rost <at> math.uni-bielefeld.de, 4655 <at> debbugs.gnu.org, larsi <at> gnus.org
Subject: bug#4655: 23.1.50; buffer-swap-text oddity
Date: Thu, 14 Jul 2016 18:03:27 +0300
> From: npostavs <at> users.sourceforge.net
> Cc: 4655 <at> debbugs.gnu.org,  lekktu <at> gmail.com,  monnier <at> iro.umontreal.ca,  dgutov <at> yandex.ru,  rost <at> math.uni-bielefeld.de,  larsi <at> gnus.org
> Date: Wed, 13 Jul 2016 19:50:49 -0400
> 
> Okay, here is my final version, I will push tomorrow.
> 
> >From f0295dbfceb3264f93d583537ff184b63779adea 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 v3] Document buffer-swap-text+save-excursion interaction
> 
> * doc/lispref/buffers.texi (Swapping Text):
> * src/buffer.c (Fbuffer_swap_text): Add warning about interaction of
> `buffer-swap-text' and `save-excursion' (Bug #4655).
> ---
>  doc/lispref/buffers.texi | 6 ++++++
>  src/buffer.c             | 4 +++-
>  2 files changed, 9 insertions(+), 1 deletion(-)
> 
> diff --git a/doc/lispref/buffers.texi b/doc/lispref/buffers.texi
> index 1f7f263..740d7cf 100644
> --- a/doc/lispref/buffers.texi
> +++ b/doc/lispref/buffers.texi
> @@ -1211,6 +1211,12 @@ 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:} If this function is called from within a
> +@code{save-excursion} form, the current buffer will be set to
> +@var{buffer} upon leaving the form, 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
> diff --git a/src/buffer.c b/src/buffer.c
> index e4269c0..89f4479 100644
> --- a/src/buffer.c
> +++ b/src/buffer.c
> @@ -2231,7 +2231,9 @@ advance_to_char_boundary (ptrdiff_t byte_pos)
>  
>  DEFUN ("buffer-swap-text", Fbuffer_swap_text, Sbuffer_swap_text,
>         1, 1, 0,
> -       doc: /* Swap the text between current buffer and BUFFER.  */)
> +       doc: /* Swap the text between current buffer and BUFFER.
> +Using this function from `save-excursion' might produce surprising
> +results, see Info node `(elisp)Swapping Text'.  */)
>    (Lisp_Object buffer)
>  {
>    struct buffer *other_buffer;
> -- 
> 2.8.0

Thanks, looks good.




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.