From rost@math.uni-bielefeld.de Tue Oct 6 11:46:11 2009 Received: (at submit) by emacsbugs.donarmstrong.com; 6 Oct 2009 18:46:12 +0000 X-Spam-Checker-Version: SpamAssassin 3.2.5-bugs.debian.org_2005_01_02 (2008-06-10) on rzlab.ucr.edu X-Spam-Level: X-Spam-Bayes: score:0.5 Bayes not run. spammytokens:Tokens not available. hammytokens:Tokens not available. X-Spam-Status: No, score=-0.6 required=4.0 tests=AWL autolearn=ham version=3.2.5-bugs.debian.org_2005_01_02 Received: from fencepost.gnu.org (fencepost.gnu.org [140.186.70.10]) by rzlab.ucr.edu (8.14.3/8.14.3/Debian-5) with ESMTP id n96Ik90W020009 for ; Tue, 6 Oct 2009 11:46:11 -0700 Received: from mail.gnu.org ([199.232.76.166]:41660 helo=mx10.gnu.org) by fencepost.gnu.org with esmtp (Exim 4.67) (envelope-from ) id 1MvF32-0004Cs-T2 for emacs-pretest-bug@gnu.org; Tue, 06 Oct 2009 14:46:09 -0400 Received: from Debian-exim by monty-python.gnu.org with spam-scanned (Exim 4.60) (envelope-from ) id 1MvF32-0001GH-4u for emacs-pretest-bug@gnu.org; Tue, 06 Oct 2009 14:46:08 -0400 Received: from mail1.math.uni-bielefeld.de ([129.70.14.32]:65447) by monty-python.gnu.org with esmtps (TLS-1.0:DHE_RSA_AES_256_CBC_SHA1:32) (Exim 4.60) (envelope-from ) id 1MvF31-0001G4-Rm for emacs-pretest-bug@gnu.org; Tue, 06 Oct 2009 14:46:08 -0400 Received: from sonic02.math.uni-bielefeld.de (sonic02.math.uni-bielefeld.de [129.70.14.134]) by mail1.math.uni-bielefeld.de (Postfix) with ESMTP id 05D1795982; Tue, 6 Oct 2009 20:46:05 +0200 (CEST) Received: by sonic02.math.uni-bielefeld.de (Postfix, from userid 3710) id 9A5B2EFE6F; Tue, 6 Oct 2009 20:46:04 +0200 (CEST) From: Markus Rost To: emacs-pretest-bug@gnu.org Subject: 23.1.50; buffer-swap-text oddity X-GNU-Emacs-Mailer: GNU Emacs 22.3 X-Home-Page: http://www.math.uni-bielefeld.de/~rost Message-Id: <20091006184604.9A5B2EFE6F@sonic02.math.uni-bielefeld.de> Date: Tue, 6 Oct 2009 20:46:04 +0200 (CEST) X-detected-operating-system: by monty-python.gnu.org: FreeBSD 5.3-5.4 If you evaluate the form (let ((bufA (get-buffer-create "A")) (bufB (get-buffer-create "B"))) (set-buffer bufA) (message "buffer-msg-1 %s" (current-buffer)) (save-excursion (buffer-swap-text bufB)) (message "buffer-msg-2 %s" (current-buffer))) the *Messages* buffer contains buffer-msg-1 A buffer-msg-2 B With the save-excursion I would have expected the messages buffer-msg-1 A buffer-msg-2 A From lekktu@gmail.com Tue Oct 6 21:01:50 2009 Received: (at 4655) by emacsbugs.donarmstrong.com; 7 Oct 2009 04:01:51 +0000 X-Spam-Checker-Version: SpamAssassin 3.2.5-bugs.debian.org_2005_01_02 (2008-06-10) on rzlab.ucr.edu X-Spam-Level: X-Spam-Bayes: score:0.5 Bayes not run. spammytokens:Tokens not available. hammytokens:Tokens not available. X-Spam-Status: No, score=-2.9 required=4.0 tests=AWL,HAS_BUG_NUMBER autolearn=ham version=3.2.5-bugs.debian.org_2005_01_02 Received: from mail-bw0-f223.google.com (mail-bw0-f223.google.com [209.85.218.223]) by rzlab.ucr.edu (8.14.3/8.14.3/Debian-5) with ESMTP id n9741mus016088 for <4655@emacsbugs.donarmstrong.com>; Tue, 6 Oct 2009 21:01:50 -0700 Received: by bwz23 with SMTP id 23so4207814bwz.1 for <4655@emacsbugs.donarmstrong.com>; Tue, 06 Oct 2009 21:01:42 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=gamma; h=domainkey-signature:mime-version:received:in-reply-to:references :from:date:message-id:subject:to:cc:content-type :content-transfer-encoding; bh=1U8DVfDZyN/vFpKye/62+iB2puw3eqwlOTA5Wsvjy1g=; b=ZBErGk6YPHAz7RAPUS3EAwNxb2JYvdVIJxoAVZOgeSed3o5nFuO6ml3OKIZX3SOhcz vz5/EaHM7rXy/jOtM05B1+ubitlHOOY5nAoAP/fke3e884IAsWK8+78S9yEjySq08Gfd M/1R4E49Vz0EhnHEF7BsmlZ4FkKu82t0xkjL0= DomainKey-Signature: a=rsa-sha1; c=nofws; d=gmail.com; s=gamma; h=mime-version:in-reply-to:references:from:date:message-id:subject:to :cc:content-type:content-transfer-encoding; b=qjcuD+/btmVL5GgVnxuAbavR/ccTs1nd2l0LKoJVIO4fAWIt7maInQeYJxSUK3sUu6 aAhKQlq4p+p7xzkUNWWdWH4gYKjVvOEZHkd3/npL0Qq5Al0LVfZNYgU87nfp66OhwvVm Wc9EVXxSQz4UL7Q+jFWNBGPiEP7uBQJMwGPjo= MIME-Version: 1.0 Received: by 10.239.170.36 with SMTP id q36mr197128hbe.153.1254888102096; Tue, 06 Oct 2009 21:01:42 -0700 (PDT) In-Reply-To: <20091006184604.9A5B2EFE6F@sonic02.math.uni-bielefeld.de> References: <20091006184604.9A5B2EFE6F@sonic02.math.uni-bielefeld.de> From: Juanma Barranquero Date: Wed, 7 Oct 2009 06:01:22 +0200 Message-ID: Subject: Re: bug#4655: 23.1.50; buffer-swap-text oddity To: Markus Rost Cc: 4655@debbugs.gnu.org Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: quoted-printable > (let ((bufA (get-buffer-create "A")) > =C2=A0 =C2=A0 =C2=A0(bufB (get-buffer-create "B"))) > =C2=A0(set-buffer bufA) > =C2=A0(message "buffer-msg-1 %s" (current-buffer)) > =C2=A0(save-excursion > =C2=A0 =C2=A0(buffer-swap-text bufB)) > =C2=A0(message "buffer-msg-2 %s" (current-buffer))) > > the *Messages* buffer contains > > buffer-msg-1 A > buffer-msg-2 B > > With the save-excursion I would have expected the messages > > buffer-msg-1 A > buffer-msg-2 A Why "with the save-excursion"? I would expect A/A both with and without it (and I'm quite surprised to find that it is not so). Why do you expect buffer-swap-text to switch the current buffer? And, why it is doing it? Juanma From monnier@iro.umontreal.ca Tue Oct 6 22:41:48 2009 Received: (at 4655) by emacsbugs.donarmstrong.com; 7 Oct 2009 05:41:48 +0000 X-Spam-Checker-Version: SpamAssassin 3.2.5-bugs.debian.org_2005_01_02 (2008-06-10) on rzlab.ucr.edu X-Spam-Level: X-Spam-Bayes: score:0.5 Bayes not run. spammytokens:Tokens not available. hammytokens:Tokens not available. X-Spam-Status: No, score=-3.8 required=4.0 tests=AWL,HAS_BUG_NUMBER autolearn=ham version=3.2.5-bugs.debian.org_2005_01_02 Received: from ironport2-out.pppoe.ca (ironport2-out.teksavvy.com [206.248.154.181]) by rzlab.ucr.edu (8.14.3/8.14.3/Debian-5) with ESMTP id n975fkT2001328 for <4655@emacsbugs.donarmstrong.com>; Tue, 6 Oct 2009 22:41:48 -0700 X-IronPort-Anti-Spam-Filtered: true X-IronPort-Anti-Spam-Result: AlMFAMrGy0pMCqug/2dsb2JhbACBUdMKhCoEhzQ X-IronPort-AV: E=Sophos;i="4.44,517,1249272000"; d="scan'208";a="47219911" Received: from 76-10-171-160.dsl.teksavvy.com (HELO ceviche.home) ([76.10.171.160]) by ironport2-out.pppoe.ca with ESMTP; 07 Oct 2009 01:41:40 -0400 Received: by ceviche.home (Postfix, from userid 20848) id B6A2FB4190; Wed, 7 Oct 2009 01:41:40 -0400 (EDT) From: Stefan Monnier To: Juanma Barranquero Cc: 4655@debbugs.gnu.org, Markus Rost Subject: Re: bug#4655: 23.1.50; buffer-swap-text oddity Message-ID: References: <20091006184604.9A5B2EFE6F@sonic02.math.uni-bielefeld.de> Date: Wed, 07 Oct 2009 01:41:40 -0400 In-Reply-To: (Juanma Barranquero's message of "Wed, 7 Oct 2009 06:01:22 +0200") User-Agent: Gnus/5.13 (Gnus v5.13) Emacs/23.1.50 (gnu/linux) MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii > Why do you expect buffer-swap-text to switch the current buffer? I'm not sure he expects it. And if he does, I can't tell you why, so I'll pass. > And, why it is doing it? I don't think it does when not called within save-excursion. But when called within the save-excursion, the reason is simple: 1- markers are swapped along with the buffer texts (with a some exceptions, mostly window-markers). 2- save-excursion saves the "position and current buffer" as a marker. Combine 1 and 2 together, and you'll see that save-excursion ends up changing the current buffer. Stefan From rost@math.uni-bielefeld.de Wed Oct 7 01:53:59 2009 Received: (at 4655) by emacsbugs.donarmstrong.com; 7 Oct 2009 08:54:00 +0000 X-Spam-Checker-Version: SpamAssassin 3.2.5-bugs.debian.org_2005_01_02 (2008-06-10) on rzlab.ucr.edu X-Spam-Level: X-Spam-Bayes: score:0.5 Bayes not run. spammytokens:Tokens not available. hammytokens:Tokens not available. X-Spam-Status: No, score=-2.1 required=4.0 tests=AWL,HAS_BUG_NUMBER autolearn=ham version=3.2.5-bugs.debian.org_2005_01_02 Received: from xen16.math.uni-bielefeld.de (xen16.math.uni-bielefeld.de [129.70.14.14]) by rzlab.ucr.edu (8.14.3/8.14.3/Debian-5) with ESMTP id n978rvWt004711 for <4655@emacsbugs.donarmstrong.com>; Wed, 7 Oct 2009 01:53:59 -0700 Received: from sonic02.math.uni-bielefeld.de (sonic02.math.uni-bielefeld.de [129.70.14.134]) by xen16.math.uni-bielefeld.de (Postfix) with ESMTP id 5DC2630072C2; Wed, 7 Oct 2009 10:53:52 +0200 (CEST) Received: by sonic02.math.uni-bielefeld.de (Postfix, from userid 3710) id 502A2EFCF2; Wed, 7 Oct 2009 10:53:51 +0200 (CEST) From: Markus Rost To: Stefan Monnier CC: lekktu@gmail.com, 4655@debbugs.gnu.org In-reply-to: (message from Stefan Monnier on Wed, 07 Oct 2009 01:41:40 -0400) Subject: Re: bug#4655: 23.1.50; buffer-swap-text oddity X-GNU-Emacs-Mailer: GNU Emacs 22.3 X-Home-Page: http://www.math.uni-bielefeld.de/~rost References: <20091006184604.9A5B2EFE6F@sonic02.math.uni-bielefeld.de> Message-Id: <20091007085351.502A2EFCF2@sonic02.math.uni-bielefeld.de> Date: Wed, 7 Oct 2009 10:53:51 +0200 (CEST) Juanma wrote: > I would expect A/A both with and > without it (and I'm quite surprised to find that it is not so). Exactly. > Why do you expect buffer-swap-text to switch the current buffer? I don't. See below for the concrete situation which led to my example. Stefan wrote: > 1- markers are swapped along with the buffer texts (with a some > exceptions, mostly window-markers). > 2- save-excursion saves the "position and current buffer" as a marker. > Combine 1 and 2 together, and you'll see that save-excursion ends up > changing the current buffer. That explains what happened, thanks. But 2- is not obvious from the documentation of save-excursion. And the conclusion "save-excursion ends up changing the current buffer" is very, very surprising. Since I am not the only one to be surprised, it seems to me that if save-excursion/buffer-swap-text keeps having this behavior, it should be documented, perhaps with a warning for lisp programmers. ========== Here is the concrete scenario which induced my buffer-swap-text example: I have set (defadvice rmail-cease-edit (after update-rmail-summary preactivate) "Recompute Summary-line immediately." (rmail-summary)) I expected this to behave like hitting 'h' after editing an rmail buffer. But I get an error: rmail-new-summary: No RMAIL buffer found The reason is that rmail-cease-edit contains the piece (save-excursion (rmail-show-message) (rmail-toggle-header (if pruned 1 0)))) and rmail-show-message has some buffer/text swapping in it. Moreover, the swap partner rmail-view-buffer (an odd name by the way) doesn't know its rmail-buffer (maybe it should?), so calling rmail-summary from it triggers the error. ========== On a general note: Thank you for all the great developments in Emacs 22/23. Markus From lekktu@gmail.com Wed Oct 7 03:08:14 2009 Received: (at 4655) by emacsbugs.donarmstrong.com; 7 Oct 2009 10:08:15 +0000 X-Spam-Checker-Version: SpamAssassin 3.2.5-bugs.debian.org_2005_01_02 (2008-06-10) on rzlab.ucr.edu X-Spam-Level: X-Spam-Bayes: score:0.5 Bayes not run. spammytokens:Tokens not available. hammytokens:Tokens not available. X-Spam-Status: No, score=-2.9 required=4.0 tests=AWL,HAS_BUG_NUMBER autolearn=ham version=3.2.5-bugs.debian.org_2005_01_02 Received: from mail-fx0-f207.google.com (mail-fx0-f207.google.com [209.85.220.207]) by rzlab.ucr.edu (8.14.3/8.14.3/Debian-5) with ESMTP id n97A8CWd019418 for <4655@emacsbugs.donarmstrong.com>; Wed, 7 Oct 2009 03:08:14 -0700 Received: by fxm3 with SMTP id 3so4243763fxm.44 for <4655@emacsbugs.donarmstrong.com>; Wed, 07 Oct 2009 03:08:07 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=gamma; h=domainkey-signature:mime-version:received:in-reply-to:references :from:date:message-id:subject:to:cc:content-type; bh=Xl9J1/75bCmakEdx5GxsQzmT9cG5dI7nDnaV0hU3s00=; b=pJxCq7IKCXzlxQpeKsj50KmljwVS73KFECEb329FS9DtiLDrTBl651SS6nHzvdirvG CHJnt4qTrH+CBvnGgRBtyUsNbZf0D/SbTrWkHmbnPe4BO4wSb4nstcPFybq3HsY/nBq8 Ccxb9dlw1J8cEeHjAUGRTJ0mv5eMW5d9Hr+E8= DomainKey-Signature: a=rsa-sha1; c=nofws; d=gmail.com; s=gamma; h=mime-version:in-reply-to:references:from:date:message-id:subject:to :cc:content-type; b=gUJ3Ew5hJBMKGOXeq24K7tmUv254wSJACAFIXfJkk2AIbsAOrPsqdkYJMAIEOkm5ps Vkbby7oSOzt9ZNLrVcchKzkfTwcb9fTIc4EEymmzI1FU6y3beOn5XzUnfAfqgvGzTWrn FaakwjK3u53dOubgS/tbQjNbVMHe1jf5iB5bI= MIME-Version: 1.0 Received: by 10.239.144.97 with SMTP id n33mr205442hba.183.1254910087122; Wed, 07 Oct 2009 03:08:07 -0700 (PDT) In-Reply-To: References: <20091006184604.9A5B2EFE6F@sonic02.math.uni-bielefeld.de> From: Juanma Barranquero Date: Wed, 7 Oct 2009 12:07:47 +0200 Message-ID: Subject: Re: bug#4655: 23.1.50; buffer-swap-text oddity To: Stefan Monnier Cc: 4655@debbugs.gnu.org, Markus Rost Content-Type: text/plain; charset=UTF-8 On Wed, Oct 7, 2009 at 07:41, Stefan Monnier wrote: > 2- save-excursion saves the "position and current buffer" as a marker. > Combine 1 and 2 together, and you'll see that save-excursion ends up > changing the current buffer. Oops. Yes, I see. Well, we could document it, but from my POV it looks more like a bug than a "feature". Juanma From monnier@iro.umontreal.ca Wed Oct 7 07:29:19 2009 Received: (at 4655) by emacsbugs.donarmstrong.com; 7 Oct 2009 14:29:19 +0000 X-Spam-Checker-Version: SpamAssassin 3.2.5-bugs.debian.org_2005_01_02 (2008-06-10) on rzlab.ucr.edu X-Spam-Level: X-Spam-Bayes: score:0.5 Bayes not run. spammytokens:Tokens not available. hammytokens:Tokens not available. X-Spam-Status: No, score=-3.7 required=4.0 tests=AWL,HAS_BUG_NUMBER autolearn=ham version=3.2.5-bugs.debian.org_2005_01_02 Received: from ironport2-out.pppoe.ca (ironport2-out.teksavvy.com [206.248.154.183]) by rzlab.ucr.edu (8.14.3/8.14.3/Debian-5) with ESMTP id n97ETH7s027832 for <4655@emacsbugs.donarmstrong.com>; Wed, 7 Oct 2009 07:29:18 -0700 X-IronPort-Anti-Spam-Filtered: true X-IronPort-Anti-Spam-Result: AlMFAANDzEpMCqug/2dsb2JhbACBUtUuhCoEhzQ X-IronPort-AV: E=Sophos;i="4.44,519,1249272000"; d="scan'208";a="47234672" Received: from 76-10-171-160.dsl.teksavvy.com (HELO pastel.home) ([76.10.171.160]) by ironport2-out.pppoe.ca with ESMTP; 07 Oct 2009 10:29:12 -0400 Received: by pastel.home (Postfix, from userid 20848) id DF21E81F0; Wed, 7 Oct 2009 10:29:11 -0400 (EDT) From: Stefan Monnier To: Juanma Barranquero Cc: 4655@debbugs.gnu.org, Markus Rost Subject: Re: bug#4655: 23.1.50; buffer-swap-text oddity Message-ID: References: <20091006184604.9A5B2EFE6F@sonic02.math.uni-bielefeld.de> Date: Wed, 07 Oct 2009 10:29:11 -0400 In-Reply-To: (Juanma Barranquero's message of "Wed, 7 Oct 2009 12:07:47 +0200") User-Agent: Gnus/5.13 (Gnus v5.13) Emacs/23.1.50 (gnu/linux) MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii >> 2- save-excursion saves the "position and current buffer" as a marker. >> Combine 1 and 2 together, and you'll see that save-excursion ends up >> changing the current buffer. > Oops. Yes, I see. > Well, we could document it, but from my POV it looks more like a bug > than a "feature". Agreed. This said, we have a problem. If we consider the buffer-swap-text as a kind of "two-way copy&paste", just with a more efficient implementation, then it would be OK for save-excursion to not preserve the position, i.e. handle save-excursion markers similarly to window-markers. I see some problems with it, tho: 1- how to find all the save-excursion markers (we'd probably have to walk the specpdl list and compare the restore function with save_excursion_restore, which is very ugly). 2- if we reset those marker's position in buffer-swap-text, then (save-excursion (buffer-swap-text BUF) (dosomething) (buffer-swap-text BUF)) would end up moving point to (point-min) for no good reason, which is rather inconvenient and might be worse than the OP. 3- we could change save-excursion itself to check the the markers still points to the same buffer. That would solve the OP, but the cost of making all save-excursions more expensive (for the sake of a rare corner case). 4- should save-excursion care more about preserving the position inside the current text, or preserving the current buffer? 5- most uses of save-excursion are wrong, and the OP is among them. I.e. I'd tend to prefer documenting it (in buffer-swap-text), and remind people that they should usually use with-current-buffer rather than save-excursion. Stefan "who thinks save-excursion is an ugly beast" From rost@math.uni-bielefeld.de Thu Oct 8 09:48:50 2009 Received: (at 4655) by emacsbugs.donarmstrong.com; 8 Oct 2009 16:48:50 +0000 X-Spam-Checker-Version: SpamAssassin 3.2.5-bugs.debian.org_2005_01_02 (2008-06-10) on rzlab.ucr.edu X-Spam-Level: X-Spam-Bayes: score:0.5 Bayes not run. spammytokens:Tokens not available. hammytokens:Tokens not available. X-Spam-Status: No, score=-2.1 required=4.0 tests=AWL,HAS_BUG_NUMBER, MURPHY_DRUGS_REL8 autolearn=ham version=3.2.5-bugs.debian.org_2005_01_02 Received: from xen16.math.uni-bielefeld.de (xen16.math.uni-bielefeld.de [129.70.14.14]) by rzlab.ucr.edu (8.14.3/8.14.3/Debian-5) with ESMTP id n98Gmmiu020539 for <4655@emacsbugs.donarmstrong.com>; Thu, 8 Oct 2009 09:48:50 -0700 Received: from sonic02.math.uni-bielefeld.de (sonic02.math.uni-bielefeld.de [129.70.14.134]) by xen16.math.uni-bielefeld.de (Postfix) with ESMTP id 5993930072C2; Thu, 8 Oct 2009 18:48:42 +0200 (CEST) Received: by sonic02.math.uni-bielefeld.de (Postfix, from userid 3710) id BAC66EFE6B; Thu, 8 Oct 2009 18:48:39 +0200 (CEST) From: Markus Rost To: Stefan Monnier CC: lekktu@gmail.com, 4655@debbugs.gnu.org In-reply-to: (message from Stefan Monnier on Wed, 07 Oct 2009 10:29:11 -0400) Subject: Re: bug#4655: 23.1.50; buffer-swap-text oddity X-GNU-Emacs-Mailer: GNU Emacs 22.3 X-Home-Page: http://www.math.uni-bielefeld.de/~rost References: <20091006184604.9A5B2EFE6F@sonic02.math.uni-bielefeld.de> Message-Id: <20091008164839.BAC66EFE6B@sonic02.math.uni-bielefeld.de> Date: Thu, 8 Oct 2009 18:48:39 +0200 (CEST) A follow up to my previous message: If you look at the end of rmail-cease-edit: (save-excursion (rmail-show-message) (rmail-toggle-header (if pruned 1 0)))) (run-hooks 'rmail-mode-hook)) the question arises in which buffer rmail-mode-hook should be run? One may check with (add-hook 'rmail-mode-hook (lambda () (message "foo: %s" (current-buffer)))) that currently it runs in rmail-view-buffer, which is perhaps not what one expects. Changing to (rmail-show-message) (save-excursion (rmail-toggle-header (if pruned 1 0)))) (run-hooks 'rmail-mode-hook)) is probably OK. That would be in line with Stefan's point: > 5- most uses of save-excursion are wrong, ======= Here are more issues related to the usage of buffer-swap-text: I tried to fix (I think this bug should be fixed before the next release: The mbox files should not be corrupted.) with the patch below. See also the thread of It seems to work, except that after a save ('s' in Rmail) the rmail-buffer gets a wrong value of buffer-file-coding-system (to be seen in the mode line). Only temporarily, switching back and forth to another message in Rmail restores the correct value of buffer-file-coding-system. After further debugging, it turned out that the problem sits in ;; Used in `write-region-annotate-functions' to write rmail files. (defun rmail-write-region-annotate (start end) (when (and (null start) (rmail-buffers-swapped-p)) (set-buffer rmail-view-buffer) (widen) nil)) Namely, when rmail-expunge-and-save calls save-buffer, then, with rmail-write-region-annotate in write-region-annotate-functions, save-buffer and basic-save-buffer* write the rmail-view-buffer to the file (which is correct) but then set the buffer-file-coding-system to last-coding-system-used in the rmail-buffer (which is not correct). It seems that generally write-region-annotate-functions should not change the buffer to be written. (What if arg START of write-region is a buffer position?) ===File ~/.emacs.d/rmail/rmail23/bug/rmail-swap.diff======== *** rmail.el 06 Oct 2009 13:20:10 +0200 1.554 --- rmail.el 08 Oct 2009 14:07:01 +0200 *************** *** 1306,1320 **** (defun rmail-swap-buffers () "Swap text between current buffer and `rmail-view-buffer'. ! This function preserves the current buffer's modified flag, and also ! sets the current buffer's `buffer-file-coding-system' to that of ! `rmail-view-buffer'." (let ((modp (buffer-modified-p)) (coding (with-current-buffer rmail-view-buffer buffer-file-coding-system))) (buffer-swap-text rmail-view-buffer) (setq buffer-file-coding-system coding) (restore-buffer-modified-p modp))) (defun rmail-buffers-swapped-p () --- 1306,1322 ---- (defun rmail-swap-buffers () "Swap text between current buffer and `rmail-view-buffer'. ! This function preserves the current buffer's modified flag and ! also swaps the value of `buffer-file-coding-system'." (let ((modp (buffer-modified-p)) + (coding0 buffer-file-coding-system) (coding (with-current-buffer rmail-view-buffer buffer-file-coding-system))) (buffer-swap-text rmail-view-buffer) (setq buffer-file-coding-system coding) + (with-current-buffer rmail-view-buffer + (setq buffer-file-coding-system coding0)) (restore-buffer-modified-p modp))) (defun rmail-buffers-swapped-p () ============================================================ From debbugs-submit-bounces@debbugs.gnu.org Wed Jan 27 17:28:11 2010 Received: (at control) by debbugs.gnu.org; 27 Jan 2010 22:28:11 +0000 Received: from localhost ([127.0.0.1] helo=debbugs.gnu.org) by debbugs.gnu.org with esmtp (Exim 4.69) (envelope-from ) id 1NaGMs-0000c3-Bf for submit@debbugs.gnu.org; Wed, 27 Jan 2010 17:28:10 -0500 Received: from fencepost.gnu.org ([140.186.70.10]) by debbugs.gnu.org with esmtp (Exim 4.69) (envelope-from ) id 1NaGMr-0000by-0E for control@debbugs.gnu.org; Wed, 27 Jan 2010 17:28:09 -0500 Received: from rgm by fencepost.gnu.org with local (Exim 4.69) (envelope-from ) id 1NaGMn-0007OK-3v; Wed, 27 Jan 2010 17:28:05 -0500 MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Transfer-Encoding: 7bit Message-ID: <19296.48629.96436.638769@fencepost.gnu.org> Date: Wed, 27 Jan 2010 17:28:05 -0500 From: Glenn Morris To: control Subject: control X-Attribution: GM X-Mailer: VM (www.wonderworks.com/vm), GNU Emacs (www.gnu.org/software/emacs) X-Hue: cyan X-Ran: 0TV}r/rsw&u^pJU\=0+2(iP_DvG;#sy=b-[j^^4Y%q'cqa)&LXPkw?icI:bXVA9JYlF9%K X-Debbugs-No-Ack: yes X-Spam-Score: -4.9 (----) X-Debbugs-Envelope-To: control X-BeenThere: debbugs-submit@debbugs.gnu.org X-Mailman-Version: 2.1.11 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Sender: debbugs-submit-bounces@debbugs.gnu.org Errors-To: debbugs-submit-bounces@debbugs.gnu.org X-Spam-Score: -4.9 (----) close 4605 severity 4610 wishlist severity 4629 important tags 4629 patch severity 4655 minor From debbugs-submit-bounces@debbugs.gnu.org Wed Jul 13 10:13:32 2011 Received: (at 4655) by debbugs.gnu.org; 13 Jul 2011 14:13:32 +0000 Received: from localhost ([127.0.0.1] helo=debbugs.gnu.org) by debbugs.gnu.org with esmtp (Exim 4.69) (envelope-from ) id 1Qh0Bs-0002X8-Nu for submit@debbugs.gnu.org; Wed, 13 Jul 2011 10:13:32 -0400 Received: from hermes.netfonds.no ([80.91.224.195]) by debbugs.gnu.org with esmtp (Exim 4.69) (envelope-from ) id 1Qh0Bc-0002WC-86 for 4655@debbugs.gnu.org; Wed, 13 Jul 2011 10:13:18 -0400 Received: from cm-84.215.51.58.getinternet.no ([84.215.51.58] helo=quimbies.gnus.org) by hermes.netfonds.no with esmtpsa (TLS1.0:DHE_RSA_AES_128_CBC_SHA1:16) (Exim 4.72) (envelope-from ) id 1Qh0BO-00017e-KJ; Wed, 13 Jul 2011 16:12:58 +0200 From: Lars Magne Ingebrigtsen To: Stefan Monnier Subject: Re: bug#4655: 23.1.50; buffer-swap-text oddity In-Reply-To: (Stefan Monnier's message of "Wed, 07 Oct 2009 10:29:11 -0400") Date: Wed, 13 Jul 2011 16:08:17 +0200 Message-ID: References: <20091006184604.9A5B2EFE6F@sonic02.math.uni-bielefeld.de> User-Agent: Gnus/5.110018 (No Gnus v0.18) Emacs/24.0.50 (gnu/linux) X-Now-Playing: Talking Heads's _Fear Of Music_: "Memories Can't Wait" X-Hashcash: 1:23:110713:lekktu@gmail.com::0BeqSsD/D7OkTK3C:06iA1 X-Hashcash: 1:23:110713:4655@debbugs.gnu.org::1ZFntZxqd/PU3A/7:00000000000000000000000000000000000000000IaSu X-Hashcash: 1:23:110713:monnier@iro.umontreal.ca::MnVhKUsczDwE2BVr:0000000000000000000000000000000000000cZgD X-Hashcash: 1:23:110713:rost@math.uni-bielefeld.de::7Cta8Ne3aiPuQUcY:00000000000000000000000000000000000o6so MIME-Version: 1.0 Content-Type: text/plain X-MailScanner-ID: 1Qh0BO-00017e-KJ X-Netfonds-MailScanner: Found to be clean X-Netfonds-MailScanner-From: larsi@gnus.org MailScanner-NULL-Check: 1311171178.70218@pZE2lKZM1RseOH+nPHUwbQ X-Spam-Status: No X-Spam-Score: -2.7 (--) X-Debbugs-Envelope-To: 4655 Cc: Markus Rost , Juanma Barranquero , 4655@debbugs.gnu.org X-BeenThere: debbugs-submit@debbugs.gnu.org X-Mailman-Version: 2.1.11 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Sender: debbugs-submit-bounces@debbugs.gnu.org Errors-To: debbugs-submit-bounces@debbugs.gnu.org X-Spam-Score: -2.7 (--) Stefan Monnier writes: >>> 2- save-excursion saves the "position and current buffer" as a marker. >>> Combine 1 and 2 together, and you'll see that save-excursion ends up >>> changing the current buffer. > >> Oops. Yes, I see. >> Well, we could document it, but from my POV it looks more like a bug >> than a "feature". > > Agreed. This said, we have a problem. Has this been fixed? I seem to be unable to reproduce this bug in Emacs 24... -- (domestic pets only, the antidote for overdose, milk.) bloggy blog http://lars.ingebrigtsen.no/ From debbugs-submit-bounces@debbugs.gnu.org Sun Jul 10 21:58:57 2016 Received: (at 4655) by debbugs.gnu.org; 11 Jul 2016 01:58:57 +0000 Received: from localhost ([127.0.0.1]:45780 helo=debbugs.gnu.org) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1bMQUo-0006uv-7M for submit@debbugs.gnu.org; Sun, 10 Jul 2016 21:58:57 -0400 Received: from mail-it0-f43.google.com ([209.85.214.43]:36758) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1bMQUe-0006uJ-PU; Sun, 10 Jul 2016 21:58:48 -0400 Received: by mail-it0-f43.google.com with SMTP id f6so43260852ith.1; Sun, 10 Jul 2016 18:58:44 -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=7QAmPWt7LqGe52j5ZeHzTxIlxmLlgHOF97E5t5v82iw=; b=EUlgNjOIrCUYURYvcT9cemNch+i2QzWuFdtbP6gwjnAoO2n10y3K9R529coA/Oa6C+ Bxaw9irkvqFCbEG8Ul5/k10Mw2/si6cFjX7zM6cCse8RBaBJVezSf9bdHOtyQugeB21L v+druOQsy2ifClfSteyhoyYwaejh7fIW5J4MUZaTdXpi8HEGS7UBwdFZcDif1nVmLcqz MLbAX78E46FpcrjvV8+NO5JLxNK23/zP/zJ5gnM/o1J5wya3QiGQoBfGMOWtPRg5PH9w jilHcYXWb1PapKTY7KmA55NqpVp5vpCyti0jHoh6BKvO3Edzlz5UYiYK/4/RD2BFdw9q Sqrw== 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=7QAmPWt7LqGe52j5ZeHzTxIlxmLlgHOF97E5t5v82iw=; b=K2y26wQk+V4PKyCm7M7Opn+3+TmFQa+Y3VDp9sITTGgSsTARog09wgrEaL6DFJETa1 g3gGySlr6pqImCeIMoMPQfxf8ZXAMmerqdjZrtfO+pCZ91l4O9cO1oPzEj+g3vcr3wt8 Y1W3iXObAQyfNRM633NOAA1hXEVx2cu40gEDVqCnSs/hcoZXjGr5//4qDzTi39QjmXjQ ltYjQfjtlR+Wm2iiB7kx3k28VlSBn89i3NGgvjwIwDszdnj4hYWSCmeDsbSMfjxLdqdt jJPymyBrYGkqWHcsuEbm57zgkPnOs5+WXQ3yBscHHxLFT1wJ6jpUXRx7T4H1qYpcP1Ps AaHw== X-Gm-Message-State: ALyK8tI8+/cifPZSygJt8in9zBO2B9AvWLFv5ufjO0QvVVVl8UT2lHq5H4iBL2ih1HZMww== X-Received: by 10.36.82.82 with SMTP id d79mr8322594itb.3.1468202319283; Sun, 10 Jul 2016 18:58:39 -0700 (PDT) Received: from zony (206-188-64-44.cpe.distributel.net. [206.188.64.44]) by smtp.googlemail.com with ESMTPSA id l184sm6588242itd.14.2016.07.10.18.58.38 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Sun, 10 Jul 2016 18:58:38 -0700 (PDT) From: npostavs@users.sourceforge.net To: Lars Magne Ingebrigtsen Subject: Re: bug#4655: 23.1.50; buffer-swap-text oddity References: <20091006184604.9A5B2EFE6F@sonic02.math.uni-bielefeld.de> Date: Sun, 10 Jul 2016 21:58:36 -0400 In-Reply-To: (Lars Magne Ingebrigtsen's message of "Wed, 13 Jul 2011 16:08:17 +0200") Message-ID: <874m7xgckz.fsf@users.sourceforge.net> User-Agent: Gnus/5.13 (Gnus v5.13) Emacs/25.0.93 (gnu/linux) MIME-Version: 1.0 Content-Type: multipart/mixed; boundary="=-=-=" X-Spam-Score: -0.7 (/) X-Debbugs-Envelope-To: 4655 Cc: Markus Rost , Juanma Barranquero , 4655@debbugs.gnu.org, Stefan Monnier X-BeenThere: debbugs-submit@debbugs.gnu.org X-Mailman-Version: 2.1.18 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: debbugs-submit-bounces@debbugs.gnu.org Sender: "Debbugs-submit" X-Spam-Score: -0.7 (/) --=-=-= Content-Type: text/plain tags 4655 patch quit Lars Magne Ingebrigtsen writes: > Stefan Monnier writes: > >>>> 2- save-excursion saves the "position and current buffer" as a marker. >>>> Combine 1 and 2 together, and you'll see that save-excursion ends up >>>> changing the current buffer. >> >>> Oops. Yes, I see. >>> Well, we could document it, but from my POV it looks more like a bug >>> than a "feature". >> >> Agreed. This said, we have a problem. > > Has this been fixed? I seem to be unable to reproduce this bug in Emacs > 24... Reproduces for me with 23.4 up through 25.0.95. So here's a patch to mention it in the manual: --=-=-= Content-Type: text/x-diff Content-Disposition: inline; filename=v1-0001-Document-buffer-swap-text-save-excursion-interact.patch Content-Description: patch >From 7c79e2f1aef7e59d80d7b46533a93f2f23ad6759 Mon Sep 17 00:00:00 2001 From: Noam Postavsky Date: Sun, 10 Jul 2016 21:52:23 -0400 Subject: [PATCH v1] Document buffer-swap-text+save-excursion interaction * doc/lispref/buffers.texi (Swapping Text): Add warning about interaction of `buffer-swap-text' and `save-excursion' (Bug #4655). --- doc/lispref/buffers.texi | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/doc/lispref/buffers.texi b/doc/lispref/buffers.texi index 1f7f263..22c6726 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:} The current buffer will be set to @var{buffer} if +this function is called from within @code{save-excursion}, 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 -- 2.8.0 --=-=-=-- From debbugs-submit-bounces@debbugs.gnu.org Mon Jul 11 10:37:53 2016 Received: (at 4655) by debbugs.gnu.org; 11 Jul 2016 14:37:53 +0000 Received: from localhost ([127.0.0.1]:46964 helo=debbugs.gnu.org) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1bMcLI-0003dv-Sp for submit@debbugs.gnu.org; Mon, 11 Jul 2016 10:37:53 -0400 Received: from eggs.gnu.org ([208.118.235.92]:43257) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1bMcLI-0003df-18 for 4655@debbugs.gnu.org; Mon, 11 Jul 2016 10:37:52 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1bMcL8-0007BX-UW for 4655@debbugs.gnu.org; Mon, 11 Jul 2016 10:37:46 -0400 X-Spam-Checker-Version: SpamAssassin 3.3.2 (2011-06-06) on eggs.gnu.org X-Spam-Level: X-Spam-Status: No, score=-3.2 required=5.0 tests=BAYES_00,RP_MATCHES_RCVD autolearn=disabled version=3.3.2 Received: from fencepost.gnu.org ([2001:4830:134:3::e]:48318) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1bMcL5-0007BB-DE; Mon, 11 Jul 2016 10:37:39 -0400 Received: from 84.94.185.246.cable.012.net.il ([84.94.185.246]:3813 helo=home-c4e4a596f7) by fencepost.gnu.org with esmtpsa (TLS1.2:RSA_AES_128_CBC_SHA1:128) (Exim 4.82) (envelope-from ) id 1bMcL3-0003gI-7u; Mon, 11 Jul 2016 10:37:37 -0400 Date: Mon, 11 Jul 2016 17:37:18 +0300 Message-Id: <83y458ckbl.fsf@gnu.org> From: Eli Zaretskii To: npostavs@users.sourceforge.net In-reply-to: <874m7xgckz.fsf@users.sourceforge.net> (npostavs@users.sourceforge.net) Subject: Re: bug#4655: 23.1.50; buffer-swap-text oddity References: <20091006184604.9A5B2EFE6F@sonic02.math.uni-bielefeld.de> <874m7xgckz.fsf@users.sourceforge.net> X-detected-operating-system: by eggs.gnu.org: GNU/Linux 2.2.x-3.x [generic] X-Received-From: 2001:4830:134:3::e X-Spam-Score: -6.3 (------) X-Debbugs-Envelope-To: 4655 Cc: rost@math.uni-bielefeld.de, lekktu@gmail.com, larsi@gnus.org, 4655@debbugs.gnu.org, monnier@iro.umontreal.ca X-BeenThere: debbugs-submit@debbugs.gnu.org X-Mailman-Version: 2.1.18 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Reply-To: Eli Zaretskii Errors-To: debbugs-submit-bounces@debbugs.gnu.org Sender: "Debbugs-submit" X-Spam-Score: -6.3 (------) > From: npostavs@users.sourceforge.net > Date: Sun, 10 Jul 2016 21:58:36 -0400 > Cc: Markus Rost , > Juanma Barranquero , 4655@debbugs.gnu.org, > Stefan Monnier > > --- 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:} The current buffer will be set to @var{buffer} if > +this function is called from within @code{save-excursion}, since the > +marker used by @code{save-excursion} to save the position and buffer > +will be swapped as well. > @end defun Fine with me, but I think we should also add a single sentence to the doc string, something like Using this function from `save-excursion' might produce surprising results, see Info node `(elisp)Swapping Text'. With that taken care of, please push to emacs-25. Thanks. From debbugs-submit-bounces@debbugs.gnu.org Mon Jul 11 15:02:16 2016 Received: (at 4655) by debbugs.gnu.org; 11 Jul 2016 19:02:16 +0000 Received: from localhost ([127.0.0.1]:47224 helo=debbugs.gnu.org) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1bMgT9-00029B-M8 for submit@debbugs.gnu.org; Mon, 11 Jul 2016 15:02:15 -0400 Received: from smtp.math.uni-bielefeld.de ([129.70.45.10]:44454) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1bMgHy-0001qD-AB for 4655@debbugs.gnu.org; Mon, 11 Jul 2016 14:50:42 -0400 Received: from ssh.math.uni-bielefeld.de (kvm01.math.uni-bielefeld.de [129.70.45.15]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (Client CN "ssh.math.uni-bielefeld.de", Issuer "math.uni-bielefeld.de" (verified OK)) by smtp.math.uni-bielefeld.de (Postfix) with ESMTPS id 6E0965F5C8; Mon, 11 Jul 2016 20:50:35 +0200 (CEST) Received: by ssh.math.uni-bielefeld.de (Postfix, from userid 3710) id 56B9240619; Mon, 11 Jul 2016 20:50:35 +0200 (CEST) From: Markus Rost To: Eli Zaretskii In-reply-to: <83y458ckbl.fsf@gnu.org> (message from Eli Zaretskii on Mon, 11 Jul 2016 17:37:18 +0300) Subject: Re: bug#4655: 23.1.50; buffer-swap-text oddity X-Mail-Tool: GNU Emacs 22.3 X-Home-Page: http://www.math.uni-bielefeld.de/~rost References: <20091006184604.9A5B2EFE6F@sonic02.math.uni-bielefeld.de> <874m7xgckz.fsf@users.sourceforge.net> <83y458ckbl.fsf@gnu.org> Message-Id: <20160711185035.56B9240619@ssh.math.uni-bielefeld.de> Date: Mon, 11 Jul 2016 20:50:35 +0200 (CEST) X-Spam-Score: -3.6 (---) X-Debbugs-Envelope-To: 4655 X-Mailman-Approved-At: Mon, 11 Jul 2016 15:02:14 -0400 Cc: lekktu@gmail.com, larsi@gnus.org, 4655@debbugs.gnu.org, monnier@iro.umontreal.ca, npostavs@users.sourceforge.net X-BeenThere: debbugs-submit@debbugs.gnu.org X-Mailman-Version: 2.1.18 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: debbugs-submit-bounces@debbugs.gnu.org Sender: "Debbugs-submit" X-Spam-Score: -3.6 (---) > please push to emacs-25. 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 From debbugs-submit-bounces@debbugs.gnu.org Mon Jul 11 15:07:52 2016 Received: (at 4655) by debbugs.gnu.org; 11 Jul 2016 19:07:52 +0000 Received: from localhost ([127.0.0.1]:47239 helo=debbugs.gnu.org) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1bMgYa-0002HW-7J for submit@debbugs.gnu.org; Mon, 11 Jul 2016 15:07:52 -0400 Received: from mail-wm0-f54.google.com ([74.125.82.54]:36579) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1bMgYY-0002Gs-Ms for 4655@debbugs.gnu.org; Mon, 11 Jul 2016 15:07:51 -0400 Received: by mail-wm0-f54.google.com with SMTP id f126so102278792wma.1 for <4655@debbugs.gnu.org>; Mon, 11 Jul 2016 12:07:50 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20120113; h=sender:subject:to:references:cc:from:message-id:date:user-agent :mime-version:in-reply-to:content-transfer-encoding; bh=uSCLPdXYCghRTJiOFaKJOuKMxG7blO8zDAxfNsIycKY=; b=TKR2F5xXwvDMm/laWN37mq7cLzJEnR3ZJpDbNFFbWQHZnII+G4eMYATpRcutqpHBuq xtgdjzLBu6xX9YS41zoz6iZACbnuDD6GWJBniOzK2aSJLPDQfbNh6w6nDKII06jP53Am iwbYkyLZ6+xTZ9Gqtsfxs4nNL2bo3DoVg5PsQAHTEKzAQI6qPLKZ8zxaywnu5aRx+Fyx rxzpL5jFAXb04U+aU1+YFTDwYwu9urznhxaSK40KtUGsCXfnFVImbIfhepF4lxeqpulP BpfuK+aTluQ2EZcPkARuy+RlBX1c7/MWov3yz+O5/bdioTBBepolXHCzcRWhYRS2DnIN k1MQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20130820; h=x-gm-message-state:sender:subject:to:references:cc:from:message-id :date:user-agent:mime-version:in-reply-to:content-transfer-encoding; bh=uSCLPdXYCghRTJiOFaKJOuKMxG7blO8zDAxfNsIycKY=; b=N09bszazbOR915l4ow4lgAcB8HfmIydKlcKv0WG5MHb2cm6nLHCjcMmj9eNg0fIP4l ySlP3mxLPOY/Lk8nZRXz+HFxulPviP2gU6QX8Mnd/gtuqWuJfSZiXrBAfd2E6R2cq6mB 3Wlh1PUSrftaPtdpPjG8vJkUmctE/1p21dO8R6uxq7JfNbSWpTyz7tSd0fR/tIwARGEs Cjsyyfks+28hMdsnH1w4ov7aBs5HSbtFba9iQ4G64RCA3KKWYCM5DNVk2ltWakV2/mlG 20vJ44ILzECs6BgIUSTPv87y5HbofjXVjznovJufewROTOtFz5bBfSxDC5C0XXm8ViU/ /qnw== X-Gm-Message-State: ALyK8tJ5bGM2cCfP1RP4kGP/0p3fAglqFqQMQMr61Itq/Jn6Okc8hg44KlQ3Nrv4iNURUg== X-Received: by 10.194.35.6 with SMTP id d6mr1114084wjj.8.1468264064993; Mon, 11 Jul 2016 12:07:44 -0700 (PDT) Received: from [192.168.1.2] ([185.105.173.135]) by smtp.googlemail.com with ESMTPSA id c142sm1213881wme.18.2016.07.11.12.07.43 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Mon, 11 Jul 2016 12:07:44 -0700 (PDT) Subject: Re: bug#4655: 23.1.50; buffer-swap-text oddity To: Markus Rost , Eli Zaretskii References: <20091006184604.9A5B2EFE6F@sonic02.math.uni-bielefeld.de> <874m7xgckz.fsf@users.sourceforge.net> <83y458ckbl.fsf@gnu.org> <20160711185035.56B9240619@ssh.math.uni-bielefeld.de> From: Dmitry Gutov Message-ID: Date: Mon, 11 Jul 2016 22:07:42 +0300 User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:47.0) Gecko/20100101 Thunderbird/47.0 MIME-Version: 1.0 In-Reply-To: <20160711185035.56B9240619@ssh.math.uni-bielefeld.de> Content-Type: text/plain; charset=windows-1252; format=flowed Content-Transfer-Encoding: 7bit X-Spam-Score: -0.7 (/) X-Debbugs-Envelope-To: 4655 Cc: lekktu@gmail.com, larsi@gnus.org, 4655@debbugs.gnu.org, monnier@iro.umontreal.ca, npostavs@users.sourceforge.net X-BeenThere: debbugs-submit@debbugs.gnu.org X-Mailman-Version: 2.1.18 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: debbugs-submit-bounces@debbugs.gnu.org Sender: "Debbugs-submit" X-Spam-Score: -0.7 (/) On 07/11/2016 09:50 PM, Markus Rost wrote: >> please push to emacs-25. > > 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. From debbugs-submit-bounces@debbugs.gnu.org Mon Jul 11 21:59:09 2016 Received: (at 4655) by debbugs.gnu.org; 12 Jul 2016 01:59:09 +0000 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 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 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) 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) From: npostavs@users.sourceforge.net To: Dmitry Gutov Subject: Re: bug#4655: 23.1.50; buffer-swap-text oddity References: <20091006184604.9A5B2EFE6F@sonic02.math.uni-bielefeld.de> <874m7xgckz.fsf@users.sourceforge.net> <83y458ckbl.fsf@gnu.org> <20160711185035.56B9240619@ssh.math.uni-bielefeld.de> Date: Mon, 11 Jul 2016 21:58:59 -0400 In-Reply-To: (Dmitry Gutov's message of "Mon, 11 Jul 2016 22:07:42 +0300") Message-ID: <87lh17fwgs.fsf@users.sourceforge.net> User-Agent: Gnus/5.13 (Gnus v5.13) Emacs/25.0.93 (gnu/linux) MIME-Version: 1.0 Content-Type: multipart/mixed; boundary="=-=-=" X-Spam-Score: -0.7 (/) X-Debbugs-Envelope-To: 4655 Cc: lekktu@gmail.com, 4655@debbugs.gnu.org, monnier@iro.umontreal.ca, Markus Rost , Eli Zaretskii , larsi@gnus.org X-BeenThere: debbugs-submit@debbugs.gnu.org X-Mailman-Version: 2.1.18 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: debbugs-submit-bounces@debbugs.gnu.org Sender: "Debbugs-submit" X-Spam-Score: -0.7 (/) --=-=-= 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). --=-=-=-- From debbugs-submit-bounces@debbugs.gnu.org Tue Jul 12 01:17:52 2016 Received: (at 4655) by debbugs.gnu.org; 12 Jul 2016 05:17:52 +0000 Received: from localhost ([127.0.0.1]:47457 helo=debbugs.gnu.org) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1bMq4r-0004b0-14 for submit@debbugs.gnu.org; Tue, 12 Jul 2016 01:17:52 -0400 Received: from eggs.gnu.org ([208.118.235.92]:40527) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1bMq4m-0004ai-J9 for 4655@debbugs.gnu.org; Tue, 12 Jul 2016 01:17:47 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1bMq4d-0004le-QB for 4655@debbugs.gnu.org; Tue, 12 Jul 2016 01:17:39 -0400 X-Spam-Checker-Version: SpamAssassin 3.3.2 (2011-06-06) on eggs.gnu.org X-Spam-Level: X-Spam-Status: No, score=-3.2 required=5.0 tests=BAYES_00,RP_MATCHES_RCVD autolearn=disabled version=3.3.2 Received: from fencepost.gnu.org ([2001:4830:134:3::e]:58300) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1bMq4K-0004j5-73; Tue, 12 Jul 2016 01:17:16 -0400 Received: from 84.94.185.246.cable.012.net.il ([84.94.185.246]:4445 helo=home-c4e4a596f7) by fencepost.gnu.org with esmtpsa (TLS1.2:RSA_AES_128_CBC_SHA1:128) (Exim 4.82) (envelope-from ) id 1bMq4I-0001i8-3A; Tue, 12 Jul 2016 01:17:14 -0400 Date: Tue, 12 Jul 2016 08:16:56 +0300 Message-Id: <83zipnbflj.fsf@gnu.org> From: Eli Zaretskii To: npostavs@users.sourceforge.net In-reply-to: <87lh17fwgs.fsf@users.sourceforge.net> (npostavs@users.sourceforge.net) Subject: Re: bug#4655: 23.1.50; buffer-swap-text oddity 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> X-detected-operating-system: by eggs.gnu.org: GNU/Linux 2.2.x-3.x [generic] X-Received-From: 2001:4830:134:3::e X-Spam-Score: -6.3 (------) X-Debbugs-Envelope-To: 4655 Cc: lekktu@gmail.com, monnier@iro.umontreal.ca, dgutov@yandex.ru, rost@math.uni-bielefeld.de, 4655@debbugs.gnu.org, larsi@gnus.org X-BeenThere: debbugs-submit@debbugs.gnu.org X-Mailman-Version: 2.1.18 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Reply-To: Eli Zaretskii Errors-To: debbugs-submit-bounces@debbugs.gnu.org Sender: "Debbugs-submit" X-Spam-Score: -6.3 (------) > From: npostavs@users.sourceforge.net > Cc: Markus Rost , Eli Zaretskii , 4655@debbugs.gnu.org, lekktu@gmail.com, larsi@gnus.org, monnier@iro.umontreal.ca > Date: Mon, 11 Jul 2016 21:58:59 -0400 > > 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. Yes, something like "upon return from this form ...". I think it's a good idea. Otherwise the text is good, IMO. Thanks. From debbugs-submit-bounces@debbugs.gnu.org Wed Jul 13 19:50:59 2016 Received: (at 4655) by debbugs.gnu.org; 13 Jul 2016 23:50:59 +0000 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 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 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) 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) From: npostavs@users.sourceforge.net To: Eli Zaretskii Subject: Re: bug#4655: 23.1.50; buffer-swap-text oddity 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> Date: Wed, 13 Jul 2016 19:50:49 -0400 In-Reply-To: <83zipnbflj.fsf@gnu.org> (Eli Zaretskii's message of "Tue, 12 Jul 2016 08:16:56 +0300") Message-ID: <87a8hlf67a.fsf@users.sourceforge.net> User-Agent: Gnus/5.13 (Gnus v5.13) Emacs/25.0.93 (gnu/linux) MIME-Version: 1.0 Content-Type: multipart/mixed; boundary="=-=-=" X-Spam-Score: -0.7 (/) X-Debbugs-Envelope-To: 4655 Cc: lekktu@gmail.com, monnier@iro.umontreal.ca, dgutov@yandex.ru, rost@math.uni-bielefeld.de, 4655@debbugs.gnu.org, larsi@gnus.org X-BeenThere: debbugs-submit@debbugs.gnu.org X-Mailman-Version: 2.1.18 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: debbugs-submit-bounces@debbugs.gnu.org Sender: "Debbugs-submit" X-Spam-Score: -0.7 (/) --=-=-= 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 --=-=-=-- From debbugs-submit-bounces@debbugs.gnu.org Thu Jul 14 11:04:56 2016 Received: (at 4655) by debbugs.gnu.org; 14 Jul 2016 15:04:56 +0000 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 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 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 X-Spam-Checker-Version: SpamAssassin 3.3.2 (2011-06-06) on eggs.gnu.org X-Spam-Level: X-Spam-Status: No, score=-1.3 required=5.0 tests=BAYES_20,RP_MATCHES_RCVD autolearn=disabled version=3.3.2 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 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 Date: Thu, 14 Jul 2016 18:03:27 +0300 Message-Id: <83d1mg8dog.fsf@gnu.org> From: Eli Zaretskii To: npostavs@users.sourceforge.net In-reply-to: <87a8hlf67a.fsf@users.sourceforge.net> (npostavs@users.sourceforge.net) Subject: Re: bug#4655: 23.1.50; buffer-swap-text oddity 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> X-detected-operating-system: by eggs.gnu.org: GNU/Linux 2.2.x-3.x [generic] X-Received-From: 2001:4830:134:3::e X-Spam-Score: -6.3 (------) X-Debbugs-Envelope-To: 4655 Cc: lekktu@gmail.com, monnier@iro.umontreal.ca, dgutov@yandex.ru, rost@math.uni-bielefeld.de, 4655@debbugs.gnu.org, larsi@gnus.org X-BeenThere: debbugs-submit@debbugs.gnu.org X-Mailman-Version: 2.1.18 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Reply-To: Eli Zaretskii Errors-To: debbugs-submit-bounces@debbugs.gnu.org Sender: "Debbugs-submit" X-Spam-Score: -1.3 (-) > 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. From debbugs-submit-bounces@debbugs.gnu.org Thu Jul 14 20:05:47 2016 Received: (at 4655) by debbugs.gnu.org; 15 Jul 2016 00:05:47 +0000 Received: from localhost ([127.0.0.1]:51869 helo=debbugs.gnu.org) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1bNqdT-0004hs-6o for submit@debbugs.gnu.org; Thu, 14 Jul 2016 20:05:46 -0400 Received: from mail-it0-f42.google.com ([209.85.214.42]:35364) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1bNqdL-0004h6-3t; Thu, 14 Jul 2016 20:05:38 -0400 Received: by mail-it0-f42.google.com with SMTP id u186so6261868ita.0; Thu, 14 Jul 2016 17:05:35 -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=wlVbkuxVbNPsb2+6p6rD3jQ63/9aR91nhY+PZFRZ6Cs=; b=YpVXtG9vMLILaTCNZSLyDqTW+I1MFS+SJl1mDuLyjLGPVe2MWukqVdoGKGADPR4p+j 2thnkPEQ6XbtU26NTV74zDuRmloHN4xATXg7gPhZQi3VsAj8WLnlCcQ9Y2cL72jQiWkV /Ez3ECyLvKDprWrl543pGcNa0HJ3UWWq/M1ncGgQj1LXwhloopFUWE2SijKcIZsPhv55 STSwasq+3zluslU/jjL3qnbWdTFepEH8jRzag8ada8lr1NdjwUp968jh9T2m+jF7lHDT jxpLL4pOIvkPmWPPAqYrN9LIdKjSoUXHCQ7GXe6mhj9uV9zsaaK0DFO4Ki3q1pS2+ZJl yQKg== 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=wlVbkuxVbNPsb2+6p6rD3jQ63/9aR91nhY+PZFRZ6Cs=; b=jLgBSA1yc1Lh+Rgs6r0lrxXFSOv2accc0dz2BBi9mLRynSRZoCTGYWZjuJE4y9hCSw SCbqXm+JL5Rp4HYpJ5zldiUZQnZyRHjLap9koRims6QDQLLpYJayumHww5tLUwz2Zir0 JTTMkDKMWqnYKlpis7ViHgNDIjIM6eJxPl8lTWYlylGj9dPmcVcOmbrNkke7an9oi9wu hMA+lRqVpx7+ZCMJcuku55SCkxiz6YT7aQXMeALCOpjNZ35RIjUHM3PKokawvaqx3o0W b0fomcqDpb+q7Yi2kA2wFuEQ60C22xLEJDojFw3Och5AZ9FVBsWwPOMzy7TMO1zJ9qJ4 VV8Q== X-Gm-Message-State: ALyK8tJriV6JIU4d3EdX9UrYhvNA3GZT0zhyz5f735SrJtPyReiYigkkKO2bBiF6e5FzCg== X-Received: by 10.36.188.65 with SMTP id n62mr32219473ite.61.1468541129635; Thu, 14 Jul 2016 17:05:29 -0700 (PDT) Received: from zony (206-188-64-44.cpe.distributel.net. [206.188.64.44]) by smtp.googlemail.com with ESMTPSA id u7sm396217ita.21.2016.07.14.17.05.28 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Thu, 14 Jul 2016 17:05:29 -0700 (PDT) From: npostavs@users.sourceforge.net To: Eli Zaretskii Subject: Re: bug#4655: 23.1.50; buffer-swap-text oddity 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> <83d1mg8dog.fsf@gnu.org> Date: Thu, 14 Jul 2016 20:05:28 -0400 In-Reply-To: <83d1mg8dog.fsf@gnu.org> (Eli Zaretskii's message of "Thu, 14 Jul 2016 18:03:27 +0300") Message-ID: <87shvbepfb.fsf@users.sourceforge.net> User-Agent: Gnus/5.13 (Gnus v5.13) Emacs/25.0.93 (gnu/linux) MIME-Version: 1.0 Content-Type: text/plain X-Spam-Score: -0.7 (/) X-Debbugs-Envelope-To: 4655 Cc: lekktu@gmail.com, monnier@iro.umontreal.ca, dgutov@yandex.ru, rost@math.uni-bielefeld.de, 4655@debbugs.gnu.org, larsi@gnus.org X-BeenThere: debbugs-submit@debbugs.gnu.org X-Mailman-Version: 2.1.18 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: debbugs-submit-bounces@debbugs.gnu.org Sender: "Debbugs-submit" X-Spam-Score: -0.7 (/) close 4655 quit >> 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. pushed as 9ba51edf From unknown Mon Sep 08 03:16:19 2025 Received: (at fakecontrol) by fakecontrolmessage; To: internal_control@debbugs.gnu.org From: Debbugs Internal Request Subject: Internal Control Message-Id: bug archived. Date: Fri, 12 Aug 2016 11:24:04 +0000 User-Agent: Fakemail v42.6.9 # This is a fake control message. # # The action: # bug archived. thanks # This fakemail brought to you by your local debbugs # administrator