Update FSF's address.
[bpt/emacs.git] / lisp / w32-fns.el
CommitLineData
95ed0025 1;; winnt.el --- Lisp routines for Windows NT.
b578f267 2
95ed0025
RS
3;; Copyright (C) 1994 Free Software Foundation, Inc.
4
5;; Author: Geoff Voelker (voelker@cs.washington.edu)
6
7;; This file is part of GNU Emacs.
8
9;; GNU Emacs is free software; you can redistribute it and/or modify
10;; it under the terms of the GNU General Public License as published by
11;; the Free Software Foundation; either version 2, or (at your option)
12;; any later version.
13
14;; GNU Emacs is distributed in the hope that it will be useful,
15;; but WITHOUT ANY WARRANTY; without even the implied warranty of
16;; MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
17;; GNU General Public License for more details.
18
19;; You should have received a copy of the GNU General Public License
b578f267
EN
20;; along with GNU Emacs; see the file COPYING. If not, write to the
21;; Free Software Foundation, Inc., 59 Temple Place - Suite 330,
22;; Boston, MA 02111-1307, USA.
95ed0025
RS
23
24;;; Commentary:
25
26;; (August 12, 1993)
81b38822 27;; Created.
95ed0025 28
81b38822
KH
29;; (November 21, 1994)
30;; [C-M-backspace] defined.
31;; mode-line-format defined to show buffer file type.
32;; audio bell initialized.
95ed0025
RS
33
34;;; Code:
35
36;; Map delete and backspace
37(define-key function-key-map [backspace] "\177")
38(define-key function-key-map [delete] "\C-d")
39(define-key function-key-map [M-backspace] [?\M-\177])
81b38822
KH
40(define-key function-key-map [C-M-backspace] [\C-\M-delete])
41
42;; Show file type (text or binary) on modeline
43(setq-default mode-line-format
44 (list (purecopy "")
45 'mode-line-modified
46 'mode-line-buffer-identification
47 (purecopy " ")
48 'global-mode-string
49 (purecopy " %[(")
50 (purecopy "%t:")
51 'mode-name 'mode-line-process 'minor-mode-alist
52 (purecopy "%n")
53 (purecopy ")%]--")
54 (purecopy '(line-number-mode "L%l--"))
55 (purecopy '(-3 . "%p"))
56 (purecopy "-%-")))
95ed0025
RS
57
58;; Ignore case on file-name completion
59(setq completion-ignore-case t)
60
61;; The cmd.exe shell uses the "/c" switch instead of the "-c" switch
62;; for executing its command line argument (from simple.el).
63(setq shell-command-switch "/c")
64
98b17af9
RS
65;; Use ";" instead of ":" as a path separator (from files.el).
66(setq path-separator ";")
67
d99671d7
RS
68;; Set the null device (for compile.el).
69(setq grep-null-device "NUL")
70
71;; Set the grep regexp to match entries with drive letters.
72(setq grep-regexp-alist
73 '(("^\\(\\([a-zA-Z]:\\)?[^:( \t\n]+\\)[:( \t]+\\([0-9]+\\)[:) \t]" 1 3)))
74
95ed0025
RS
75;; Taken from dos-fn.el ... don't want all that's in the file, maybe
76;; separate it out someday.
77
78(defvar file-name-buffer-file-type-alist
79 '(
80 ("[:/].*config.sys$" . nil) ; config.sys text
81 ("\\.elc$" . t) ; emacs stuff
82 ("\\.\\(obj\\|exe\\|com\\|lib\\|sys\\|chk\\|out\\|bin\\|ico\\|pif\\)$" . t)
83 ; MS-Dos stuff
84 ("\\.\\(arc\\|zip\\|pak\\|lzh\\|zoo\\)$" . t)
85 ; Packers
86 ("\\.\\(a\\|o\\|tar\\|z\\|gz\\|taz\\)$" . t)
87 ; Unix stuff
88 ("\\.tp[ulpw]$" . t)
89 ; Borland Pascal stuff
90 ("[:/]tags$" . t)
91 ; Emacs TAGS file
92 )
93 "*Alist for distinguishing text files from binary files.
94Each element has the form (REGEXP . TYPE), where REGEXP is matched
95against the file name, and TYPE is nil for text, t for binary.")
96
97(defun find-buffer-file-type (filename)
98 (let ((alist file-name-buffer-file-type-alist)
99 (found nil)
100 (code nil))
101 (let ((case-fold-search t))
102 (setq filename (file-name-sans-versions filename))
103 (while (and (not found) alist)
104 (if (string-match (car (car alist)) filename)
105 (setq code (cdr (car alist))
106 found t))
107 (setq alist (cdr alist))))
108 (if found
109 (cond((memq code '(nil t)) code)
110 ((and (symbolp code) (fboundp code))
111 (funcall code filename)))
112 default-buffer-file-type)))
113
114(defun find-file-binary (filename)
115 "Visit file FILENAME and treat it as binary."
116 (interactive "FFind file binary: ")
117 (let ((file-name-buffer-file-type-alist '(("" . t))))
118 (find-file filename)))
119
120(defun find-file-text (filename)
121 "Visit file FILENAME and treat it as a text file."
122 (interactive "FFind file text: ")
123 (let ((file-name-buffer-file-type-alist '(("" . nil))))
124 (find-file filename)))
125
126(defun find-file-not-found-set-buffer-file-type ()
127 (save-excursion
128 (set-buffer (current-buffer))
129 (setq buffer-file-type (find-buffer-file-type (buffer-file-name))))
130 nil)
131
132;;; To set the default file type on new files.
133(add-hook 'find-file-not-found-hooks 'find-file-not-found-set-buffer-file-type)
134
d99671d7
RS
135;;; For using attached Unix filesystems.
136(defun save-to-unix-hook ()
137 (save-excursion
138 (setq buffer-file-type t))
139 nil)
140
141(defun revert-from-unix-hook ()
142 (save-excursion
143 (setq buffer-file-type (find-buffer-file-type (buffer-file-name))))
144 nil)
145
146;; Really should provide this capability at the drive letter granularity.
147(defun using-unix-filesystems (flag)
148 (if flag
149 (progn
150 (add-hook 'write-file-hooks 'save-to-unix-hook)
d99671d7
RS
151 (add-hook 'after-save-hook 'revert-from-unix-hook))
152 (progn
153 (remove-hook 'write-file-hooks 'save-to-unix-hook)
d99671d7
RS
154 (remove-hook 'after-save-hook 'revert-from-unix-hook))))
155
95ed0025 156;;; Fix interface to (X-specific) mouse.el
95ed0025
RS
157(defalias 'x-set-selection 'ignore)
158(fset 'x-get-selection '(lambda (&rest rest) ""))
159(fmakunbound 'font-menu-add-default)
160(global-unset-key [C-down-mouse-1])
161(global-unset-key [C-down-mouse-2])
162(global-unset-key [C-down-mouse-3])
163
81b38822
KH
164;;; Set to a system sound if you want a fancy bell.
165(set-message-beep nil)
166
95ed0025 167;;; winnt.el ends here