From mboxrd@z Thu Jan 1 00:00:00 1970 Path: news.gmane.org!not-for-mail From: Eli Zaretskii Newsgroups: gmane.emacs.bugs Subject: bug#4655: 23.1.50; buffer-swap-text oddity Date: Thu, 14 Jul 2016 18:03:27 +0300 Message-ID: <83d1mg8dog.fsf@gnu.org> References: <20091006184604.9A5B2EFE6F@sonic02.math.uni-bielefeld.de> <874m7xgckz.fsf@users.sourceforge.net> <83y458ckbl.fsf@gnu.org> <20160711185035.56B9240619@ssh.math.uni-bielefeld.de> <87lh17fwgs.fsf@users.sourceforge.net> <83zipnbflj.fsf@gnu.org> <87a8hlf67a.fsf@users.sourceforge.net> Reply-To: Eli Zaretskii NNTP-Posting-Host: plane.gmane.org X-Trace: ger.gmane.org 1468509515 6293 80.91.229.3 (14 Jul 2016 15:18:35 GMT) X-Complaints-To: usenet@ger.gmane.org NNTP-Posting-Date: Thu, 14 Jul 2016 15:18:35 +0000 (UTC) Cc: lekktu@gmail.com, monnier@iro.umontreal.ca, dgutov@yandex.ru, rost@math.uni-bielefeld.de, 4655@debbugs.gnu.org, larsi@gnus.org To: npostavs@users.sourceforge.net Original-X-From: bug-gnu-emacs-bounces+geb-bug-gnu-emacs=m.gmane.org@gnu.org Thu Jul 14 17:18:24 2016 Return-path: Envelope-to: geb-bug-gnu-emacs@m.gmane.org Original-Received: from lists.gnu.org ([208.118.235.17]) by plane.gmane.org with esmtp (Exim 4.69) (envelope-from ) id 1bNiP1-0008CU-70 for geb-bug-gnu-emacs@m.gmane.org; Thu, 14 Jul 2016 17:18:15 +0200 Original-Received: from localhost ([::1]:54747 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1bNiP0-0000iR-5C for geb-bug-gnu-emacs@m.gmane.org; Thu, 14 Jul 2016 11:18:14 -0400 Original-Received: from eggs.gnu.org ([2001:4830:134:3::10]:49798) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1bNiCI-0001mW-Hq for bug-gnu-emacs@gnu.org; Thu, 14 Jul 2016 11:05:10 -0400 Original-Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1bNiCD-00053Z-Tf for bug-gnu-emacs@gnu.org; Thu, 14 Jul 2016 11:05:05 -0400 Original-Received: from debbugs.gnu.org ([208.118.235.43]:39231) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1bNiCD-00053U-QT for bug-gnu-emacs@gnu.org; Thu, 14 Jul 2016 11:05:01 -0400 Original-Received: from Debian-debbugs by debbugs.gnu.org with local (Exim 4.84_2) (envelope-from ) id 1bNiCD-0003Il-JT for bug-gnu-emacs@gnu.org; Thu, 14 Jul 2016 11:05:01 -0400 X-Loop: help-debbugs@gnu.org Resent-From: Eli Zaretskii Original-Sender: "Debbugs-submit" Resent-CC: bug-gnu-emacs@gnu.org Resent-Date: Thu, 14 Jul 2016 15:05:01 +0000 Resent-Message-ID: Resent-Sender: help-debbugs@gnu.org X-GNU-PR-Message: followup 4655 X-GNU-PR-Package: emacs X-GNU-PR-Keywords: patch Original-Received: via spool by 4655-submit@debbugs.gnu.org id=B4655.146850869612676 (code B ref 4655); Thu, 14 Jul 2016 15:05:01 +0000 Original-Received: (at 4655) by debbugs.gnu.org; 14 Jul 2016 15:04:56 +0000 Original-Received: from localhost ([127.0.0.1]:51568 helo=debbugs.gnu.org) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1bNiC4-0003IJ-D7 for submit@debbugs.gnu.org; Thu, 14 Jul 2016 11:04:56 -0400 Original-Received: from eggs.gnu.org ([208.118.235.92]:58490) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1bNiBz-0003I3-QT for 4655@debbugs.gnu.org; Thu, 14 Jul 2016 11:04:51 -0400 Original-Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1bNiBo-0004tm-UO for 4655@debbugs.gnu.org; Thu, 14 Jul 2016 11:04:42 -0400 Original-Received: from fencepost.gnu.org ([2001:4830:134:3::e]:44620) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1bNiAu-0004cd-Qp; Thu, 14 Jul 2016 11:03:40 -0400 Original-Received: from 84.94.185.246.cable.012.net.il ([84.94.185.246]:1756 helo=home-c4e4a596f7) by fencepost.gnu.org with esmtpsa (TLS1.2:RSA_AES_128_CBC_SHA1:128) (Exim 4.82) (envelope-from ) id 1bNiAt-0003ak-Fu; Thu, 14 Jul 2016 11:03:40 -0400 In-reply-to: <87a8hlf67a.fsf@users.sourceforge.net> (npostavs@users.sourceforge.net) X-detected-operating-system: by eggs.gnu.org: GNU/Linux 2.2.x-3.x [generic] X-BeenThere: debbugs-submit@debbugs.gnu.org X-Mailman-Version: 2.1.18 Precedence: list X-detected-operating-system: by eggs.gnu.org: GNU/Linux 2.2.x-3.x [generic] X-Received-From: 208.118.235.43 X-BeenThere: bug-gnu-emacs@gnu.org List-Id: "Bug reports for GNU Emacs, the Swiss army knife of text editors" List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: bug-gnu-emacs-bounces+geb-bug-gnu-emacs=m.gmane.org@gnu.org Original-Sender: "bug-gnu-emacs" Xref: news.gmane.org gmane.emacs.bugs:121070 Archived-At: > From: npostavs@users.sourceforge.net > Cc: 4655@debbugs.gnu.org, lekktu@gmail.com, monnier@iro.umontreal.ca, dgutov@yandex.ru, rost@math.uni-bielefeld.de, larsi@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 > 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.