;; dos-w32.el --- Functions shared among MS-DOS and W32 (NT/95) platforms
-;; Copyright (C) 1996, 2001-2011 Free Software Foundation, Inc.
+;; Copyright (C) 1996, 2001-2013 Free Software Foundation, Inc.
;; Maintainer: Geoff Voelker <voelker@cs.washington.edu>
;; Keywords: internal
;; Set the null device (for compile.el).
(setq null-device "NUL")
-;; For distinguishing file types based upon suffixes.
-(defvar file-name-buffer-file-type-alist
- '(
- ("[:/].*config.sys$" . nil) ; config.sys text
+;; For distinguishing file types based upon suffixes. DEPRECATED, DO NOT USE!
+(defcustom file-name-buffer-file-type-alist
+ '(("[:/].*config.sys$" . nil) ; config.sys text
("\\.\\(obj\\|exe\\|com\\|lib\\|sys\\|bin\\|ico\\|pif\\|class\\)$" . t)
; MS-Dos stuff
("\\.\\(dll\\|drv\\|386\\|vxd\\|fon\\|fnt\\|fot\\|ttf\\|grp\\)$" . t)
("\\.tp[ulpw]$" . t) ; borland Pascal stuff
("[:/]tags$" . nil) ; emacs TAGS file
)
- "*Alist for distinguishing text files from binary files.
+ "Alist used in the past for distinguishing text files from binary files.
Each element has the form (REGEXP . TYPE), where REGEXP is matched
-against the file name, and TYPE is nil for text, t for binary.")
+against the file name, and TYPE is nil for text, t for binary.
-;; Return the pair matching filename on file-name-buffer-file-type-alist,
-;; or nil otherwise.
-(defun find-buffer-file-type-match (filename)
- (let ((alist file-name-buffer-file-type-alist)
- (found nil))
- (let ((case-fold-search t))
- (setq filename (file-name-sans-versions filename))
- (while (and (not found) alist)
- (if (string-match (car (car alist)) filename)
- (setq found (car alist)))
- (setq alist (cdr alist)))
- found)))
-
-;; Don't check for untranslated file systems here.
-(defun find-buffer-file-type (filename)
- (let ((match (find-buffer-file-type-match filename))
- (code))
- (if (not match)
- (default-value 'buffer-file-type)
- (setq code (cdr match))
- (cond ((memq code '(nil t)) code)
- ((and (symbolp code) (fboundp code))
- (funcall code filename))))))
+This variable is deprecated, not used anywhere, and will soon be deleted."
+ :type '(repeat (cons regexp boolean))
+ :group 'dos-fns
+ :group 'w32)
+
+(make-obsolete-variable 'file-name-buffer-file-type-alist
+ 'file-coding-system-alist
+ "24.4")
(setq-default buffer-file-coding-system 'undecided-dos)
If it matches in `untranslated-filesystem-list':
If the file exists: `undecided'
If the file does not exist: `undecided-unix'
- If it matches in `file-name-buffer-file-type-alist':
- If the match is t (for binary): `no-conversion'
- If the match is nil (for dos-text): `undecided-dos'
Otherwise:
If the file exists: `undecided'
If the file does not exist default value of `buffer-file-coding-system'
be a cons cell of the form \(FILENAME . BUFFER\), where BUFFER is a buffer
into which the file's contents were already read, but not yet decoded.
-If operation is `write-region', the coding system is chosen based upon
-the value of `buffer-file-coding-system' and `buffer-file-type'. If
-`buffer-file-coding-system' is non-nil, its value is used. If it is
-nil and `buffer-file-type' is t, the coding system is `no-conversion'.
+If operation is `write-region', the coding system is chosen based
+upon the value of `buffer-file-coding-system'. If
+`buffer-file-coding-system' is non-nil, its value is used.
Otherwise, it is `undecided-dos'.
-The two most common situations are when DOS and Unix files are read
-and written, and their names do not match in
-`untranslated-filesystem-list' and `file-name-buffer-file-type-alist'.
-In these cases, the coding system initially will be `undecided'. As
-the file is read in the DOS case, the coding system will be changed to
-`undecided-dos' as CR/LFs are detected. As the file is read in the
-Unix case, the coding system will be changed to `undecided-unix' as
-LFs are detected. In both cases, `buffer-file-coding-system' will be
-set to the appropriate coding system, and the value of
-`buffer-file-coding-system' will be used when writing the file."
+The most common situation is when DOS and Unix files are read and
+written, and their names do not match in `untranslated-filesystem-list'.
+In these cases, the coding system initially will be `undecided'.
+As the file is read in the DOS case, the coding system will be
+changed to `undecided-dos' as CR/LFs are detected. As the file
+is read in the Unix case, the coding system will be changed to
+`undecided-unix' as LFs are detected. In both cases,
+`buffer-file-coding-system' will be set to the appropriate coding
+system, and the value of `buffer-file-coding-system' will be used
+when writing the file."
(let ((op (nth 0 command))
- (binary nil) (text nil)
(undecided nil) (undecided-unix nil)
target target-buf)
(cond ((eq op 'insert-file-contents)
(and (bufferp (cdr target))
(buffer-name (cdr target))))
(setq target (car target)))
- ;; First check for a file name that indicates
- ;; it is truly binary.
- (setq binary (find-buffer-file-type target))
- (cond (binary)
- ;; Next check for files that MUST use DOS eol conversion.
- ((find-buffer-file-type-match target)
- (setq text t))
- ;; For any other existing file, decide based on contents.
- ((or
+ (cond ((or
+ ;; For any existing file, decide based on contents.
(file-exists-p target)
;; If TARGET does not exist as a file, replace its
;; base name with TARGET-BUF and try again. This
;; Next check for a non-DOS file system.
((untranslated-file-p target)
(setq undecided-unix t)))
- (cond (binary '(no-conversion . no-conversion))
- (text '(undecided-dos . undecided-dos))
- (undecided-unix '(undecided-unix . undecided-unix))
+ (cond (undecided-unix '(undecided-unix . undecided-unix))
(undecided '(undecided . undecided))
(t (cons (default-value 'buffer-file-coding-system)
(default-value 'buffer-file-coding-system)))))
;; Normally this is used only in a non-file-visiting
;; buffer, because normally buffer-file-coding-system is non-nil
;; in a file-visiting buffer.
- (if buffer-file-type
- '(no-conversion . no-conversion)
- '(undecided-dos . undecided-dos)))))))
-
-(modify-coding-system-alist 'file "" 'find-buffer-file-type-coding-system)
+ '(undecided-dos . undecided-dos))))))
(defun find-file-binary (filename)
"Visit file FILENAME and treat it as binary."
(interactive "FFind file binary: ")
- (let ((file-name-buffer-file-type-alist '(("" . t))))
+ (let ((coding-system-for-read 'no-conversion))
(find-file filename)))
(defun find-file-text (filename)
"Visit file FILENAME and treat it as a text file."
(interactive "FFind file text: ")
- (let ((file-name-buffer-file-type-alist '(("" . nil))))
+ (let ((coding-system-for-read 'undecided-dos))
(find-file filename)))
(defun find-file-not-found-set-buffer-file-coding-system ()
(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)))))
+ nil)))
;;; To set the default coding system on new files.
(add-hook 'find-file-not-found-functions
;; directory separators changed to directory-sep-char.
(let ((name nil))
(setq name (mapconcat
- '(lambda (char)
- (if (and (<= ?A char) (<= char ?Z))
- (char-to-string (+ (- char ?A) ?a))
- (char-to-string char)))
+ (lambda (char)
+ (if (and (<= ?A char) (<= char ?Z))
+ (char-to-string (+ (- char ?A) ?a))
+ (char-to-string char)))
filename nil))
;; Use expand-file-name to canonicalize directory separators, except
;; with bare drive letters (which would have the cwd appended).
;;; Support for printing under DOS/Windows, see lpr.el and ps-print.el.
-(defvar direct-print-region-use-command-dot-com t
- "*Control whether command.com is used to print on Windows 9x.")
+(defcustom direct-print-region-use-command-dot-com t
+ "If non-nil, use command.com to print on Windows 9x."
+ :type 'boolean
+ :group 'dos-fns
+ :group 'w32)
;; Function to actually send data to the printer port.
;; Supports writing directly, and using various programs.
(apply 'call-process lpr-prog nil errbuf nil rest))
;; Run command.com to access printer port on Windows 9x, unless
;; we are supposed to append to an existing (non-empty) file,
- ;; to work around a bug in Windows 9x that prevents Win32
+ ;; to work around a bug in Windows 9x that prevents Windows
;; programs from accessing LPT ports reliably.
((and (eq system-type 'windows-nt)
(getenv "winbootdir")