(auto-save-list-file-prefix): Under MS-DOS, use `.s-'.
[bpt/emacs.git] / lisp / dos-fns.el
CommitLineData
007c61fa
RS
1;;; dos-fns.el --- MS-Dos specific functions.
2
3aaa90ef 3;; Copyright (C) 1991, 1993 Free Software Foundation, Inc.
007c61fa
RS
4
5;; Maintainer: Morten Welinder (terra@diku.dk)
6;; Keywords: internal
7
8;; This file is part of GNU Emacs.
9
10;; GNU Emacs is free software; you can redistribute it and/or modify
11;; it under the terms of the GNU General Public License as published by
12;; the Free Software Foundation; either version 2, or (at your option)
13;; any later version.
14
15;; GNU Emacs is distributed in the hope that it will be useful,
16;; but WITHOUT ANY WARRANTY; without even the implied warranty of
17;; MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
18;; GNU General Public License for more details.
19
20;; You should have received a copy of the GNU General Public License
21;; along with GNU Emacs; see the file COPYING. If not, write to
22;; the Free Software Foundation, 675 Mass Ave, Cambridge, MA 02139, USA.
23
24;;; Commentary:
25
26;; Part of this code is taken from (or derived from) demacs.
27
28;;; Code:
29
64852bcd 30;;; Add %t: into the mode line format just after the open-paren.
dde25849 31(let ((tail (member " %[(" mode-line-format)))
64852bcd
RS
32 (setcdr tail (cons (purecopy "%t:")
33 (cdr tail))))
007c61fa 34
35d6dd87
RS
35;; Use ";" instead of ":" as a path separator (from files.el).
36(setq path-separator ";")
37
38;; Set the null device (for compile.el).
39(setq grep-null-device "NUL")
40
41;; Set the grep regexp to match entries with drive letters.
42(setq grep-regexp-alist
43 '(("^\\(\\([a-zA-Z]:\\)?[^:( \t\n]+\\)[:( \t]+\\([0-9]+\\)[:) \t]" 1 3)))
44
007c61fa
RS
45(defvar file-name-buffer-file-type-alist
46 '(
594cabd7
RS
47 ("[:/].*config.sys$" . nil) ; config.sys text
48 ("\\.elc$" . t) ; emacs stuff
49 ("\\.\\(obj\\|exe\\|com\\|lib\\|sys\\|chk\\|out\\|bin\\|ico\\|pif\\)$" . t)
007c61fa 50 ; MS-Dos stuff
594cabd7 51 ("\\.\\(arc\\|zip\\|pak\\|lzh\\|zoo\\)$" . t)
007c61fa 52 ; Packers
594cabd7 53 ("\\.\\(a\\|o\\|tar\\|z\\|gz\\|taz\\)$" . t)
007c61fa 54 ; Unix stuff
594cabd7 55 ("\\.tp[ulpw]$" . t)
007c61fa 56 ; Borland Pascal stuff
21f2acd3 57 ("[:/]tags$" . t)
007c61fa 58 ; Emacs TAGS file
594cabd7
RS
59 )
60 "*Alist for distinguishing text files from binary files.
61Each element has the form (REGEXP . TYPE), where REGEXP is matched
62against the file name, and TYPE is nil for text, t for binary.")
007c61fa
RS
63
64(defun find-buffer-file-type (filename)
65 (let ((alist file-name-buffer-file-type-alist)
66 (found nil)
67 (code nil))
68 (let ((case-fold-search t))
69 (setq filename (file-name-sans-versions filename))
70 (while (and (not found) alist)
71 (if (string-match (car (car alist)) filename)
72 (setq code (cdr (car alist))
73 found t))
74 (setq alist (cdr alist))))
594cabd7
RS
75 (if found
76 (cond((memq code '(nil t)) code)
007c61fa
RS
77 ((and (symbolp code) (fboundp code))
78 (funcall code filename)))
79 default-buffer-file-type)))
80
81(defun find-file-binary (filename)
594cabd7 82 "Visit file FILENAME and treat it as binary."
007c61fa 83 (interactive "FFind file binary: ")
594cabd7 84 (let ((file-name-buffer-file-type-alist '(("" . t))))
007c61fa
RS
85 (find-file filename)))
86
87(defun find-file-text (filename)
594cabd7 88 "Visit file FILENAME and treat it as a text file."
007c61fa 89 (interactive "FFind file text: ")
594cabd7 90 (let ((file-name-buffer-file-type-alist '(("" . nil))))
007c61fa
RS
91 (find-file filename)))
92
93(defun find-file-not-found-set-buffer-file-type ()
94 (save-excursion
95 (set-buffer (current-buffer))
96 (setq buffer-file-type (find-buffer-file-type (buffer-file-name))))
97 nil)
98
99;;; To set the default file type on new files.
100(add-hook 'find-file-not-found-hooks 'find-file-not-found-set-buffer-file-type)
101
007c61fa
RS
102(defvar msdos-shells '("command.com" "4dos.com" "ndos.com")
103 "*List of shells that use `/c' instead of `-c' and a backslashed command.")
104
21f2acd3 105(defconst register-name-alist
007c61fa 106 '((ax . 0) (bx . 1) (cx . 2) (dx . 3) (si . 4) (di . 5)
21f2acd3
RS
107 (cflag . 6) (flags . 7)
108 (al . (0 . 0)) (bl . (1 . 0)) (cl . (2 . 0)) (dl . (3 . 0))
109 (ah . (0 . 1)) (bh . (1 . 1)) (ch . (2 . 1)) (dh . (3 . 1))))
007c61fa
RS
110
111(defun make-register ()
112 (make-vector 8 0))
113
114(defun register-value (regs name)
21f2acd3 115 (let ((where (cdr (assoc name register-name-alist))))
007c61fa
RS
116 (cond ((consp where)
117 (let ((tem (aref regs (car where))))
118 (if (zerop (cdr where))
119 (% tem 256)
120 (/ tem 256))))
121 ((numberp where)
122 (aref regs where))
123 (t nil))))
124
125(defun set-register-value (regs name value)
126 (and (numberp value)
21f2acd3
RS
127 (>= value 0)
128 (let ((where (cdr (assoc name register-name-alist))))
007c61fa 129 (cond ((consp where)
21f2acd3
RS
130 (let ((tem (aref regs (car where)))
131 (value (logand value 255)))
132 (aset regs
133 (car where)
134 (if (zerop (cdr where))
135 (logior (logand tem 65280) value)
136 (logior (logand tem 255) (lsh value 8))))))
007c61fa 137 ((numberp where)
21f2acd3 138 (aset regs where (logand value 65535))))))
007c61fa
RS
139 regs)
140
141(defsubst intdos (regs)
142 (int86 33 regs))
143
87485d6f
MW
144;; Extra stub to functions in src/frame.c
145;; Emacs aborts during dump if the following don't have a doc string.
146(defun window-frame (window)
147 "Return the frame that WINDOW resides on."
148 (selected-frame))
149(defun raise-frame (frame)
150 "Raise FRAME to the top of the desktop."
151 nil)
152(defun select-frame (frame &optional no-enter)
153 "Select FRAME for input events."
154 (selected-frame))