From mboxrd@z Thu Jan 1 00:00:00 1970 Path: news.gmane.org!not-for-mail From: Stefan Monnier Newsgroups: gmane.emacs.bugs Subject: bug#4655: 23.1.50; buffer-swap-text oddity Date: Wed, 07 Oct 2009 10:29:11 -0400 Message-ID: References: <20091006184604.9A5B2EFE6F@sonic02.math.uni-bielefeld.de> Reply-To: Stefan Monnier , 4655@emacsbugs.donarmstrong.com NNTP-Posting-Host: lo.gmane.org Mime-Version: 1.0 Content-Type: text/plain; charset=us-ascii X-Trace: ger.gmane.org 1254927493 22066 80.91.229.12 (7 Oct 2009 14:58:13 GMT) X-Complaints-To: usenet@ger.gmane.org NNTP-Posting-Date: Wed, 7 Oct 2009 14:58:13 +0000 (UTC) Cc: Markus Rost , 4655@emacsbugs.donarmstrong.com To: Juanma Barranquero Original-X-From: bug-gnu-emacs-bounces+geb-bug-gnu-emacs=m.gmane.org@gnu.org Wed Oct 07 16:58:03 2009 Return-path: Envelope-to: geb-bug-gnu-emacs@m.gmane.org Original-Received: from lists.gnu.org ([199.232.76.165]) by lo.gmane.org with esmtp (Exim 4.50) id 1MvXxp-0004EY-VK for geb-bug-gnu-emacs@m.gmane.org; Wed, 07 Oct 2009 16:58:02 +0200 Original-Received: from localhost ([127.0.0.1]:53648 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.43) id 1MvXxp-00049z-A2 for geb-bug-gnu-emacs@m.gmane.org; Wed, 07 Oct 2009 10:58:01 -0400 Original-Received: from mailman by lists.gnu.org with tmda-scanned (Exim 4.43) id 1MvXnT-0002x2-31 for bug-gnu-emacs@gnu.org; Wed, 07 Oct 2009 10:47:19 -0400 Original-Received: from exim by lists.gnu.org with spam-scanned (Exim 4.43) id 1MvXnP-0002s8-1x for bug-gnu-emacs@gnu.org; Wed, 07 Oct 2009 10:47:18 -0400 Original-Received: from [199.232.76.173] (port=59112 helo=monty-python.gnu.org) by lists.gnu.org with esmtp (Exim 4.43) id 1MvXnO-0002rg-9w for bug-gnu-emacs@gnu.org; Wed, 07 Oct 2009 10:47:14 -0400 Original-Received: from rzlab.ucr.edu ([138.23.92.77]:45377) by monty-python.gnu.org with esmtps (TLS-1.0:DHE_RSA_AES_256_CBC_SHA1:32) (Exim 4.60) (envelope-from ) id 1MvXnN-0001pM-L8 for bug-gnu-emacs@gnu.org; Wed, 07 Oct 2009 10:47:14 -0400 Original-Received: from rzlab.ucr.edu (rzlab.ucr.edu [127.0.0.1]) by rzlab.ucr.edu (8.14.3/8.14.3/Debian-5) with ESMTP id n97El9kM030511; Wed, 7 Oct 2009 07:47:09 -0700 Original-Received: (from debbugs@localhost) by rzlab.ucr.edu (8.14.3/8.14.3/Submit) id n97EZ5ex028665; Wed, 7 Oct 2009 07:35:05 -0700 Resent-Date: Wed, 7 Oct 2009 07:35:05 -0700 X-Loop: owner@emacsbugs.donarmstrong.com Resent-From: Stefan Monnier Resent-To: bug-submit-list@donarmstrong.com Resent-CC: Emacs Bugs 2Resent-Date: Wed, 07 Oct 2009 14:35:05 +0000 Resent-Message-ID: Resent-Sender: owner@emacsbugs.donarmstrong.com X-Emacs-PR-Message: followup 4655 X-Emacs-PR-Package: emacs X-Emacs-PR-Keywords: Original-Received: via spool by 4655-submit@emacsbugs.donarmstrong.com id=B4655.125492575927837 (code B ref 4655); Wed, 07 Oct 2009 14:35:05 +0000 Original-Received: (at 4655) by emacsbugs.donarmstrong.com; 7 Oct 2009 14:29:19 +0000 X-Spam-Bayes: score:0.5 Bayes not run. spammytokens:Tokens not available. hammytokens:Tokens not available. Original-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" Original-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 Original-Received: by pastel.home (Postfix, from userid 20848) id DF21E81F0; Wed, 7 Oct 2009 10:29:11 -0400 (EDT) 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) X-detected-operating-system: by monty-python.gnu.org: GNU/Linux 2.6 (newer, 2) Resent-Date: Wed, 07 Oct 2009 10:47:18 -0400 X-BeenThere: bug-gnu-emacs@gnu.org X-Mailman-Version: 2.1.5 Precedence: list List-Id: "Bug reports for GNU Emacs, the Swiss army knife of text editors" List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Original-Sender: bug-gnu-emacs-bounces+geb-bug-gnu-emacs=m.gmane.org@gnu.org Errors-To: bug-gnu-emacs-bounces+geb-bug-gnu-emacs=m.gmane.org@gnu.org Xref: news.gmane.org gmane.emacs.bugs:31762 Archived-At: >> 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"