From mboxrd@z Thu Jan 1 00:00:00 1970 Path: news.gmane.org!not-for-mail From: David Kastrup Newsgroups: gmane.emacs.devel Subject: Re: Changing of line format and undo Date: Wed, 21 Jun 2006 18:31:18 +0200 Message-ID: <858xnqxyg9.fsf@lola.goethe.zz> References: <44987375.2010000@student.lu.se> <449961F6.6020001@student.lu.se> <85mzc6y204.fsf@lola.goethe.zz> <44996AE1.7020907@student.lu.se> NNTP-Posting-Host: main.gmane.org Mime-Version: 1.0 Content-Type: text/plain; charset=us-ascii X-Trace: sea.gmane.org 1150907543 15958 80.91.229.2 (21 Jun 2006 16:32:23 GMT) X-Complaints-To: usenet@sea.gmane.org NNTP-Posting-Date: Wed, 21 Jun 2006 16:32:23 +0000 (UTC) Cc: Eli Zaretskii , emacs-devel@gnu.org Original-X-From: emacs-devel-bounces+ged-emacs-devel=m.gmane.org@gnu.org Wed Jun 21 18:32:20 2006 Return-path: Envelope-to: ged-emacs-devel@m.gmane.org Original-Received: from lists.gnu.org ([199.232.76.165]) by ciao.gmane.org with esmtp (Exim 4.43) id 1Ft5cc-0000xh-3E for ged-emacs-devel@m.gmane.org; Wed, 21 Jun 2006 18:32:06 +0200 Original-Received: from localhost ([127.0.0.1] helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.43) id 1Ft5cb-000428-LF for ged-emacs-devel@m.gmane.org; Wed, 21 Jun 2006 12:32:05 -0400 Original-Received: from mailman by lists.gnu.org with tmda-scanned (Exim 4.43) id 1Ft5cQ-00041L-LC for emacs-devel@gnu.org; Wed, 21 Jun 2006 12:31:54 -0400 Original-Received: from exim by lists.gnu.org with spam-scanned (Exim 4.43) id 1Ft5cQ-000419-6H for emacs-devel@gnu.org; Wed, 21 Jun 2006 12:31:54 -0400 Original-Received: from [199.232.76.173] (helo=monty-python.gnu.org) by lists.gnu.org with esmtp (Exim 4.43) id 1Ft5cQ-000416-1v for emacs-devel@gnu.org; Wed, 21 Jun 2006 12:31:54 -0400 Original-Received: from [199.232.76.164] (helo=fencepost.gnu.org) by monty-python.gnu.org with esmtp (Exim 4.52) id 1Ft5nC-0005tL-NL for emacs-devel@gnu.org; Wed, 21 Jun 2006 12:43:02 -0400 Original-Received: from localhost ([127.0.0.1] helo=lola.goethe.zz) by fencepost.gnu.org with esmtp (Exim 4.34) id 1Ft5cP-0002UE-09; Wed, 21 Jun 2006 12:31:53 -0400 Original-Received: by lola.goethe.zz (Postfix, from userid 1002) id A8BF11C4D3B5; Wed, 21 Jun 2006 18:31:18 +0200 (CEST) Original-To: Lennart Borgman In-Reply-To: <44996AE1.7020907@student.lu.se> (Lennart Borgman's message of "Wed, 21 Jun 2006 17:50:57 +0200") User-Agent: Gnus/5.11 (Gnus v5.11) Emacs/22.0.50 (gnu/linux) 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:56056 Archived-At: Lennart Borgman writes: > David Kastrup wrote: >> Lennart Borgman writes: >> >> >>> Eli Zaretskii wrote: >>> >>>>> Date: Wed, 21 Jun 2006 00:15:17 +0200 >>>>> From: Lennart Borgman >>>>> >>>>> If you change line endings this change is not saved to undo. Is >>>>> this the expected behaviour? >>>>> >>>> If you mean "C-x RET f", then it doesn't really change anything. It >>>> just sets a buffer-local variable to some value. So there's nothing >>>> to undo. >>>> >>> That is an internal Emacs perpective. From a users point of view there >>> is truly a change. If you for example change the line endings the file >>> will be saved with this new line endings. >>> >>> BTW should not changes of this kind also set the buffer to modified? >>> >> >> What makes you think they don't? >> >> > Test this for example: > > (defun test-set-eol() > (interactive) > (let* ((coding buffer-file-coding-system) > (new-coding (coding-system-change-eol-conversion coding 2))) > (setq buffer-file-coding-system new-coding))) Very funny. setq most certainly does not trigger effects like a changed buffer modification flag. But setq is not a user-level command. Here is one that is: C-x RET f (translated from C-x f) runs the command set-buffer-file-coding-system which is an interactive compiled Lisp function in `mule.el'. It is bound to C-x RET f, . (set-buffer-file-coding-system CODING-SYSTEM &optional FORCE NOMODIFY) Set the file coding-system of the current buffer to CODING-SYSTEM. This means that when you save the buffer, it will be converted according to CODING-SYSTEM. For a list of possible values of CODING-SYSTEM, use M-x list-coding-systems. If CODING-SYSTEM leaves the text conversion unspecified, or if it leaves the end-of-line conversion unspecified, FORCE controls what to do. If FORCE is nil, get the unspecified aspect (or aspects) from the buffer's previous `buffer-file-coding-system' value (if it is specified there). Otherwise, leave it unspecified. This marks the buffer modified so that the succeeding M-x save-buffer surely saves the buffer with CODING-SYSTEM. From a program, if you don't want to mark the buffer modified, specify t for NOMODIFY. If you know exactly what coding system you want to use, just set the variable `buffer-file-coding-system' directly. -- David Kastrup, Kriemhildstr. 15, 44793 Bochum