From mboxrd@z Thu Jan 1 00:00:00 1970 Path: news.gmane.org!not-for-mail From: npostavs@users.sourceforge.net Newsgroups: gmane.emacs.bugs Subject: bug#4655: 23.1.50; buffer-swap-text oddity Date: Wed, 13 Jul 2016 19:50:49 -0400 Message-ID: <87a8hlf67a.fsf@users.sourceforge.net> 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> NNTP-Posting-Host: plane.gmane.org Mime-Version: 1.0 Content-Type: multipart/mixed; boundary="=-=-=" X-Trace: ger.gmane.org 1468453894 27635 80.91.229.3 (13 Jul 2016 23:51:34 GMT) X-Complaints-To: usenet@ger.gmane.org NNTP-Posting-Date: Wed, 13 Jul 2016 23:51:34 +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: Eli Zaretskii Original-X-From: bug-gnu-emacs-bounces+geb-bug-gnu-emacs=m.gmane.org@gnu.org Thu Jul 14 01:51:16 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 1bNTvv-0004Sn-Dc for geb-bug-gnu-emacs@m.gmane.org; Thu, 14 Jul 2016 01:51:15 +0200 Original-Received: from localhost ([::1]:50588 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1bNTvu-0001vC-EL for geb-bug-gnu-emacs@m.gmane.org; Wed, 13 Jul 2016 19:51:14 -0400 Original-Received: from eggs.gnu.org ([2001:4830:134:3::10]:60363) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1bNTvl-0001uv-DA for bug-gnu-emacs@gnu.org; Wed, 13 Jul 2016 19:51:06 -0400 Original-Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1bNTvi-0006uT-7T for bug-gnu-emacs@gnu.org; Wed, 13 Jul 2016 19:51:05 -0400 Original-Received: from debbugs.gnu.org ([208.118.235.43]:37989) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1bNTvi-0006uP-4L for bug-gnu-emacs@gnu.org; Wed, 13 Jul 2016 19:51:02 -0400 Original-Received: from Debian-debbugs by debbugs.gnu.org with local (Exim 4.84_2) (envelope-from ) id 1bNTvh-0004ww-W0 for bug-gnu-emacs@gnu.org; Wed, 13 Jul 2016 19:51:02 -0400 X-Loop: help-debbugs@gnu.org Resent-From: npostavs@users.sourceforge.net Original-Sender: "Debbugs-submit" Resent-CC: bug-gnu-emacs@gnu.org Resent-Date: Wed, 13 Jul 2016 23:51: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.146845385919016 (code B ref 4655); Wed, 13 Jul 2016 23:51:01 +0000 Original-Received: (at 4655) by debbugs.gnu.org; 13 Jul 2016 23:50:59 +0000 Original-Received: from localhost ([127.0.0.1]:50326 helo=debbugs.gnu.org) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1bNTvf-0004we-8u for submit@debbugs.gnu.org; Wed, 13 Jul 2016 19:50:59 -0400 Original-Received: from mail-it0-f51.google.com ([209.85.214.51]:34963) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1bNTvd-0004wS-H0 for 4655@debbugs.gnu.org; Wed, 13 Jul 2016 19:50:57 -0400 Original-Received: by mail-it0-f51.google.com with SMTP id u186so34664796ita.0 for <4655@debbugs.gnu.org>; Wed, 13 Jul 2016 16:50:57 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20120113; h=sender:from:to:cc:subject:references:date:in-reply-to:message-id :user-agent:mime-version; bh=ZDrAL+1k+CYqaVVhWtHQWbh9oPQJKKEP98dBlXDb1UE=; b=nu8MY5VeVBnx8Ef0IyKX8Dd6KEchcdUd7fSOsYO/ySPuaG/EPQj0xH15TFklcnXsqr jyqdhLF8hLxMF5l3oaRYZynCO10m3xxukKhUQae88SH1WhFcBEKCM050bWnkfTpJOlWG QPHBaHxa3LbJoZU7PU8EcXCHH0gmmhMz0C/PTvwNvphAKynzTbquOXl6B8DrVfu9Oo2h GI3WgkUz0RYnpCxOEcPCiw8/ijuZjRfEDb9IlK3fTDgz8ACymC6l62UXLXfsmBucahDv 1lPqAZ3YSFVHrjPGi7E4BfrxdbIonNYKrkpCmJc6sknLDjQMU6LkkJho48+S0fWQfsnf +acA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20130820; h=x-gm-message-state:sender:from:to:cc:subject:references:date :in-reply-to:message-id:user-agent:mime-version; bh=ZDrAL+1k+CYqaVVhWtHQWbh9oPQJKKEP98dBlXDb1UE=; b=c/plzXOjlcvoJbHTzstzALW1c6T5qgw/5liUvvDizbArftn7wz3GBii8po7WvES8mA 6yNu5ELoBacRXn/tZ+pKp5psHWdAuegOJZJrjNXMlxKV9Neowhke4DDPwN/miYBzl5cV fUvk/vc09t1vCvonE1ZzkzXZ8r82SebSQVBj20GQj5+qmvR+svynAQyDiuoQDJd+EGXW 43ND6mnE+mLznO1KR9Xdd8G/IPSzbkkCB27+SJieUMNOYZn+YvBFAqz6F361F7yh06Xp fOhV/P9BgsFzUXMf1hBL97O9TaiYFGwBN/AYKxFL2cQVM68iAQdIrETdC/OLFWdwGQU0 ++Rg== X-Gm-Message-State: ALyK8tIurdz9AcESGliO6+nFtci5XOYlEnffGjA9r3tOujrG6+G45rkPJKd3cny4kwp1mw== X-Received: by 10.36.37.146 with SMTP id g140mr11522854itg.58.1468453851971; Wed, 13 Jul 2016 16:50:51 -0700 (PDT) Original-Received: from zony (206-188-64-44.cpe.distributel.net. [206.188.64.44]) by smtp.googlemail.com with ESMTPSA id s84sm3169991ioe.39.2016.07.13.16.50.50 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Wed, 13 Jul 2016 16:50:51 -0700 (PDT) In-Reply-To: <83zipnbflj.fsf@gnu.org> (Eli Zaretskii's message of "Tue, 12 Jul 2016 08:16:56 +0300") User-Agent: Gnus/5.13 (Gnus v5.13) Emacs/25.0.93 (gnu/linux) 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:121045 Archived-At: --=-=-= Content-Type: text/plain Eli Zaretskii writes: > Yes, something like "upon return from this form ...". I think it's a > good idea. > > Otherwise the text is good, IMO. Okay, here is my final version, I will push tomorrow. --=-=-= Content-Type: text/x-diff Content-Disposition: inline; filename=v3-0001-Document-buffer-swap-text-save-excursion-interact.patch Content-Description: patch-v3 >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 --=-=-=--