Mercurial > emacs
annotate lisp/w32-fns.el @ 15197:a97349b06c2c
Comment changes.
author | Richard M. Stallman <rms@gnu.org> |
---|---|
date | Thu, 09 May 1996 23:21:54 +0000 |
parents | 72a1f82a6748 |
children | 12a9c8b48830 |
rev | line source |
---|---|
15003 | 1 ;;; winnt.el --- Lisp routines for Windows NT. |
14169 | 2 |
9803 | 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 | |
14169 | 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. | |
9803 | 23 |
24 ;;; Commentary: | |
25 | |
26 ;; (August 12, 1993) | |
11399 | 27 ;; Created. |
9803 | 28 |
11399 | 29 ;; (November 21, 1994) |
30 ;; [C-M-backspace] defined. | |
31 ;; mode-line-format defined to show buffer file type. | |
32 ;; audio bell initialized. | |
9803 | 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]) | |
11399 | 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--")) | |
14446
bdff3ee6ee93
(mode-line-format): Include column-number-mode.
Richard M. Stallman <rms@gnu.org>
parents:
14169
diff
changeset
|
55 (purecopy '(column-number-mode "C%c--")) |
11399 | 56 (purecopy '(-3 . "%p")) |
57 (purecopy "-%-"))) | |
9803 | 58 |
59 ;; Ignore case on file-name completion | |
60 (setq completion-ignore-case t) | |
61 | |
62 ;; The cmd.exe shell uses the "/c" switch instead of the "-c" switch | |
63 ;; for executing its command line argument (from simple.el). | |
64 (setq shell-command-switch "/c") | |
65 | |
11743
824f238e0c64
(path-separator): Set to ";".
Richard M. Stallman <rms@gnu.org>
parents:
11399
diff
changeset
|
66 ;; Use ";" instead of ":" as a path separator (from files.el). |
824f238e0c64
(path-separator): Set to ";".
Richard M. Stallman <rms@gnu.org>
parents:
11399
diff
changeset
|
67 (setq path-separator ";") |
824f238e0c64
(path-separator): Set to ";".
Richard M. Stallman <rms@gnu.org>
parents:
11399
diff
changeset
|
68 |
12254
cf9fbf172b0d
(grep-null-device): Set to "NUL".
Richard M. Stallman <rms@gnu.org>
parents:
11743
diff
changeset
|
69 ;; Set the null device (for compile.el). |
cf9fbf172b0d
(grep-null-device): Set to "NUL".
Richard M. Stallman <rms@gnu.org>
parents:
11743
diff
changeset
|
70 (setq grep-null-device "NUL") |
cf9fbf172b0d
(grep-null-device): Set to "NUL".
Richard M. Stallman <rms@gnu.org>
parents:
11743
diff
changeset
|
71 |
cf9fbf172b0d
(grep-null-device): Set to "NUL".
Richard M. Stallman <rms@gnu.org>
parents:
11743
diff
changeset
|
72 ;; Set the grep regexp to match entries with drive letters. |
cf9fbf172b0d
(grep-null-device): Set to "NUL".
Richard M. Stallman <rms@gnu.org>
parents:
11743
diff
changeset
|
73 (setq grep-regexp-alist |
cf9fbf172b0d
(grep-null-device): Set to "NUL".
Richard M. Stallman <rms@gnu.org>
parents:
11743
diff
changeset
|
74 '(("^\\(\\([a-zA-Z]:\\)?[^:( \t\n]+\\)[:( \t]+\\([0-9]+\\)[:) \t]" 1 3))) |
cf9fbf172b0d
(grep-null-device): Set to "NUL".
Richard M. Stallman <rms@gnu.org>
parents:
11743
diff
changeset
|
75 |
9803 | 76 ;; Taken from dos-fn.el ... don't want all that's in the file, maybe |
77 ;; separate it out someday. | |
78 | |
79 (defvar file-name-buffer-file-type-alist | |
80 '( | |
81 ("[:/].*config.sys$" . nil) ; config.sys text | |
82 ("\\.elc$" . t) ; emacs stuff | |
83 ("\\.\\(obj\\|exe\\|com\\|lib\\|sys\\|chk\\|out\\|bin\\|ico\\|pif\\)$" . t) | |
84 ; MS-Dos stuff | |
85 ("\\.\\(arc\\|zip\\|pak\\|lzh\\|zoo\\)$" . t) | |
86 ; Packers | |
87 ("\\.\\(a\\|o\\|tar\\|z\\|gz\\|taz\\)$" . t) | |
88 ; Unix stuff | |
89 ("\\.tp[ulpw]$" . t) | |
90 ; Borland Pascal stuff | |
91 ("[:/]tags$" . t) | |
92 ; Emacs TAGS file | |
93 ) | |
94 "*Alist for distinguishing text files from binary files. | |
95 Each element has the form (REGEXP . TYPE), where REGEXP is matched | |
96 against the file name, and TYPE is nil for text, t for binary.") | |
97 | |
98 (defun find-buffer-file-type (filename) | |
99 (let ((alist file-name-buffer-file-type-alist) | |
100 (found nil) | |
101 (code nil)) | |
102 (let ((case-fold-search t)) | |
103 (setq filename (file-name-sans-versions filename)) | |
104 (while (and (not found) alist) | |
105 (if (string-match (car (car alist)) filename) | |
106 (setq code (cdr (car alist)) | |
107 found t)) | |
108 (setq alist (cdr alist)))) | |
109 (if found | |
110 (cond((memq code '(nil t)) code) | |
111 ((and (symbolp code) (fboundp code)) | |
112 (funcall code filename))) | |
113 default-buffer-file-type))) | |
114 | |
115 (defun find-file-binary (filename) | |
116 "Visit file FILENAME and treat it as binary." | |
117 (interactive "FFind file binary: ") | |
118 (let ((file-name-buffer-file-type-alist '(("" . t)))) | |
119 (find-file filename))) | |
120 | |
121 (defun find-file-text (filename) | |
122 "Visit file FILENAME and treat it as a text file." | |
123 (interactive "FFind file text: ") | |
124 (let ((file-name-buffer-file-type-alist '(("" . nil)))) | |
125 (find-file filename))) | |
126 | |
127 (defun find-file-not-found-set-buffer-file-type () | |
128 (save-excursion | |
129 (set-buffer (current-buffer)) | |
130 (setq buffer-file-type (find-buffer-file-type (buffer-file-name)))) | |
131 nil) | |
132 | |
133 ;;; To set the default file type on new files. | |
134 (add-hook 'find-file-not-found-hooks 'find-file-not-found-set-buffer-file-type) | |
135 | |
12254
cf9fbf172b0d
(grep-null-device): Set to "NUL".
Richard M. Stallman <rms@gnu.org>
parents:
11743
diff
changeset
|
136 ;;; For using attached Unix filesystems. |
cf9fbf172b0d
(grep-null-device): Set to "NUL".
Richard M. Stallman <rms@gnu.org>
parents:
11743
diff
changeset
|
137 (defun save-to-unix-hook () |
cf9fbf172b0d
(grep-null-device): Set to "NUL".
Richard M. Stallman <rms@gnu.org>
parents:
11743
diff
changeset
|
138 (save-excursion |
cf9fbf172b0d
(grep-null-device): Set to "NUL".
Richard M. Stallman <rms@gnu.org>
parents:
11743
diff
changeset
|
139 (setq buffer-file-type t)) |
cf9fbf172b0d
(grep-null-device): Set to "NUL".
Richard M. Stallman <rms@gnu.org>
parents:
11743
diff
changeset
|
140 nil) |
cf9fbf172b0d
(grep-null-device): Set to "NUL".
Richard M. Stallman <rms@gnu.org>
parents:
11743
diff
changeset
|
141 |
cf9fbf172b0d
(grep-null-device): Set to "NUL".
Richard M. Stallman <rms@gnu.org>
parents:
11743
diff
changeset
|
142 (defun revert-from-unix-hook () |
cf9fbf172b0d
(grep-null-device): Set to "NUL".
Richard M. Stallman <rms@gnu.org>
parents:
11743
diff
changeset
|
143 (save-excursion |
cf9fbf172b0d
(grep-null-device): Set to "NUL".
Richard M. Stallman <rms@gnu.org>
parents:
11743
diff
changeset
|
144 (setq buffer-file-type (find-buffer-file-type (buffer-file-name)))) |
cf9fbf172b0d
(grep-null-device): Set to "NUL".
Richard M. Stallman <rms@gnu.org>
parents:
11743
diff
changeset
|
145 nil) |
cf9fbf172b0d
(grep-null-device): Set to "NUL".
Richard M. Stallman <rms@gnu.org>
parents:
11743
diff
changeset
|
146 |
cf9fbf172b0d
(grep-null-device): Set to "NUL".
Richard M. Stallman <rms@gnu.org>
parents:
11743
diff
changeset
|
147 ;; Really should provide this capability at the drive letter granularity. |
cf9fbf172b0d
(grep-null-device): Set to "NUL".
Richard M. Stallman <rms@gnu.org>
parents:
11743
diff
changeset
|
148 (defun using-unix-filesystems (flag) |
cf9fbf172b0d
(grep-null-device): Set to "NUL".
Richard M. Stallman <rms@gnu.org>
parents:
11743
diff
changeset
|
149 (if flag |
cf9fbf172b0d
(grep-null-device): Set to "NUL".
Richard M. Stallman <rms@gnu.org>
parents:
11743
diff
changeset
|
150 (progn |
cf9fbf172b0d
(grep-null-device): Set to "NUL".
Richard M. Stallman <rms@gnu.org>
parents:
11743
diff
changeset
|
151 (add-hook 'write-file-hooks 'save-to-unix-hook) |
cf9fbf172b0d
(grep-null-device): Set to "NUL".
Richard M. Stallman <rms@gnu.org>
parents:
11743
diff
changeset
|
152 (add-hook 'after-save-hook 'revert-from-unix-hook)) |
cf9fbf172b0d
(grep-null-device): Set to "NUL".
Richard M. Stallman <rms@gnu.org>
parents:
11743
diff
changeset
|
153 (progn |
cf9fbf172b0d
(grep-null-device): Set to "NUL".
Richard M. Stallman <rms@gnu.org>
parents:
11743
diff
changeset
|
154 (remove-hook 'write-file-hooks 'save-to-unix-hook) |
cf9fbf172b0d
(grep-null-device): Set to "NUL".
Richard M. Stallman <rms@gnu.org>
parents:
11743
diff
changeset
|
155 (remove-hook 'after-save-hook 'revert-from-unix-hook)))) |
cf9fbf172b0d
(grep-null-device): Set to "NUL".
Richard M. Stallman <rms@gnu.org>
parents:
11743
diff
changeset
|
156 |
15135
72a1f82a6748
(original-make-auto-save-file-name): New symbol bound
Geoff Voelker <voelker@cs.washington.edu>
parents:
15003
diff
changeset
|
157 ;;; Avoid creating auto-save file names containing illegal characters |
72a1f82a6748
(original-make-auto-save-file-name): New symbol bound
Geoff Voelker <voelker@cs.washington.edu>
parents:
15003
diff
changeset
|
158 ;;; (primarily "*", eg. for the *mail* buffer). |
72a1f82a6748
(original-make-auto-save-file-name): New symbol bound
Geoff Voelker <voelker@cs.washington.edu>
parents:
15003
diff
changeset
|
159 (fset 'original-make-auto-save-file-name |
72a1f82a6748
(original-make-auto-save-file-name): New symbol bound
Geoff Voelker <voelker@cs.washington.edu>
parents:
15003
diff
changeset
|
160 (symbol-function 'make-auto-save-file-name)) |
72a1f82a6748
(original-make-auto-save-file-name): New symbol bound
Geoff Voelker <voelker@cs.washington.edu>
parents:
15003
diff
changeset
|
161 |
72a1f82a6748
(original-make-auto-save-file-name): New symbol bound
Geoff Voelker <voelker@cs.washington.edu>
parents:
15003
diff
changeset
|
162 (defun make-auto-save-file-name () |
72a1f82a6748
(original-make-auto-save-file-name): New symbol bound
Geoff Voelker <voelker@cs.washington.edu>
parents:
15003
diff
changeset
|
163 "Return file name to use for auto-saves of current buffer. |
72a1f82a6748
(original-make-auto-save-file-name): New symbol bound
Geoff Voelker <voelker@cs.washington.edu>
parents:
15003
diff
changeset
|
164 Does not consider `auto-save-visited-file-name' as that variable is checked |
72a1f82a6748
(original-make-auto-save-file-name): New symbol bound
Geoff Voelker <voelker@cs.washington.edu>
parents:
15003
diff
changeset
|
165 before calling this function. You can redefine this for customization. |
72a1f82a6748
(original-make-auto-save-file-name): New symbol bound
Geoff Voelker <voelker@cs.washington.edu>
parents:
15003
diff
changeset
|
166 See also `auto-save-file-name-p'." |
72a1f82a6748
(original-make-auto-save-file-name): New symbol bound
Geoff Voelker <voelker@cs.washington.edu>
parents:
15003
diff
changeset
|
167 (let ((name (original-make-auto-save-file-name)) |
72a1f82a6748
(original-make-auto-save-file-name): New symbol bound
Geoff Voelker <voelker@cs.washington.edu>
parents:
15003
diff
changeset
|
168 (start 0)) |
72a1f82a6748
(original-make-auto-save-file-name): New symbol bound
Geoff Voelker <voelker@cs.washington.edu>
parents:
15003
diff
changeset
|
169 ;; destructively replace occurences of * or ? with $ |
72a1f82a6748
(original-make-auto-save-file-name): New symbol bound
Geoff Voelker <voelker@cs.washington.edu>
parents:
15003
diff
changeset
|
170 (while (string-match "[?*]" name start) |
72a1f82a6748
(original-make-auto-save-file-name): New symbol bound
Geoff Voelker <voelker@cs.washington.edu>
parents:
15003
diff
changeset
|
171 (aset name (match-beginning 0) ?$) |
72a1f82a6748
(original-make-auto-save-file-name): New symbol bound
Geoff Voelker <voelker@cs.washington.edu>
parents:
15003
diff
changeset
|
172 (setq start (1+ (match-end 0)))) |
72a1f82a6748
(original-make-auto-save-file-name): New symbol bound
Geoff Voelker <voelker@cs.washington.edu>
parents:
15003
diff
changeset
|
173 name)) |
72a1f82a6748
(original-make-auto-save-file-name): New symbol bound
Geoff Voelker <voelker@cs.washington.edu>
parents:
15003
diff
changeset
|
174 |
9803 | 175 ;;; Fix interface to (X-specific) mouse.el |
176 (defalias 'x-set-selection 'ignore) | |
177 (fset 'x-get-selection '(lambda (&rest rest) "")) | |
178 (fmakunbound 'font-menu-add-default) | |
179 (global-unset-key [C-down-mouse-1]) | |
180 (global-unset-key [C-down-mouse-2]) | |
181 (global-unset-key [C-down-mouse-3]) | |
182 | |
11399 | 183 ;;; Set to a system sound if you want a fancy bell. |
184 (set-message-beep nil) | |
185 | |
9803 | 186 ;;; winnt.el ends here |