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: Mon, 11 Jul 2016 21:58:59 -0400 Message-ID: <87lh17fwgs.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> NNTP-Posting-Host: plane.gmane.org Mime-Version: 1.0 Content-Type: multipart/mixed; boundary="=-=-=" X-Trace: ger.gmane.org 1468288829 330 80.91.229.3 (12 Jul 2016 02:00:29 GMT) X-Complaints-To: usenet@ger.gmane.org NNTP-Posting-Date: Tue, 12 Jul 2016 02:00:29 +0000 (UTC) Cc: lekktu@gmail.com, monnier@iro.umontreal.ca, Markus Rost , 4655@debbugs.gnu.org, larsi@gnus.org To: Dmitry Gutov Original-X-From: bug-gnu-emacs-bounces+geb-bug-gnu-emacs=m.gmane.org@gnu.org Tue Jul 12 04:00:17 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 1bMmzh-0002N3-4V for geb-bug-gnu-emacs@m.gmane.org; Tue, 12 Jul 2016 04:00:17 +0200 Original-Received: from localhost ([::1]:36969 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1bMmzg-0000gn-8o for geb-bug-gnu-emacs@m.gmane.org; Mon, 11 Jul 2016 22:00:16 -0400 Original-Received: from eggs.gnu.org ([2001:4830:134:3::10]:59432) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1bMmza-0000dd-M7 for bug-gnu-emacs@gnu.org; Mon, 11 Jul 2016 22:00:11 -0400 Original-Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1bMmzT-00054P-6f for bug-gnu-emacs@gnu.org; Mon, 11 Jul 2016 22:00:09 -0400 Original-Received: from debbugs.gnu.org ([208.118.235.43]:35067) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1bMmzT-00054K-2e for bug-gnu-emacs@gnu.org; Mon, 11 Jul 2016 22:00:03 -0400 Original-Received: from Debian-debbugs by debbugs.gnu.org with local (Exim 4.84_2) (envelope-from ) id 1bMmzS-0007jG-Pe for bug-gnu-emacs@gnu.org; Mon, 11 Jul 2016 22:00: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: Tue, 12 Jul 2016 02:00:02 +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.146828874929623 (code B ref 4655); Tue, 12 Jul 2016 02:00:02 +0000 Original-Received: (at 4655) by debbugs.gnu.org; 12 Jul 2016 01:59:09 +0000 Original-Received: from localhost ([127.0.0.1]:47404 helo=debbugs.gnu.org) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1bMmyb-0007hi-5p for submit@debbugs.gnu.org; Mon, 11 Jul 2016 21:59:09 -0400 Original-Received: from mail-io0-f176.google.com ([209.85.223.176]:35751) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1bMmyZ-0007hU-Jb for 4655@debbugs.gnu.org; Mon, 11 Jul 2016 21:59:07 -0400 Original-Received: by mail-io0-f176.google.com with SMTP id m101so4127588ioi.2 for <4655@debbugs.gnu.org>; Mon, 11 Jul 2016 18:59:07 -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=8zDsDLfgQ0jddouO/aur8KY5HvrNJVtqqk9hCxCcOX0=; b=CiRrqpzJef6bhFLYTFoPohHgKj4feUNSrmQh5lfsaiXOrrpr/NRzuU5+DGxdm0/phO hyjTFmdR3qkyyDPPmBgIxKN/MZax36eGYsPG1I20GKr+OwA7nYh72ke74NNgmuvH29tX iLy9FF03Mv9HRAImp+BE9C7rRCRtD9YnFgYUAzMTXW7qyQGt6bpbKVlr90UwHfwKpkiE 5rMAhctcZyw7EXRMSje9ZCb/bgb6vkord4qh7Lxz+kFNTfqGUxaSV2YYT7SMR49rkpsB F5Weq6piHo0wfylBnEfdouwCZhTtZfP4gwxD1AkKEvHRIcxlKZvRa0GQ9TgPaIhNEh6j Wmgg== 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=8zDsDLfgQ0jddouO/aur8KY5HvrNJVtqqk9hCxCcOX0=; b=U6Y5erpjf6qvBamwihTPjrJavly33AqwZy2da/+uxIspik/Kk22ZQ+Y2UD62AgLE8k OCT8YBIZ0ja7EvP2qSDZER158qULtfE48OMNWNaSzSKKUblTEuReYX79OM+FowXSMkCn N4QzREZ9Ix8tvWiCIu/ZGstemHR/hafoqRmKjLO5gTYviVxW7rrqKnWmrLNm8tCOEZYL pwASppZqoSlPe1utLPI+TokazFPQvGFanPlR9foFmpJCf0BJ4rdT9ola/suHbcCNxcEK nvsUEQhR62bH7vsZTXIR6z7Pe08dkn7XvVmlugkQgrSm9znaW8rwsst8HgLEKi1OaSCl 1QkA== X-Gm-Message-State: ALyK8tL0/DtrwjIQUa7tymygv6qtdf+QGZu+KZQJRL8+BsVUQqhJFg5kuWcl39k8v56SUA== X-Received: by 10.107.169.207 with SMTP id f76mr189776ioj.192.1468288742048; Mon, 11 Jul 2016 18:59:02 -0700 (PDT) Original-Received: from zony (206-188-64-44.cpe.distributel.net. [206.188.64.44]) by smtp.googlemail.com with ESMTPSA id s20sm8720467ita.8.2016.07.11.18.59.00 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Mon, 11 Jul 2016 18:59:01 -0700 (PDT) In-Reply-To: (Dmitry Gutov's message of "Mon, 11 Jul 2016 22:07:42 +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:120885 Archived-At: --=-=-= Content-Type: text/plain Dmitry Gutov 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. --=-=-= Content-Type: text/x-diff Content-Disposition: inline; filename=v2-0001-Document-buffer-swap-text-save-excursion-interact.patch Content-Description: patch-v2 >From 3c66c6f163e72da7b8f5d40dab7cb2655faddf47 Mon Sep 17 00:00:00 2001 From: Noam Postavsky 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 --=-=-= Content-Type: text/plain >> >> 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). --=-=-=--