PREV UP next GNU Emacs Lisp Reference Manual

22.13: Files and MS-DOS

Emacs on MS-DOS makes a distinction between text files and binary files. This is necessary because ordinary text files on MS-DOS use a two character sequence between lines: carriage-return and linefeed (crlf). Emacs expects just a newline character (a linefeed) between lines. When Emacs reads or writes a text file on MS-DOS, it needs to convert the line separators. This means it needs to know which files are text files and which are binary. It makes this decision when visiting a file, and records the decision in the variable buffer-file-type for use when the file is saved.

See MS-DOS Subprocesses, for a related feature for subprocesses.

Variable: buffer-file-type
This variable, automatically local in each buffer, records the file type of the buffer's visited file. The value is nil for text, t for binary.
Function: find-buffer-file-type filename
This function determines whether file filename is a text file or a binary file. It returns nil for text, t for binary.
User Option: file-name-buffer-file-type-alist
This variable holds an alist for distinguishing text files from binary files. Each element has the form (regexp . type), where regexp is matched against the file name, and type may be is 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.
User Option: default-buffer-file-type
This variable specifies the default file type for files whose names don't indicate anything in particular. Its value should be nil for text, or t for binary.
Command: find-file-text filename
Like find-file, but treat the file as text regardless of its name.
Command: find-file-binary filename
Like find-file, but treat the file as binary regardless of its name.