From mboxrd@z Thu Jan 1 00:00:00 1970 Path: news.gmane.org!not-for-mail From: martin rudalics Newsgroups: gmane.emacs.bugs Subject: bug#1039: 23.0.60; emacs forgets EOL convention after revert-buffer Date: Sun, 28 Sep 2008 00:12:14 +0200 Message-ID: <48DEAFBE.1080806@gmx.at> References: <20080927211548.AF7DC1628122@tleilaxu> Reply-To: martin rudalics , 1039@emacsbugs.donarmstrong.com NNTP-Posting-Host: lo.gmane.org Mime-Version: 1.0 Content-Type: multipart/mixed; boundary="------------040406090001010100080608" X-Trace: ger.gmane.org 1222554625 22917 80.91.229.12 (27 Sep 2008 22:30:25 GMT) X-Complaints-To: usenet@ger.gmane.org NNTP-Posting-Date: Sat, 27 Sep 2008 22:30:25 +0000 (UTC) Cc: rfrancoise@debian.org To: Peter De Wachter , 1039@emacsbugs.donarmstrong.com Original-X-From: bug-gnu-emacs-bounces+geb-bug-gnu-emacs=m.gmane.org@gnu.org Sun Sep 28 00:31:22 2008 connect(): Connection refused 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 1KjiJs-00040J-Li for geb-bug-gnu-emacs@m.gmane.org; Sun, 28 Sep 2008 00:31:21 +0200 Original-Received: from localhost ([127.0.0.1]:41625 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.43) id 1KjiIp-0000Wy-PY for geb-bug-gnu-emacs@m.gmane.org; Sat, 27 Sep 2008 18:30:15 -0400 Original-Received: from mailman by lists.gnu.org with tmda-scanned (Exim 4.43) id 1KjiIZ-0000V0-Pq for bug-gnu-emacs@gnu.org; Sat, 27 Sep 2008 18:29:59 -0400 Original-Received: from exim by lists.gnu.org with spam-scanned (Exim 4.43) id 1KjiIX-0000Tm-Nh for bug-gnu-emacs@gnu.org; Sat, 27 Sep 2008 18:29:59 -0400 Original-Received: from [199.232.76.173] (port=34160 helo=monty-python.gnu.org) by lists.gnu.org with esmtp (Exim 4.43) id 1KjiIX-0000Ti-I1 for bug-gnu-emacs@gnu.org; Sat, 27 Sep 2008 18:29:57 -0400 Original-Received: from rzlab.ucr.edu ([138.23.92.77]:41519) by monty-python.gnu.org with esmtps (TLS-1.0:DHE_RSA_AES_256_CBC_SHA1:32) (Exim 4.60) (envelope-from ) id 1KjiIX-0000JS-4l for bug-gnu-emacs@gnu.org; Sat, 27 Sep 2008 18:29:57 -0400 Original-Received: from rzlab.ucr.edu (rzlab.ucr.edu [127.0.0.1]) by rzlab.ucr.edu (8.13.8/8.13.8/Debian-3) with ESMTP id m8RMTsRv028476; Sat, 27 Sep 2008 15:29:54 -0700 Original-Received: (from debbugs@localhost) by rzlab.ucr.edu (8.13.8/8.13.8/Submit) id m8RMP3Yj027426; Sat, 27 Sep 2008 15:25:03 -0700 X-Loop: don@donarmstrong.com Resent-From: martin rudalics Resent-To: bug-submit-list@donarmstrong.com Resent-CC: Emacs Bugs Resent-Date: Sat, 27 Sep 2008 22:25:03 +0000 Resent-Message-ID: Resent-Sender: don@donarmstrong.com X-Emacs-PR-Message: report 1039 X-Emacs-PR-Package: emacs X-Emacs-PR-Keywords: Original-Received: via spool by 1039-submit@emacsbugs.donarmstrong.com id=B1039.122255378126112 (code B ref 1039); Sat, 27 Sep 2008 22:25:03 +0000 Original-Received: (at 1039) by emacsbugs.donarmstrong.com; 27 Sep 2008 22:16:21 +0000 Original-Received: from mail.gmx.net (mail.gmx.net [213.165.64.20]) by rzlab.ucr.edu (8.13.8/8.13.8/Debian-3) with SMTP id m8RMGG29026105 for <1039@emacsbugs.donarmstrong.com>; Sat, 27 Sep 2008 15:16:17 -0700 Original-Received: (qmail invoked by alias); 27 Sep 2008 22:16:10 -0000 Original-Received: from 62-47-47-119.adsl.highway.telekom.at (EHLO [62.47.47.119]) [62.47.47.119] by mail.gmx.net (mp054) with SMTP; 28 Sep 2008 00:16:10 +0200 X-Authenticated: #14592706 X-Provags-ID: V01U2FsdGVkX181MRRiEeg1+YAw3a9/FGodbQlbTVb/1K5EDkErQg cNoI35cMNrq+Le User-Agent: Thunderbird 2.0.0.16 (Windows/20080708) In-Reply-To: <20080927211548.AF7DC1628122@tleilaxu> X-Y-GMX-Trusted: 0 X-FuHaFi: 0.78,0.5600000000000001 X-detected-operating-system: by monty-python.gnu.org: GNU/Linux 2.6 (newer, 3) Resent-Date: Sat, 27 Sep 2008 18:29:59 -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:20837 Archived-At: This is a multi-part message in MIME format. --------------040406090001010100080608 Content-Type: text/plain; charset=ISO-8859-15; format=flowed Content-Transfer-Encoding: 7bit > If you load a file with DOS line endings, and revert it with M-x > revert-buffer, emacs forgets the used EOL convention and will use > Unix line endings when writing the file. The inverse scenario of this is biting me for some time already. I'm currently using the attached patch. martin --------------040406090001010100080608 Content-Type: text/plain; name="revert.diff" Content-Transfer-Encoding: 7bit Content-Disposition: inline; filename="revert.diff" *** files.el.~1.999.~ 2008-09-22 07:39:31.937500000 +0200 --- files.el 2008-09-26 13:49:18.968750000 +0200 *************** *** 4437,4442 **** --- 4437,4443 ---- mechanism, this hook is not used.") (defvar revert-buffer-internal-hook) + (defvar revert-buffer-file-coding-system) (defun revert-buffer (&optional ignore-auto noconfirm preserve-modes) "Replace current buffer text with the text of the visited file on disk. *************** *** 4558,4571 **** ;; (called from insert-file-contents) to set ;; buffer-file-coding-system to a proper value. (kill-local-variable 'buffer-file-coding-system) ! ;; Note that this preserves point in an intelligent way. (if preserve-modes (let ((buffer-file-format buffer-file-format)) (insert-file-contents file-name (not auto-save-p) nil nil t)) (insert-file-contents file-name (not auto-save-p) ! nil nil t))))) ;; Recompute the truename in case changes in symlinks ;; have changed the truename. (setq buffer-file-truename --- 4559,4578 ---- ;; (called from insert-file-contents) to set ;; buffer-file-coding-system to a proper value. (kill-local-variable 'buffer-file-coding-system) ! ;; But in case something goes wrong there provide a ! ;; fallback coding system. ! (setq revert-buffer-file-coding-system ! (list revert-buffer-file-coding-system)) ;; Note that this preserves point in an intelligent way. (if preserve-modes (let ((buffer-file-format buffer-file-format)) (insert-file-contents file-name (not auto-save-p) nil nil t)) (insert-file-contents file-name (not auto-save-p) ! nil nil t)) ! ;; Remember this. ! (setq revert-buffer-file-coding-system ! buffer-file-coding-system)))) ;; Recompute the truename in case changes in symlinks ;; have changed the truename. (setq buffer-file-truename *** international/mule.el.~1.274.~ 2008-07-31 07:33:47.000000000 +0200 --- international/mule.el 2008-09-26 13:55:52.640625000 +0200 *************** *** 1146,1151 **** --- 1146,1163 ---- (put (intern name) 'coding-system-define-form form) (setq coding-system-alist (cons (list name) coding-system-alist))))) + ;;; This is nil initially, set to `buffer-file-coding-system' when the + ;;; latter is set, and to a list with that value as its only element + ;;; when the buffer shall be reverted. `after-insert-file-set-coding' + ;;; will use this value when `find-new-buffer-file-coding-system' does + ;;; not provide a useful value. + (defvar revert-buffer-file-coding-system nil + "The file coding system usable for reverting a buffer. + Internally used by when reverting a buffer and no other coding + system is provided.") + (make-variable-buffer-local 'revert-buffer-file-coding-system) + (put 'revert-buffer-file-coding-system 'permanent-local t) + (defun 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 *************** *** 1169,1174 **** --- 1181,1188 ---- (setq coding-system (merge-coding-systems coding-system buffer-file-coding-system))) (setq buffer-file-coding-system coding-system) + ;; And record its value here. + (setq revert-buffer-file-coding-system coding-system) ;; This is in case of an explicit call. Normally, `normal-mode' and ;; `set-buffer-major-mode-hook' take care of setting the table. (if (fboundp 'ucs-set-table-for-input) ; don't lose when building *************** *** 1860,1866 **** (setq buffer-file-coding-system-explicit coding-system-for-read)) (if last-coding-system-used (let ((coding-system ! (find-new-buffer-file-coding-system last-coding-system-used))) (when coding-system ;; Tell set-buffer-file-coding-system not to mark the file ;; as modified; we just read it, and it's supposed to be unmodified. --- 1874,1883 ---- (setq buffer-file-coding-system-explicit coding-system-for-read)) (if last-coding-system-used (let ((coding-system ! (or (find-new-buffer-file-coding-system last-coding-system-used) ! ;; Use the coding system before revertin the buffer if ! ;; we have nothing newer. ! (car-safe revert-buffer-file-coding-system)))) (when coding-system ;; Tell set-buffer-file-coding-system not to mark the file ;; as modified; we just read it, and it's supposed to be unmodified. --------------040406090001010100080608--