all messages for Emacs-related lists mirrored at yhetil.org
 help / color / mirror / code / Atom feed
From: npostavs@users.sourceforge.net
To: Dmitry Gutov <dgutov@yandex.ru>
Cc: lekktu@gmail.com, monnier@iro.umontreal.ca,
	Markus Rost <rost@math.uni-bielefeld.de>,
	4655@debbugs.gnu.org, larsi@gnus.org
Subject: bug#4655: 23.1.50; buffer-swap-text oddity
Date: Mon, 11 Jul 2016 21:58:59 -0400	[thread overview]
Message-ID: <87lh17fwgs.fsf@users.sourceforge.net> (raw)
In-Reply-To: <a12506cf-ded0-28f7-7297-d107f0bf3990@yandex.ru> (Dmitry Gutov's message of "Mon, 11 Jul 2016 22:07:42 +0300")

[-- Attachment #1: Type: text/plain, Size: 281 bytes --]

Dmitry Gutov <dgutov@yandex.ru> writes:

> On 07/11/2016 09:50 PM, Markus Rost wrote:
>>> please push to emacs-25.

I'm thinking also to tweak the wording a bit to make it clear that the
buffer change happens at the end of the save-excursion, not when
buffer-swap-text is called.


[-- Warning: decoded text below may be mangled, UTF-8 assumed --]
[-- Attachment #2: patch-v2 --]
[-- Type: text/x-diff, Size: 1783 bytes --]

From 3c66c6f163e72da7b8f5d40dab7cb2655faddf47 Mon Sep 17 00:00:00 2001
From: Noam Postavsky <npostavs@gmail.com>
Date: Sun, 10 Jul 2016 21:52:23 -0400
Subject: [PATCH v2] 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 | 5 +++++
 src/buffer.c             | 4 +++-
 2 files changed, 8 insertions(+), 1 deletion(-)

diff --git a/doc/lispref/buffers.texi b/doc/lispref/buffers.texi
index 1f7f263..e10c2b3 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:} If called from within @code{save-excursion}, this
+function will set the saved buffer to @var{buffer}, 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


[-- Attachment #3: Type: text/plain, Size: 462 bytes --]



>>
>> Oh, I am still using
>>
>> GNU Emacs 22.3.5 (x86_64-unknown-linux-gnu, GTK+ Version 2.24.23) of 2015-11-14 on euclid
>
> Sorry, you'll have to upgrade to Emacs 25 when it comes out, to see
> this fixed. Emacs 24 and earlier are not supported anymore.

To be clear, the particular behaviour that prompted this bug report will
not be fixed/changed, I'm just documenting it (obviously there are a lot
of other changes and improvements between 22.3 and 25).

  reply	other threads:[~2016-07-12  1:58 UTC|newest]

Thread overview: 32+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
     [not found] <jwv3a2eiia3.fsf-monnier+emacs@gnu.org>
2009-10-06 18:46 ` bug#4655: 23.1.50; buffer-swap-text oddity Markus Rost
2009-10-07  4:01   ` Juanma Barranquero
2009-10-07  5:41     ` Stefan Monnier
2009-10-07  8:53       ` Markus Rost
2009-10-07 10:07       ` Juanma Barranquero
2009-10-07 14:29         ` Stefan Monnier
2009-10-08 16:48           ` Markus Rost
2011-07-13 14:08           ` Lars Magne Ingebrigtsen
2016-07-11  1:58             ` npostavs
2016-07-11 14:37               ` Eli Zaretskii
2016-07-11 18:50                 ` Markus Rost
2016-07-11 19:07                   ` Dmitry Gutov
2016-07-12  1:58                     ` npostavs [this message]
2016-07-12  5:16                       ` Eli Zaretskii
2016-07-13 23:50                         ` npostavs
2016-07-14 15:03                           ` Eli Zaretskii
2016-07-15  0:05                             ` npostavs
2010-01-10  7:36   ` bug#5273: marked as done (23.1; format-alist encode vs write-region-post-annotation-function) Emacs bug Tracking System
2010-01-13  0:45   ` bug#5256: marked as done (conjunct formation should follow input sequence when inserting text) Emacs bug Tracking System
2010-01-13  0:49   ` bug#5265: marked as done (23.1.90; vc - can't reread redirected stdin for log message) Emacs bug Tracking System
2010-01-14  1:22   ` bug#5276: marked as done (23.1; Doc string of bookmark-bmenu-execute-deletions) Emacs bug Tracking System
2010-01-16 20:05   ` bug#5267: 23.1; doc string of defstruct Chong Yidong
2010-01-16 21:39   ` bug#5279: 23.1; VC: should set LC_MESSAGES to C (with patch) Chong Yidong
2010-05-13 19:20   ` bug#5284: 23.1; gnus-summary-expire-thread does not work Glenn Morris
2010-05-24 19:53   ` bug#5270: [PATCH] * lisp/image-dired.el (image-dired-dired-insert-marked-thumbs) Insert thumbnails before file names of marked files in the dired buffer Thierry Volpiatto
2010-05-25 15:49     ` Juri Linkov
2010-05-25 16:59       ` Thierry Volpiatto
2010-05-25 17:46         ` Juri Linkov
2010-06-30 20:35   ` bug#5281: 23.1; xml-parse-region causes infinite loops if the region is not well-formed XML Chong Yidong
2009-12-29 18:19 bug#5284: 23.1; gnus-summary-expire-thread does not work Tom Tromey
2010-05-11  6:04 ` Andreas Seltenreich
     [not found]   ` <mailman.7.1273778942.8369.bug-gnu-emacs@gnu.org>
2010-06-30 21:35     ` Ted Zlatanov

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=87lh17fwgs.fsf@users.sourceforge.net \
    --to=npostavs@users.sourceforge.net \
    --cc=4655@debbugs.gnu.org \
    --cc=dgutov@yandex.ru \
    --cc=larsi@gnus.org \
    --cc=lekktu@gmail.com \
    --cc=monnier@iro.umontreal.ca \
    --cc=rost@math.uni-bielefeld.de \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
Code repositories for project(s) associated with this external index

	https://git.savannah.gnu.org/cgit/emacs.git
	https://git.savannah.gnu.org/cgit/emacs/org-mode.git

This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.