Go to the first, previous, next, last section, table of contents.


MS-DOS File Types

Emacs on MS-DOS and on MS-Windows recognizes certain file names as text files or binary files. By "binary file" we mean a file of literal byte values that are not necessary meant to be characters. Emacs does no end-of-line conversion and no character code conversion for a binary file. Meanwhile, when you create a new file which is marked by its name as a "text file", Emacs uses DOS end-of-line conversion.

Variable: buffer-file-type
This variable, automatically buffer-local in each buffer, records the file type of the buffer's visited file. When a buffer does not specify a coding system with buffer-file-coding-system, this variable is used to determine which coding system to use when writing the contents of the buffer. It should be nil for text, t for binary. If it is t, the coding system is no-conversion. Otherwise, undecided-dos is used.

Normally this variable is set by visiting a file; it is set to nil if the file was visited without any actual conversion.

User Option: file-name-buffer-file-type-alist
This variable holds an alist for recognizing text and binary files. Each element has the form (regexp . type), where regexp is matched against the file name, and type may be nil for text, t for binary, or a function to call to compute which. If it is a function, then it is called with a single argument (the file name) and should return t or nil.

Emacs when running on MS-DOS or MS-Windows checks this alist to decide which coding system to use when reading a file. For a text file, undecided-dos is used. For a binary file, no-conversion is used.

If no element in this alist matches a given file name, then default-buffer-file-type says how to treat the file.

User Option: default-buffer-file-type
This variable says how to handle files for which file-name-buffer-file-type-alist says nothing about the type.

If this variable is non-nil, then these files are treated as binary: the coding system no-conversion is used. Otherwise, nothing special is done for them--the coding system is deduced solely from the file contents, in the usual Emacs fashion.


Go to the first, previous, next, last section, table of contents.