217
|
1 ;;; winnt.el --- Lisp routines for Windows NT.
|
|
2
|
|
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
|
|
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.
|
|
23
|
|
24 ;;; Commentary:
|
|
25
|
|
26 ;; (August 12, 1993)
|
|
27 ;; Created.
|
|
28
|
|
29 ;; (November 21, 1994)
|
|
30 ;; [C-M-backspace] defined.
|
|
31 ;; mode-line-format defined to show buffer file type.
|
|
32 ;; audio bell initialized.
|
|
33 ;;
|
|
34 ;; (March 18, 1997)
|
|
35 ;; Ported to XEmacs by Marc Paquette <marcpa@cam.org>
|
|
36 ;;
|
|
37
|
|
38 ;;; Code:
|
|
39
|
|
40 ;; Map delete and backspace
|
|
41 ;; Not sure this is really needed in XEmacs... --marcpa
|
|
42 (define-key global-map [(backspace)] 'backward-delete-char)
|
|
43 (define-key global-map [(delete)] 'delete-char)
|
|
44 (define-key global-map [(meta backspace)] 'backward-kill-word)
|
|
45 (define-key global-map [(control meta backspace)] 'backward-kill-sexp)
|
|
46
|
|
47 ;; Ignore case on file-name completion
|
|
48 (setq completion-ignore-case t)
|
|
49
|
|
50 ;; The cmd.exe shell uses the "/c" switch instead of the "-c" switch
|
|
51 ;; for executing its command line argument (from simple.el).
|
|
52 (setq shell-command-switch "/c")
|
|
53
|
|
54 ;; For appending suffixes to directories and files in shell completions.
|
|
55 (add-hook 'shell-mode-hook
|
|
56 '(lambda () (setq comint-completion-addsuffix '("\\" . " "))))
|
|
57
|
|
58 ;; Use ";" instead of ":" as a path separator (from files.el).
|
|
59 (setq path-separator ";")
|
|
60
|
|
61 ;; Set the null device (for compile.el).
|
|
62 (setq grep-null-device "NUL")
|
|
63
|
|
64 ;; Set the grep regexp to match entries with drive letters.
|
|
65 (setq grep-regexp-alist
|
|
66 '(("^\\(\\([a-zA-Z]:\\)?[^:( \t\n]+\\)[:( \t]+\\([0-9]+\\)[:) \t]" 1 3)))
|
|
67
|
|
68 ;; Taken from dos-fn.el ... don't want all that's in the file, maybe
|
|
69 ;; separate it out someday.
|
|
70
|
|
71 (defvar file-name-buffer-file-type-alist
|
|
72 '(
|
|
73 ("[:/].*config.sys$" . nil) ; config.sys text
|
|
74 ("\\.elc$" . t) ; emacs stuff
|
|
75 ("\\.\\(obj\\|exe\\|com\\|lib\\|sys\\|chk\\|out\\|bin\\|ico\\|pif\\)$" . t)
|
|
76 ; MS-Dos stuff
|
|
77 ("\\.\\(arc\\|zip\\|pak\\|lzh\\|zoo\\)$" . t)
|
|
78 ; Packers
|
|
79 ("\\.\\(a\\|o\\|tar\\|z\\|gz\\|taz\\)$" . t)
|
|
80 ; Unix stuff
|
|
81 ("\\.tp[ulpw]$" . t)
|
|
82 ; Borland Pascal stuff
|
|
83 )
|
|
84 "*Alist for distinguishing text files from binary files.
|
|
85 Each element has the form (REGEXP . TYPE), where REGEXP is matched
|
|
86 against the file name, and TYPE is nil for text, t for binary.")
|
|
87
|
|
88 (defun find-buffer-file-type (filename)
|
|
89 (let ((alist file-name-buffer-file-type-alist)
|
|
90 (found nil)
|
|
91 (code nil))
|
|
92 (let ((case-fold-search t))
|
|
93 (setq filename (file-name-sans-versions filename))
|
|
94 (while (and (not found) alist)
|
|
95 (if (string-match (car (car alist)) filename)
|
|
96 (setq code (cdr (car alist))
|
|
97 found t))
|
|
98 (setq alist (cdr alist))))
|
|
99 (if found
|
|
100 (cond((memq code '(nil t)) code)
|
|
101 ((and (symbolp code) (fboundp code))
|
|
102 (funcall code filename)))
|
|
103 default-buffer-file-type)))
|
|
104
|
|
105 (defun find-file-binary (filename)
|
|
106 "Visit file FILENAME and treat it as binary."
|
|
107 (interactive "FFind file binary: ")
|
|
108 (let ((file-name-buffer-file-type-alist '(("" . t))))
|
|
109 (find-file filename)))
|
|
110
|
|
111 (defun find-file-text (filename)
|
|
112 "Visit file FILENAME and treat it as a text file."
|
|
113 (interactive "FFind file text: ")
|
|
114 (let ((file-name-buffer-file-type-alist '(("" . nil))))
|
|
115 (find-file filename)))
|
|
116
|
|
117 (defun find-file-not-found-set-buffer-file-type ()
|
|
118 (save-excursion
|
|
119 (set-buffer (current-buffer))
|
|
120 (setq buffer-file-type (find-buffer-file-type (buffer-file-name))))
|
|
121 nil)
|
|
122
|
|
123 ;;; To set the default file type on new files.
|
|
124 (add-hook 'find-file-not-found-hooks 'find-file-not-found-set-buffer-file-type)
|
|
125
|
|
126 ;;; For using attached Unix filesystems.
|
|
127 (defun save-to-unix-hook ()
|
|
128 (save-excursion
|
|
129 (setq buffer-file-type t))
|
|
130 nil)
|
|
131
|
|
132 (defun revert-from-unix-hook ()
|
|
133 (save-excursion
|
|
134 (setq buffer-file-type (find-buffer-file-type (buffer-file-name))))
|
|
135 nil)
|
|
136
|
|
137 ;; Really should provide this capability at the drive letter granularity.
|
|
138 (defun using-unix-filesystems (flag)
|
|
139 "Read and write files without CR/LF translation, if FLAG is non-nil.
|
|
140 This is in effect assuming the files are on a remote Unix file system.
|
|
141 If FLAG is nil, resume using CR/LF translation as usual."
|
|
142 (if flag
|
|
143 (progn
|
|
144 (add-hook 'write-file-hooks 'save-to-unix-hook)
|
|
145 (add-hook 'after-save-hook 'revert-from-unix-hook))
|
|
146 (progn
|
|
147 (remove-hook 'write-file-hooks 'save-to-unix-hook)
|
|
148 (remove-hook 'after-save-hook 'revert-from-unix-hook))))
|
|
149
|
|
150 ;;; Avoid creating auto-save file names containing invalid characters
|
|
151 ;;; (primarily "*", eg. for the *mail* buffer).
|
|
152 (fset 'original-make-auto-save-file-name
|
|
153 (symbol-function 'make-auto-save-file-name))
|
|
154
|
|
155 (defun make-auto-save-file-name ()
|
|
156 "Return file name to use for auto-saves of current buffer.
|
|
157 Does not consider `auto-save-visited-file-name' as that variable is checked
|
|
158 before calling this function. You can redefine this for customization.
|
|
159 See also `auto-save-file-name-p'."
|
|
160 (let ((name (original-make-auto-save-file-name))
|
|
161 (start 0))
|
|
162 ;; destructively replace occurences of * or ? with $
|
|
163 (while (string-match "[?*]" name start)
|
|
164 (aset name (match-beginning 0) ?$)
|
|
165 (setq start (1+ (match-end 0))))
|
|
166 name))
|
|
167
|
|
168 ;; ### FIX ME: need to look at XEmacs xmouse.el versus FSF mouse.el
|
|
169 ;; and adjust accordingly: I think 'x-selections is an FSFism.
|
|
170 ;; --marcpa
|
|
171 ;;; Fix interface to (X-specific) mouse.el
|
|
172 (defun x-set-selection (type data)
|
|
173 (or type (setq type 'PRIMARY))
|
|
174 (put 'x-selections type data))
|
|
175
|
|
176 (defun x-get-selection (&optional type data-type)
|
|
177 (or type (setq type 'PRIMARY))
|
|
178 (get 'x-selections type))
|
|
179
|
|
180 ;; FSFisms
|
|
181 ;(fmakunbound 'font-menu-add-default)
|
|
182 ;(global-unset-key [C-down-mouse-1])
|
|
183 ;(global-unset-key [C-down-mouse-2])
|
|
184 ;(global-unset-key [C-down-mouse-3])
|
|
185
|
|
186 ;;; Set to a system sound if you want a fancy bell.
|
|
187 ;(set-message-beep nil)
|
|
188
|
|
189 ;;; winnt.el ends here
|