Switch to recommended form of GPLv3 permissions notice.
[bpt/emacs.git] / lisp / dos-w32.el
index 4768586..beadb18 100644 (file)
@@ -1,6 +1,7 @@
 ;; dos-w32.el --- Functions shared among MS-DOS and W32 (NT/95) platforms
 
-;; Copyright (C) 1996 Free Software Foundation, Inc.
+;; Copyright (C) 1996, 2001, 2002, 2003, 2004, 2005,
+;;   2006, 2007, 2008 Free Software Foundation, Inc.
 
 ;; Maintainer: Geoff Voelker <voelker@cs.washington.edu>
 ;; Keywords: internal
@@ -9,7 +10,7 @@
 
 ;; GNU Emacs is free software; you can redistribute it and/or modify
 ;; it under the terms of the GNU General Public License as published by
-;; the Free Software Foundation; either version 2, or (at your option)
+;; the Free Software Foundation; either version 3, or (at your option)
 ;; any later version.
 
 ;; GNU Emacs is distributed in the hope that it will be useful,
@@ -19,8 +20,8 @@
 
 ;; You should have received a copy of the GNU General Public License
 ;; along with GNU Emacs; see the file COPYING.  If not, write to the
-;; Free Software Foundation, Inc., 59 Temple Place - Suite 330,
-;; Boston, MA 02111-1307, USA.
+;; Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor,
+;; Boston, MA 02110-1301, USA.
 
 ;;; Commentary:
 
@@ -73,6 +74,9 @@ against the file name, and TYPE is nil for text, t for binary.")
        (setq alist (cdr alist)))
       found)))
 
+;; Silence compiler. Defined in src/buffer.c on DOS_NT.
+(defvar default-buffer-file-type)
+
 ;; Don't check for untranslated file systems here.
 (defun find-buffer-file-type (filename)
   (let ((match (find-buffer-file-type-match filename))
@@ -87,10 +91,13 @@ against the file name, and TYPE is nil for text, t for binary.")
 (setq-default buffer-file-coding-system 'undecided-dos)
 
 (defun find-buffer-file-type-coding-system (command)
-  "Choose a coding system for a file operation.
-If COMMAND is `insert-file-contents', the coding system is chosen based
-upon the filename, the contents of `untranslated-filesystem-list' and
-`file-name-buffer-file-type-alist', and whether the file exists:
+  "Choose a coding system for a file operation in COMMAND.
+COMMAND is a list that specifies the operation, an I/O primitive, as its
+CAR, and the arguments that might be given to that operation as its CDR.
+If operation is `insert-file-contents', the coding system is chosen based
+upon the filename (the CAR of the arguments beyond the operation), the contents
+of `untranslated-filesystem-list' and `file-name-buffer-file-type-alist',
+and whether the file exists:
 
   If it matches in `untranslated-filesystem-list':
     If the file exists:                                        `undecided'
@@ -102,7 +109,11 @@ upon the filename, the contents of `untranslated-filesystem-list' and
     If the file exists:                                        `undecided'
     If the file does not exist:               default-buffer-file-coding-system
 
-If COMMAND is `write-region', the coding system is chosen based upon
+Note that the CAR of arguments to `insert-file-contents' operation could
+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'.
@@ -125,6 +136,13 @@ set to the appropriate coding system, and the value of
        (undecided nil) (undecided-unix nil))
     (cond ((eq op 'insert-file-contents)
           (setq target (nth 1 command))
+          ;; If TARGET is a cons cell, it has the form (FILENAME . BUFFER),
+          ;; where BUFFER is a buffer into which the file was already read,
+          ;; but its contents were not yet decoded.  (This form of the
+          ;; arguments is used, e.g., in arc-mode.el.)  This function
+          ;; doesn't care about the contents, it only looks at the file's
+          ;; name, which is the CAR of the cons cell.
+          (if (consp target) (setq target (car target)))
           ;; First check for a file name that indicates
           ;; it is truly binary.
           (setq binary (find-buffer-file-type target))
@@ -185,7 +203,7 @@ set to the appropriate coding system, and the value of
       (setq buffer-file-type (eq buffer-file-coding-system 'no-conversion)))))
 
 ;;; To set the default coding system on new files.
-(add-hook 'find-file-not-found-hooks
+(add-hook 'find-file-not-found-functions
          'find-file-not-found-set-buffer-file-coding-system)
 
 ;;; To accomodate filesystems that do not require CR/LF translation.
@@ -352,6 +370,8 @@ filesystem mounted on drive Z:, FILESYSTEM could be \"Z:\"."
 
 (defvar printer-name)
 
+(declare-function default-printer-name "w32fns.c")
+
 (defun direct-print-region-function (start end
                                           &optional lpr-prog
                                           delete-text buf display
@@ -378,13 +398,16 @@ indicates a specific program should be invoked."
         (printer (or (and (boundp 'dos-printer)
                           (stringp (symbol-value 'dos-printer))
                           (symbol-value 'dos-printer))
-                     printer-name)))
+                     printer-name
+                     (default-printer-name))))
     (or (eq coding-system-for-write 'no-conversion)
        (setq coding-system-for-write
              (aref eol-type 1)))       ; force conversion to DOS EOLs
     (direct-print-region-helper printer start end lpr-prog
                                delete-text buf display rest)))
 
+(defvar print-region-function)
+(defvar lpr-headers-switches)
 (setq print-region-function 'direct-print-region-function)
 
 ;; Set this to nil if you have a port of the `pr' program
@@ -411,10 +434,12 @@ indicates a specific program should be invoked."
   (let ((printer (or (and (boundp 'dos-ps-printer)
                          (stringp (symbol-value 'dos-ps-printer))
                          (symbol-value 'dos-ps-printer))
-                    ps-printer-name)))
+                    ps-printer-name
+                    (default-printer-name))))
     (direct-print-region-helper printer start end lpr-prog
                                delete-text buf display rest)))
 
+(defvar ps-print-region-function)
 (setq ps-print-region-function 'direct-ps-print-region-function)
 
 ;(setq ps-lpr-command "gs")
@@ -424,4 +449,5 @@ indicates a specific program should be invoked."
 
 (provide 'dos-w32)
 
+;; arch-tag: dcfefdd2-362f-4fbc-9141-9634f5f4d6a7
 ;;; dos-w32.el ends here