comparison lisp/dos-fns.el @ 15253:05b3a08b268f

(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-win32.el.
author Karl Heuer <kwzh@gnu.org>
date Fri, 17 May 1996 22:36:39 +0000
parents 160e99f12c6d
children 25dbb4494147
comparison
equal deleted inserted replaced
15252:11d64da21aa9 15253:05b3a08b268f
25 ;;; Commentary: 25 ;;; Commentary:
26 26
27 ;; Part of this code is taken from (or derived from) demacs. 27 ;; Part of this code is taken from (or derived from) demacs.
28 28
29 ;;; Code: 29 ;;; Code:
30
31 ;;; Add %t: into the mode line format just after the open-paren.
32 (let ((tail (member " %[(" mode-line-format)))
33 (setcdr tail (cons (purecopy "%t:")
34 (cdr tail))))
35
36 ;; Use ";" instead of ":" as a path separator (from files.el).
37 (setq path-separator ";")
38
39 ;; Set the null device (for compile.el).
40 (setq grep-null-device "NUL")
41
42 ;; Set the grep regexp to match entries with drive letters.
43 (setq grep-regexp-alist
44 '(("^\\(\\([a-zA-Z]:\\)?[^:( \t\n]+\\)[:( \t]+\\([0-9]+\\)[:) \t]" 1 3)))
45 30
46 ;; This overrides a trivial definition in files.el. 31 ;; This overrides a trivial definition in files.el.
47 (defun convert-standard-filename (filename) 32 (defun convert-standard-filename (filename)
48 "Convert a standard file's name to something suitable for the current OS. 33 "Convert a standard file's name to something suitable for the current OS.
49 This function's standard definition is trivial; it just returns the argument. 34 This function's standard definition is trivial; it just returns the argument.
91 ;; make sure the munged name ends with it also. 76 ;; make sure the munged name ends with it also.
92 (if (equal lastchar ?~) 77 (if (equal lastchar ?~)
93 (aset string (1- (length string)) lastchar)) 78 (aset string (1- (length string)) lastchar))
94 (concat dir string)))) 79 (concat dir string))))
95 80
96 (defvar file-name-buffer-file-type-alist
97 '(
98 ("[:/].*config.sys$" . nil) ; config.sys text
99 ("\\.elc$" . t) ; emacs stuff
100 ("\\.\\(obj\\|exe\\|com\\|lib\\|sys\\|chk\\|out\\|bin\\|ico\\|pif\\)$" . t)
101 ; MS-Dos stuff
102 ("\\.\\(arc\\|zip\\|pak\\|lzh\\|zoo\\)$" . t)
103 ; Packers
104 ("\\.\\(a\\|o\\|tar\\|z\\|gz\\|taz\\)$" . t)
105 ; Unix stuff
106 ("\\.tp[ulpw]$" . t)
107 ; Borland Pascal stuff
108 ("[:/]tags$" . t)
109 ; Emacs TAGS file
110 )
111 "*Alist for distinguishing text files from binary files.
112 Each element has the form (REGEXP . TYPE), where REGEXP is matched
113 against the file name, and TYPE is nil for text, t for binary.")
114
115 (defun find-buffer-file-type (filename)
116 (let ((alist file-name-buffer-file-type-alist)
117 (found nil)
118 (code nil))
119 (let ((case-fold-search t))
120 (setq filename (file-name-sans-versions filename))
121 (while (and (not found) alist)
122 (if (string-match (car (car alist)) filename)
123 (setq code (cdr (car alist))
124 found t))
125 (setq alist (cdr alist))))
126 (if found
127 (cond((memq code '(nil t)) code)
128 ((and (symbolp code) (fboundp code))
129 (funcall code filename)))
130 default-buffer-file-type)))
131
132 (defun find-file-binary (filename)
133 "Visit file FILENAME and treat it as binary."
134 (interactive "FFind file binary: ")
135 (let ((file-name-buffer-file-type-alist '(("" . t))))
136 (find-file filename)))
137
138 (defun find-file-text (filename)
139 "Visit file FILENAME and treat it as a text file."
140 (interactive "FFind file text: ")
141 (let ((file-name-buffer-file-type-alist '(("" . nil))))
142 (find-file filename)))
143
144 (defun find-file-not-found-set-buffer-file-type ()
145 (save-excursion
146 (set-buffer (current-buffer))
147 (setq buffer-file-type (find-buffer-file-type (buffer-file-name))))
148 nil)
149
150 ;;; To set the default file type on new files.
151 (add-hook 'find-file-not-found-hooks 'find-file-not-found-set-buffer-file-type)
152
153 (defvar msdos-shells '("command.com" "4dos.com" "ndos.com") 81 (defvar msdos-shells '("command.com" "4dos.com" "ndos.com")
154 "*List of shells that use `/c' instead of `-c' and a backslashed command.") 82 "*List of shells that use `/c' instead of `-c' and a backslashed command.")
155 83
156 (defconst register-name-alist 84 (defconst register-name-alist
157 '((ax . 0) (bx . 1) (cx . 2) (dx . 3) (si . 4) (di . 5) 85 '((ax . 0) (bx . 1) (cx . 2) (dx . 3) (si . 4) (di . 5)