bug-gnu-emacs
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: setting eol-type for new files


From: Eli Zaretskii
Subject: Re: setting eol-type for new files
Date: Mon, 23 Oct 2000 14:28:07 +0200 (IST)

On Tue, 26 Sep 2000, I wrote:

> > > I can't use file-coding-system-alist because it is ignored for new
> > > files.  (This is the suspected bug I reported in my previous message.)
> > 
> > > I don't want to use auto-coding-alist because it overrides "Coding:"
> > > tags in the file.
> > 
> > ?? Which version of Emacs are you using?
> > 
> > I've just tested file-coding-system-alist on the current
> > development code and on Emacs 20.7.  Both Emacs works as I
> > expected, i.e, they pay attention to
> > file-coding-system-alist even for a new file, and the
> > specification of file-coding-system-alist doesn't override
> > coding: tag.
> 
> This problem might be specific to DOS/Windows versions of Emacs, which 
> install a non-default function via modify-coding-system-alist (see 
> find-buffer-file-type-coding-system on lisp/dos-w32.el).  I will look 
> into this when I have time.

I think I found the reason for this: the DOS/Windows versions of Emacs 
set up a find-file-not-found-hook which effectively undoes the usual 
Emacs machinery to set the buffer's coding system.

Stephen, could you please try the following patch and see if it solves 
your problems?  (Note that you will need to dump Emacs, after you 
byte-compile dos-w32.el, because dos-w32 is preloaded at build time.)

2000-10-23  Eli Zaretskii  <eliz@is.elta.co.il>

        * dos-w32.el (find-file-not-found-set-buffer-file-coding-system):
        Don't call find-buffer-file-type-coding-system.  Instead, just
        set eol-type to -unix if inhibit-eol-conversion is in effect, or
        if the file is on an untranslated filesystem.


*** lisp/dos-w32.e~0    Fri Dec 10 15:34:34 1999
--- lisp/dos-w32.el     Mon Oct 23 00:17:20 2000
***************
*** 177,186 ****
  (defun find-file-not-found-set-buffer-file-coding-system ()
    (save-excursion
      (set-buffer (current-buffer))
!     (let* ((dummy-insert-op (list 'insert-file-contents (buffer-file-name)))
!          (coding-system-pair
!           (find-buffer-file-type-coding-system dummy-insert-op)))
!       (setq buffer-file-coding-system (car coding-system-pair))
        (setq buffer-file-type (eq buffer-file-coding-system 'no-conversion)))))
  
  ;;; To set the default coding system on new files.
--- 177,192 ----
  (defun find-file-not-found-set-buffer-file-coding-system ()
    (save-excursion
      (set-buffer (current-buffer))
!     (let ((coding buffer-file-coding-system))
!       ;; buffer-file-coding-system is already set by
!       ;; find-operation-coding-system, which was called from
!       ;; insert-file-contents.  All that's left is to change
!       ;; the EOL conversion, if required by the user.
!       (when (and (null coding-system-for-read)
!                (or inhibit-eol-conversion
!                    (untranslated-file-p (buffer-file-name))))
!       (setq coding (coding-system-change-eol-conversion coding 0))
!       (setq buffer-file-coding-system coding))
        (setq buffer-file-type (eq buffer-file-coding-system 'no-conversion)))))
  
  ;;; To set the default coding system on new files.



reply via email to

[Prev in Thread] Current Thread [Next in Thread]