Mercurial > emacs
comparison lisp/w32-fns.el @ 16028:fbe8d94bff00
(path-separator, grep-null-device, grep-regexp-alist)
(file-name-buffer-file-type-alist, find-buffer-file-type):
(find-file-not-found-set-buffer-file-type, find-file-binary):
(find-file-text, mode-line-format): Moved to dos-nt.el.
(save-to-unix-hook, revert-from-unix-hook)
(using-unix-filesystems): Functions removed.
author | Richard M. Stallman <rms@gnu.org> |
---|---|
date | Sun, 01 Sep 1996 17:10:56 +0000 |
parents | ac60bc3e89cd |
children | a5e9fa379097 |
comparison
equal
deleted
inserted
replaced
16027:9f2735842213 | 16028:fbe8d94bff00 |
---|---|
37 (define-key function-key-map [backspace] "\177") | 37 (define-key function-key-map [backspace] "\177") |
38 (define-key function-key-map [delete] "\C-d") | 38 (define-key function-key-map [delete] "\C-d") |
39 (define-key function-key-map [M-backspace] [?\M-\177]) | 39 (define-key function-key-map [M-backspace] [?\M-\177]) |
40 (define-key function-key-map [C-M-backspace] [\C-\M-delete]) | 40 (define-key function-key-map [C-M-backspace] [\C-\M-delete]) |
41 | 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 '(column-number-mode "C%c--")) | |
56 (purecopy '(-3 . "%p")) | |
57 (purecopy "-%-"))) | |
58 | |
59 ;; Ignore case on file-name completion | 42 ;; Ignore case on file-name completion |
60 (setq completion-ignore-case t) | 43 (setq completion-ignore-case t) |
61 | 44 |
62 ;; The cmd.exe shell uses the "/c" switch instead of the "-c" switch | 45 ;; The cmd.exe shell uses the "/c" switch instead of the "-c" switch |
63 ;; for executing its command line argument (from simple.el). | 46 ;; for executing its command line argument (from simple.el). |
64 (setq shell-command-switch "/c") | 47 (setq shell-command-switch "/c") |
65 | 48 |
66 ;; For appending suffixes to directories and files in shell completions. | 49 ;; For appending suffixes to directories and files in shell completions. |
67 (add-hook 'shell-mode-hook | 50 (add-hook 'shell-mode-hook |
68 '(lambda () (setq comint-completion-addsuffix '("\\" . " ")))) | 51 '(lambda () (setq comint-completion-addsuffix '("\\" . " ")))) |
69 | |
70 ;; Use ";" instead of ":" as a path separator (from files.el). | |
71 (setq path-separator ";") | |
72 | |
73 ;; Set the null device (for compile.el). | |
74 (setq grep-null-device "NUL") | |
75 | |
76 ;; Set the grep regexp to match entries with drive letters. | |
77 (setq grep-regexp-alist | |
78 '(("^\\(\\([a-zA-Z]:\\)?[^:( \t\n]+\\)[:( \t]+\\([0-9]+\\)[:) \t]" 1 3))) | |
79 | |
80 ;; Taken from dos-fn.el ... don't want all that's in the file, maybe | |
81 ;; separate it out someday. | |
82 | |
83 (defvar file-name-buffer-file-type-alist | |
84 '( | |
85 ("[:/].*config.sys$" . nil) ; config.sys text | |
86 ("\\.elc$" . t) ; emacs stuff | |
87 ("\\.\\(obj\\|exe\\|com\\|lib\\|sys\\|chk\\|out\\|bin\\|ico\\|pif\\)$" . t) | |
88 ; MS-Dos stuff | |
89 ("\\.\\(arc\\|zip\\|pak\\|lzh\\|zoo\\)$" . t) | |
90 ; Packers | |
91 ("\\.\\(a\\|o\\|tar\\|z\\|gz\\|taz\\)$" . t) | |
92 ; Unix stuff | |
93 ("\\.tp[ulpw]$" . t) | |
94 ; Borland Pascal stuff | |
95 ) | |
96 "*Alist for distinguishing text files from binary files. | |
97 Each element has the form (REGEXP . TYPE), where REGEXP is matched | |
98 against the file name, and TYPE is nil for text, t for binary.") | |
99 | |
100 (defun find-buffer-file-type (filename) | |
101 (let ((alist file-name-buffer-file-type-alist) | |
102 (found nil) | |
103 (code nil)) | |
104 (let ((case-fold-search t)) | |
105 (setq filename (file-name-sans-versions filename)) | |
106 (while (and (not found) alist) | |
107 (if (string-match (car (car alist)) filename) | |
108 (setq code (cdr (car alist)) | |
109 found t)) | |
110 (setq alist (cdr alist)))) | |
111 (if found | |
112 (cond((memq code '(nil t)) code) | |
113 ((and (symbolp code) (fboundp code)) | |
114 (funcall code filename))) | |
115 default-buffer-file-type))) | |
116 | |
117 (defun find-file-binary (filename) | |
118 "Visit file FILENAME and treat it as binary." | |
119 (interactive "FFind file binary: ") | |
120 (let ((file-name-buffer-file-type-alist '(("" . t)))) | |
121 (find-file filename))) | |
122 | |
123 (defun find-file-text (filename) | |
124 "Visit file FILENAME and treat it as a text file." | |
125 (interactive "FFind file text: ") | |
126 (let ((file-name-buffer-file-type-alist '(("" . nil)))) | |
127 (find-file filename))) | |
128 | |
129 (defun find-file-not-found-set-buffer-file-type () | |
130 (save-excursion | |
131 (set-buffer (current-buffer)) | |
132 (setq buffer-file-type (find-buffer-file-type (buffer-file-name)))) | |
133 nil) | |
134 | |
135 ;;; To set the default file type on new files. | |
136 (add-hook 'find-file-not-found-hooks 'find-file-not-found-set-buffer-file-type) | |
137 | |
138 ;;; For using attached Unix filesystems. | |
139 (defun save-to-unix-hook () | |
140 (save-excursion | |
141 (setq buffer-file-type t)) | |
142 nil) | |
143 | |
144 (defun revert-from-unix-hook () | |
145 (save-excursion | |
146 (setq buffer-file-type (find-buffer-file-type (buffer-file-name)))) | |
147 nil) | |
148 | |
149 ;; Really should provide this capability at the drive letter granularity. | |
150 (defun using-unix-filesystems (flag) | |
151 "Read and write files without CR/LF translation, if FLAG is non-nil. | |
152 This is in effect assuming the files are on a remote Unix file system. | |
153 If FLAG is nil, resume using CR/LF translation as usual." | |
154 (if flag | |
155 (progn | |
156 (add-hook 'write-file-hooks 'save-to-unix-hook) | |
157 (add-hook 'after-save-hook 'revert-from-unix-hook)) | |
158 (progn | |
159 (remove-hook 'write-file-hooks 'save-to-unix-hook) | |
160 (remove-hook 'after-save-hook 'revert-from-unix-hook)))) | |
161 | 52 |
162 ;;; Avoid creating auto-save file names containing invalid characters | 53 ;;; Avoid creating auto-save file names containing invalid characters |
163 ;;; (primarily "*", eg. for the *mail* buffer). | 54 ;;; (primarily "*", eg. for the *mail* buffer). |
164 (fset 'original-make-auto-save-file-name | 55 (fset 'original-make-auto-save-file-name |
165 (symbol-function 'make-auto-save-file-name)) | 56 (symbol-function 'make-auto-save-file-name)) |