Mercurial > emacs
annotate lisp/w32-fns.el @ 14363:754031d2354f
Support for Font Lock mode.
author | Simon Marshall <simon@gnu.org> |
---|---|
date | Thu, 25 Jan 1996 10:27:31 +0000 |
parents | 83f275dcd93a |
children | bdff3ee6ee93 |
rev | line source |
---|---|
9803 | 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--")) | |
55 (purecopy '(-3 . "%p")) | |
56 (purecopy "-%-"))) | |
9803 | 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 | |
11743
824f238e0c64
(path-separator): Set to ";".
Richard M. Stallman <rms@gnu.org>
parents:
11399
diff
changeset
|
65 ;; 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
|
66 (setq path-separator ";") |
824f238e0c64
(path-separator): Set to ";".
Richard M. Stallman <rms@gnu.org>
parents:
11399
diff
changeset
|
67 |
12254
cf9fbf172b0d
(grep-null-device): Set to "NUL".
Richard M. Stallman <rms@gnu.org>
parents:
11743
diff
changeset
|
68 ;; Set the null device (for compile.el). |
cf9fbf172b0d
(grep-null-device): Set to "NUL".
Richard M. Stallman <rms@gnu.org>
parents:
11743
diff
changeset
|
69 (setq grep-null-device "NUL") |
cf9fbf172b0d
(grep-null-device): Set to "NUL".
Richard M. Stallman <rms@gnu.org>
parents:
11743
diff
changeset
|
70 |
cf9fbf172b0d
(grep-null-device): Set to "NUL".
Richard M. Stallman <rms@gnu.org>
parents:
11743
diff
changeset
|
71 ;; 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
|
72 (setq grep-regexp-alist |
cf9fbf172b0d
(grep-null-device): Set to "NUL".
Richard M. Stallman <rms@gnu.org>
parents:
11743
diff
changeset
|
73 '(("^\\(\\([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
|
74 |
9803 | 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. | |
94 Each element has the form (REGEXP . TYPE), where REGEXP is matched | |
95 against 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 | |
12254
cf9fbf172b0d
(grep-null-device): Set to "NUL".
Richard M. Stallman <rms@gnu.org>
parents:
11743
diff
changeset
|
135 ;;; For using attached Unix filesystems. |
cf9fbf172b0d
(grep-null-device): Set to "NUL".
Richard M. Stallman <rms@gnu.org>
parents:
11743
diff
changeset
|
136 (defun save-to-unix-hook () |
cf9fbf172b0d
(grep-null-device): Set to "NUL".
Richard M. Stallman <rms@gnu.org>
parents:
11743
diff
changeset
|
137 (save-excursion |
cf9fbf172b0d
(grep-null-device): Set to "NUL".
Richard M. Stallman <rms@gnu.org>
parents:
11743
diff
changeset
|
138 (setq buffer-file-type t)) |
cf9fbf172b0d
(grep-null-device): Set to "NUL".
Richard M. Stallman <rms@gnu.org>
parents:
11743
diff
changeset
|
139 nil) |
cf9fbf172b0d
(grep-null-device): Set to "NUL".
Richard M. Stallman <rms@gnu.org>
parents:
11743
diff
changeset
|
140 |
cf9fbf172b0d
(grep-null-device): Set to "NUL".
Richard M. Stallman <rms@gnu.org>
parents:
11743
diff
changeset
|
141 (defun revert-from-unix-hook () |
cf9fbf172b0d
(grep-null-device): Set to "NUL".
Richard M. Stallman <rms@gnu.org>
parents:
11743
diff
changeset
|
142 (save-excursion |
cf9fbf172b0d
(grep-null-device): Set to "NUL".
Richard M. Stallman <rms@gnu.org>
parents:
11743
diff
changeset
|
143 (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
|
144 nil) |
cf9fbf172b0d
(grep-null-device): Set to "NUL".
Richard M. Stallman <rms@gnu.org>
parents:
11743
diff
changeset
|
145 |
cf9fbf172b0d
(grep-null-device): Set to "NUL".
Richard M. Stallman <rms@gnu.org>
parents:
11743
diff
changeset
|
146 ;; 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
|
147 (defun using-unix-filesystems (flag) |
cf9fbf172b0d
(grep-null-device): Set to "NUL".
Richard M. Stallman <rms@gnu.org>
parents:
11743
diff
changeset
|
148 (if flag |
cf9fbf172b0d
(grep-null-device): Set to "NUL".
Richard M. Stallman <rms@gnu.org>
parents:
11743
diff
changeset
|
149 (progn |
cf9fbf172b0d
(grep-null-device): Set to "NUL".
Richard M. Stallman <rms@gnu.org>
parents:
11743
diff
changeset
|
150 (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
|
151 (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
|
152 (progn |
cf9fbf172b0d
(grep-null-device): Set to "NUL".
Richard M. Stallman <rms@gnu.org>
parents:
11743
diff
changeset
|
153 (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
|
154 (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
|
155 |
9803 | 156 ;;; Fix interface to (X-specific) mouse.el |
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 | |
11399 | 164 ;;; Set to a system sound if you want a fancy bell. |
165 (set-message-beep nil) | |
166 | |
9803 | 167 ;;; winnt.el ends here |