From mboxrd@z Thu Jan 1 00:00:00 1970 Path: news.gmane.org!not-for-mail From: Stefan Monnier Newsgroups: gmane.emacs.devel Subject: Re: buffer-swap-text Date: Tue, 21 Oct 2008 18:04:32 -0400 Message-ID: References: NNTP-Posting-Host: lo.gmane.org Mime-Version: 1.0 Content-Type: text/plain; charset=us-ascii X-Trace: ger.gmane.org 1224626718 15710 80.91.229.12 (21 Oct 2008 22:05:18 GMT) X-Complaints-To: usenet@ger.gmane.org NNTP-Posting-Date: Tue, 21 Oct 2008 22:05:18 +0000 (UTC) Cc: emacs-devel@gnu.org To: Eli Zaretskii Original-X-From: emacs-devel-bounces+ged-emacs-devel=m.gmane.org@gnu.org Wed Oct 22 00:06:18 2008 connect(): Connection refused Return-path: Envelope-to: ged-emacs-devel@m.gmane.org Original-Received: from lists.gnu.org ([199.232.76.165]) by lo.gmane.org with esmtp (Exim 4.50) id 1KsPMR-0006Rj-GU for ged-emacs-devel@m.gmane.org; Wed, 22 Oct 2008 00:05:55 +0200 Original-Received: from localhost ([127.0.0.1]:42214 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.43) id 1KsPLM-0005kd-2J for ged-emacs-devel@m.gmane.org; Tue, 21 Oct 2008 18:04:48 -0400 Original-Received: from mailman by lists.gnu.org with tmda-scanned (Exim 4.43) id 1KsPLG-0005kR-SZ for emacs-devel@gnu.org; Tue, 21 Oct 2008 18:04:42 -0400 Original-Received: from exim by lists.gnu.org with spam-scanned (Exim 4.43) id 1KsPLF-0005kA-FW for emacs-devel@gnu.org; Tue, 21 Oct 2008 18:04:42 -0400 Original-Received: from [199.232.76.173] (port=40089 helo=monty-python.gnu.org) by lists.gnu.org with esmtp (Exim 4.43) id 1KsPLF-0005k7-8S for emacs-devel@gnu.org; Tue, 21 Oct 2008 18:04:41 -0400 Original-Received: from pruche.dit.umontreal.ca ([132.204.246.22]:49437) by monty-python.gnu.org with esmtp (Exim 4.60) (envelope-from ) id 1KsPLD-0002s8-49; Tue, 21 Oct 2008 18:04:39 -0400 Original-Received: from alfajor.home (vpn-132-204-232-223.acd.umontreal.ca [132.204.232.223]) by pruche.dit.umontreal.ca (8.14.1/8.14.1) with ESMTP id m9LM56xM030863; Tue, 21 Oct 2008 18:05:06 -0400 Original-Received: by alfajor.home (Postfix, from userid 20848) id D03861C178; Tue, 21 Oct 2008 18:04:32 -0400 (EDT) In-Reply-To: (Eli Zaretskii's message of "Tue, 21 Oct 2008 17:30:48 +0200") User-Agent: Gnus/5.13 (Gnus v5.13) Emacs/23.0.60 (gnu/linux) X-NAI-Spam-Score: 0 X-NAI-Spam-Rules: 1 Rules triggered RV3130=0 X-detected-operating-system: by monty-python.gnu.org: GNU/Linux 2.6 (newer, 3) X-BeenThere: emacs-devel@gnu.org X-Mailman-Version: 2.1.5 Precedence: list List-Id: "Emacs development discussions." List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Original-Sender: emacs-devel-bounces+ged-emacs-devel=m.gmane.org@gnu.org Errors-To: emacs-devel-bounces+ged-emacs-devel=m.gmane.org@gnu.org Xref: news.gmane.org gmane.emacs.devel:104789 Archived-At: >> > Should this function swap the value of buffer-file-coding-system as >> > well? Otherwise, we could confuse the user if the swapped text cannot >> > be saved with the current buffer's encoding, and we will then pop up >> > questions when the user tries to save. >> I see buffer-swap-text as a (very) low-level function. So, I'd >> rather let the code that uses it deal with things like >> buffer-file-coding-system. > I cannot imagine a situation where code that uses this function would > not want to copy buffer-file-coding-system. >> I don't think we have enough experience with it to decide whether >> that variable (or any other for that matter) needs to be swap >> alongside the buffer's text. > I'm okay with trying and erring like that, but I think that the only > reason this didn't come up yet is because the 2 sole users of this > function (tar-mode and pmail) swap text between a unibyte buffer and a > multibyte buffer, and saving is allowed only from the unibyte one (and > pmail is not yet used widely anyway). Could be. But I expect that 99.99% of the uses of buffer-swap-text will follow this model. Note also that the need to swap buffer-file-coding-system depends on how the file is saved. If the coding system to use is non-trivial, then writing the buffer-save functionality might become far from obvious (since the save might query the user about which coding-system to use, displaying the problematic chars, but these are in the "other" buffer rather than the one normally displayed), so I don't expect this use case to be common, and if it comes up, we'll probably have much larger problems to deal with than merely swapping buffer-file-coding-system. Furthermore, I'd expect that swapping might not always be right: most likely one of the two buffers will be a fresh new buffer, so swapping would mean that the old buffer gets a buffer-file-coding-system set to nil, which will be reflected in the modeline. Stefan