Mercurial > emacs
annotate lisp/dos-fns.el @ 15420:877d4b6fd768
(term-terminal-menu): Don't make a self-recursive keymap.
author | Richard M. Stallman <rms@gnu.org> |
---|---|
date | Wed, 12 Jun 1996 21:45:45 +0000 |
parents | 64095f6a315c |
children | 9f2735842213 |
rev | line source |
---|---|
5443 | 1 ;;; dos-fns.el --- MS-Dos specific functions. |
2 | |
14734 | 3 ;; Copyright (C) 1991, 1993, 1995, 1996 Free Software Foundation, Inc. |
5443 | 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 | |
14169 | 21 ;; along with GNU Emacs; see the file COPYING. If not, write to the |
22 ;; Free Software Foundation, Inc., 59 Temple Place - Suite 330, | |
23 ;; Boston, MA 02111-1307, USA. | |
5443 | 24 |
25 ;;; Commentary: | |
26 | |
27 ;; Part of this code is taken from (or derived from) demacs. | |
28 | |
29 ;;; Code: | |
30 | |
15257
25dbb4494147
Hold previous change until after the release.
Karl Heuer <kwzh@gnu.org>
parents:
15253
diff
changeset
|
31 ;;; Add %t: into the mode line format just after the open-paren. |
25dbb4494147
Hold previous change until after the release.
Karl Heuer <kwzh@gnu.org>
parents:
15253
diff
changeset
|
32 (let ((tail (member " %[(" mode-line-format))) |
25dbb4494147
Hold previous change until after the release.
Karl Heuer <kwzh@gnu.org>
parents:
15253
diff
changeset
|
33 (setcdr tail (cons (purecopy "%t:") |
25dbb4494147
Hold previous change until after the release.
Karl Heuer <kwzh@gnu.org>
parents:
15253
diff
changeset
|
34 (cdr tail)))) |
25dbb4494147
Hold previous change until after the release.
Karl Heuer <kwzh@gnu.org>
parents:
15253
diff
changeset
|
35 |
25dbb4494147
Hold previous change until after the release.
Karl Heuer <kwzh@gnu.org>
parents:
15253
diff
changeset
|
36 ;; Use ";" instead of ":" as a path separator (from files.el). |
25dbb4494147
Hold previous change until after the release.
Karl Heuer <kwzh@gnu.org>
parents:
15253
diff
changeset
|
37 (setq path-separator ";") |
25dbb4494147
Hold previous change until after the release.
Karl Heuer <kwzh@gnu.org>
parents:
15253
diff
changeset
|
38 |
25dbb4494147
Hold previous change until after the release.
Karl Heuer <kwzh@gnu.org>
parents:
15253
diff
changeset
|
39 ;; Set the null device (for compile.el). |
25dbb4494147
Hold previous change until after the release.
Karl Heuer <kwzh@gnu.org>
parents:
15253
diff
changeset
|
40 (setq grep-null-device "NUL") |
25dbb4494147
Hold previous change until after the release.
Karl Heuer <kwzh@gnu.org>
parents:
15253
diff
changeset
|
41 |
25dbb4494147
Hold previous change until after the release.
Karl Heuer <kwzh@gnu.org>
parents:
15253
diff
changeset
|
42 ;; Set the grep regexp to match entries with drive letters. |
25dbb4494147
Hold previous change until after the release.
Karl Heuer <kwzh@gnu.org>
parents:
15253
diff
changeset
|
43 (setq grep-regexp-alist |
25dbb4494147
Hold previous change until after the release.
Karl Heuer <kwzh@gnu.org>
parents:
15253
diff
changeset
|
44 '(("^\\(\\([a-zA-Z]:\\)?[^:( \t\n]+\\)[:( \t]+\\([0-9]+\\)[:) \t]" 1 3))) |
25dbb4494147
Hold previous change until after the release.
Karl Heuer <kwzh@gnu.org>
parents:
15253
diff
changeset
|
45 |
13913
4e4201bcea5d
(convert-standard-filename): New alternate definition.
Richard M. Stallman <rms@gnu.org>
parents:
13487
diff
changeset
|
46 ;; This overrides a trivial definition in files.el. |
4e4201bcea5d
(convert-standard-filename): New alternate definition.
Richard M. Stallman <rms@gnu.org>
parents:
13487
diff
changeset
|
47 (defun convert-standard-filename (filename) |
4e4201bcea5d
(convert-standard-filename): New alternate definition.
Richard M. Stallman <rms@gnu.org>
parents:
13487
diff
changeset
|
48 "Convert a standard file's name to something suitable for the current OS. |
4e4201bcea5d
(convert-standard-filename): New alternate definition.
Richard M. Stallman <rms@gnu.org>
parents:
13487
diff
changeset
|
49 This function's standard definition is trivial; it just returns the argument. |
4e4201bcea5d
(convert-standard-filename): New alternate definition.
Richard M. Stallman <rms@gnu.org>
parents:
13487
diff
changeset
|
50 However, on some systems, the function is redefined |
4e4201bcea5d
(convert-standard-filename): New alternate definition.
Richard M. Stallman <rms@gnu.org>
parents:
13487
diff
changeset
|
51 with a definition that really does change some file names." |
15187
d46c1e8bdb0d
(convert-standard-filename): Test msdos-long-file-names.
Richard M. Stallman <rms@gnu.org>
parents:
14734
diff
changeset
|
52 (if (or (msdos-long-file-names) |
d46c1e8bdb0d
(convert-standard-filename): Test msdos-long-file-names.
Richard M. Stallman <rms@gnu.org>
parents:
14734
diff
changeset
|
53 (not (stringp filename)) |
d46c1e8bdb0d
(convert-standard-filename): Test msdos-long-file-names.
Richard M. Stallman <rms@gnu.org>
parents:
14734
diff
changeset
|
54 (member (file-name-nondirectory filename) '("" "." ".."))) |
d46c1e8bdb0d
(convert-standard-filename): Test msdos-long-file-names.
Richard M. Stallman <rms@gnu.org>
parents:
14734
diff
changeset
|
55 filename |
d46c1e8bdb0d
(convert-standard-filename): Test msdos-long-file-names.
Richard M. Stallman <rms@gnu.org>
parents:
14734
diff
changeset
|
56 (let* ((dir (file-name-directory filename)) |
d46c1e8bdb0d
(convert-standard-filename): Test msdos-long-file-names.
Richard M. Stallman <rms@gnu.org>
parents:
14734
diff
changeset
|
57 (string (copy-sequence (file-name-nondirectory filename))) |
d46c1e8bdb0d
(convert-standard-filename): Test msdos-long-file-names.
Richard M. Stallman <rms@gnu.org>
parents:
14734
diff
changeset
|
58 (lastchar (aref string (1- (length string)))) |
d46c1e8bdb0d
(convert-standard-filename): Test msdos-long-file-names.
Richard M. Stallman <rms@gnu.org>
parents:
14734
diff
changeset
|
59 i firstdot) |
d46c1e8bdb0d
(convert-standard-filename): Test msdos-long-file-names.
Richard M. Stallman <rms@gnu.org>
parents:
14734
diff
changeset
|
60 ;; Change a leading period to a leading underscore. |
d46c1e8bdb0d
(convert-standard-filename): Test msdos-long-file-names.
Richard M. Stallman <rms@gnu.org>
parents:
14734
diff
changeset
|
61 (if (= (aref string 0) ?.) |
d46c1e8bdb0d
(convert-standard-filename): Test msdos-long-file-names.
Richard M. Stallman <rms@gnu.org>
parents:
14734
diff
changeset
|
62 (aset string 0 ?_)) |
d46c1e8bdb0d
(convert-standard-filename): Test msdos-long-file-names.
Richard M. Stallman <rms@gnu.org>
parents:
14734
diff
changeset
|
63 ;; Get rid of invalid characters. |
d46c1e8bdb0d
(convert-standard-filename): Test msdos-long-file-names.
Richard M. Stallman <rms@gnu.org>
parents:
14734
diff
changeset
|
64 (while (setq i (string-match |
d46c1e8bdb0d
(convert-standard-filename): Test msdos-long-file-names.
Richard M. Stallman <rms@gnu.org>
parents:
14734
diff
changeset
|
65 "[^-a-zA-Z0-9_.%~^$!#&{}@`'()\200-\376]" |
d46c1e8bdb0d
(convert-standard-filename): Test msdos-long-file-names.
Richard M. Stallman <rms@gnu.org>
parents:
14734
diff
changeset
|
66 string)) |
d46c1e8bdb0d
(convert-standard-filename): Test msdos-long-file-names.
Richard M. Stallman <rms@gnu.org>
parents:
14734
diff
changeset
|
67 (aset string i ?_)) |
d46c1e8bdb0d
(convert-standard-filename): Test msdos-long-file-names.
Richard M. Stallman <rms@gnu.org>
parents:
14734
diff
changeset
|
68 ;; If we don't have a period, |
d46c1e8bdb0d
(convert-standard-filename): Test msdos-long-file-names.
Richard M. Stallman <rms@gnu.org>
parents:
14734
diff
changeset
|
69 ;; and we have a dash or underscore that isn't the first char, |
d46c1e8bdb0d
(convert-standard-filename): Test msdos-long-file-names.
Richard M. Stallman <rms@gnu.org>
parents:
14734
diff
changeset
|
70 ;; change that to a period. |
d46c1e8bdb0d
(convert-standard-filename): Test msdos-long-file-names.
Richard M. Stallman <rms@gnu.org>
parents:
14734
diff
changeset
|
71 (if (and (not (string-match "\\." string)) |
d46c1e8bdb0d
(convert-standard-filename): Test msdos-long-file-names.
Richard M. Stallman <rms@gnu.org>
parents:
14734
diff
changeset
|
72 (setq i (string-match "[-_]" string 1))) |
d46c1e8bdb0d
(convert-standard-filename): Test msdos-long-file-names.
Richard M. Stallman <rms@gnu.org>
parents:
14734
diff
changeset
|
73 (aset string i ?\.)) |
d46c1e8bdb0d
(convert-standard-filename): Test msdos-long-file-names.
Richard M. Stallman <rms@gnu.org>
parents:
14734
diff
changeset
|
74 ;; If we don't have a period in the first 8 chars, insert one. |
d46c1e8bdb0d
(convert-standard-filename): Test msdos-long-file-names.
Richard M. Stallman <rms@gnu.org>
parents:
14734
diff
changeset
|
75 (if (> (or (string-match "\\." string) |
d46c1e8bdb0d
(convert-standard-filename): Test msdos-long-file-names.
Richard M. Stallman <rms@gnu.org>
parents:
14734
diff
changeset
|
76 (length string)) |
d46c1e8bdb0d
(convert-standard-filename): Test msdos-long-file-names.
Richard M. Stallman <rms@gnu.org>
parents:
14734
diff
changeset
|
77 8) |
d46c1e8bdb0d
(convert-standard-filename): Test msdos-long-file-names.
Richard M. Stallman <rms@gnu.org>
parents:
14734
diff
changeset
|
78 (setq string |
d46c1e8bdb0d
(convert-standard-filename): Test msdos-long-file-names.
Richard M. Stallman <rms@gnu.org>
parents:
14734
diff
changeset
|
79 (concat (substring string 0 8) |
d46c1e8bdb0d
(convert-standard-filename): Test msdos-long-file-names.
Richard M. Stallman <rms@gnu.org>
parents:
14734
diff
changeset
|
80 "." |
d46c1e8bdb0d
(convert-standard-filename): Test msdos-long-file-names.
Richard M. Stallman <rms@gnu.org>
parents:
14734
diff
changeset
|
81 (substring string 8)))) |
d46c1e8bdb0d
(convert-standard-filename): Test msdos-long-file-names.
Richard M. Stallman <rms@gnu.org>
parents:
14734
diff
changeset
|
82 (setq firstdot (or (string-match "\\." string) (1- (length string)))) |
d46c1e8bdb0d
(convert-standard-filename): Test msdos-long-file-names.
Richard M. Stallman <rms@gnu.org>
parents:
14734
diff
changeset
|
83 ;; Truncate to 3 chars after the first period. |
d46c1e8bdb0d
(convert-standard-filename): Test msdos-long-file-names.
Richard M. Stallman <rms@gnu.org>
parents:
14734
diff
changeset
|
84 (if (> (length string) (+ firstdot 4)) |
d46c1e8bdb0d
(convert-standard-filename): Test msdos-long-file-names.
Richard M. Stallman <rms@gnu.org>
parents:
14734
diff
changeset
|
85 (setq string (substring string 0 (+ firstdot 4)))) |
d46c1e8bdb0d
(convert-standard-filename): Test msdos-long-file-names.
Richard M. Stallman <rms@gnu.org>
parents:
14734
diff
changeset
|
86 ;; Change all periods except the first one into underscores. |
d46c1e8bdb0d
(convert-standard-filename): Test msdos-long-file-names.
Richard M. Stallman <rms@gnu.org>
parents:
14734
diff
changeset
|
87 (while (string-match "\\." string (1+ firstdot)) |
d46c1e8bdb0d
(convert-standard-filename): Test msdos-long-file-names.
Richard M. Stallman <rms@gnu.org>
parents:
14734
diff
changeset
|
88 (setq i (string-match "\\." string (1+ firstdot))) |
d46c1e8bdb0d
(convert-standard-filename): Test msdos-long-file-names.
Richard M. Stallman <rms@gnu.org>
parents:
14734
diff
changeset
|
89 (aset string i ?_)) |
d46c1e8bdb0d
(convert-standard-filename): Test msdos-long-file-names.
Richard M. Stallman <rms@gnu.org>
parents:
14734
diff
changeset
|
90 ;; If the last character of the original filename was `~', |
d46c1e8bdb0d
(convert-standard-filename): Test msdos-long-file-names.
Richard M. Stallman <rms@gnu.org>
parents:
14734
diff
changeset
|
91 ;; make sure the munged name ends with it also. |
d46c1e8bdb0d
(convert-standard-filename): Test msdos-long-file-names.
Richard M. Stallman <rms@gnu.org>
parents:
14734
diff
changeset
|
92 (if (equal lastchar ?~) |
d46c1e8bdb0d
(convert-standard-filename): Test msdos-long-file-names.
Richard M. Stallman <rms@gnu.org>
parents:
14734
diff
changeset
|
93 (aset string (1- (length string)) lastchar)) |
d46c1e8bdb0d
(convert-standard-filename): Test msdos-long-file-names.
Richard M. Stallman <rms@gnu.org>
parents:
14734
diff
changeset
|
94 (concat dir string)))) |
13913
4e4201bcea5d
(convert-standard-filename): New alternate definition.
Richard M. Stallman <rms@gnu.org>
parents:
13487
diff
changeset
|
95 |
15257
25dbb4494147
Hold previous change until after the release.
Karl Heuer <kwzh@gnu.org>
parents:
15253
diff
changeset
|
96 (defvar file-name-buffer-file-type-alist |
25dbb4494147
Hold previous change until after the release.
Karl Heuer <kwzh@gnu.org>
parents:
15253
diff
changeset
|
97 '( |
25dbb4494147
Hold previous change until after the release.
Karl Heuer <kwzh@gnu.org>
parents:
15253
diff
changeset
|
98 ("[:/].*config.sys$" . nil) ; config.sys text |
25dbb4494147
Hold previous change until after the release.
Karl Heuer <kwzh@gnu.org>
parents:
15253
diff
changeset
|
99 ("\\.elc$" . t) ; emacs stuff |
25dbb4494147
Hold previous change until after the release.
Karl Heuer <kwzh@gnu.org>
parents:
15253
diff
changeset
|
100 ("\\.\\(obj\\|exe\\|com\\|lib\\|sys\\|chk\\|out\\|bin\\|ico\\|pif\\)$" . t) |
25dbb4494147
Hold previous change until after the release.
Karl Heuer <kwzh@gnu.org>
parents:
15253
diff
changeset
|
101 ; MS-Dos stuff |
25dbb4494147
Hold previous change until after the release.
Karl Heuer <kwzh@gnu.org>
parents:
15253
diff
changeset
|
102 ("\\.\\(arc\\|zip\\|pak\\|lzh\\|zoo\\)$" . t) |
25dbb4494147
Hold previous change until after the release.
Karl Heuer <kwzh@gnu.org>
parents:
15253
diff
changeset
|
103 ; Packers |
25dbb4494147
Hold previous change until after the release.
Karl Heuer <kwzh@gnu.org>
parents:
15253
diff
changeset
|
104 ("\\.\\(a\\|o\\|tar\\|z\\|gz\\|taz\\)$" . t) |
25dbb4494147
Hold previous change until after the release.
Karl Heuer <kwzh@gnu.org>
parents:
15253
diff
changeset
|
105 ; Unix stuff |
25dbb4494147
Hold previous change until after the release.
Karl Heuer <kwzh@gnu.org>
parents:
15253
diff
changeset
|
106 ("\\.tp[ulpw]$" . t) |
25dbb4494147
Hold previous change until after the release.
Karl Heuer <kwzh@gnu.org>
parents:
15253
diff
changeset
|
107 ; Borland Pascal stuff |
25dbb4494147
Hold previous change until after the release.
Karl Heuer <kwzh@gnu.org>
parents:
15253
diff
changeset
|
108 ("[:/]tags$" . t) |
25dbb4494147
Hold previous change until after the release.
Karl Heuer <kwzh@gnu.org>
parents:
15253
diff
changeset
|
109 ; Emacs TAGS file |
25dbb4494147
Hold previous change until after the release.
Karl Heuer <kwzh@gnu.org>
parents:
15253
diff
changeset
|
110 ) |
25dbb4494147
Hold previous change until after the release.
Karl Heuer <kwzh@gnu.org>
parents:
15253
diff
changeset
|
111 "*Alist for distinguishing text files from binary files. |
25dbb4494147
Hold previous change until after the release.
Karl Heuer <kwzh@gnu.org>
parents:
15253
diff
changeset
|
112 Each element has the form (REGEXP . TYPE), where REGEXP is matched |
25dbb4494147
Hold previous change until after the release.
Karl Heuer <kwzh@gnu.org>
parents:
15253
diff
changeset
|
113 against the file name, and TYPE is nil for text, t for binary.") |
25dbb4494147
Hold previous change until after the release.
Karl Heuer <kwzh@gnu.org>
parents:
15253
diff
changeset
|
114 |
25dbb4494147
Hold previous change until after the release.
Karl Heuer <kwzh@gnu.org>
parents:
15253
diff
changeset
|
115 (defun find-buffer-file-type (filename) |
25dbb4494147
Hold previous change until after the release.
Karl Heuer <kwzh@gnu.org>
parents:
15253
diff
changeset
|
116 (let ((alist file-name-buffer-file-type-alist) |
25dbb4494147
Hold previous change until after the release.
Karl Heuer <kwzh@gnu.org>
parents:
15253
diff
changeset
|
117 (found nil) |
25dbb4494147
Hold previous change until after the release.
Karl Heuer <kwzh@gnu.org>
parents:
15253
diff
changeset
|
118 (code nil)) |
25dbb4494147
Hold previous change until after the release.
Karl Heuer <kwzh@gnu.org>
parents:
15253
diff
changeset
|
119 (let ((case-fold-search t)) |
25dbb4494147
Hold previous change until after the release.
Karl Heuer <kwzh@gnu.org>
parents:
15253
diff
changeset
|
120 (setq filename (file-name-sans-versions filename)) |
25dbb4494147
Hold previous change until after the release.
Karl Heuer <kwzh@gnu.org>
parents:
15253
diff
changeset
|
121 (while (and (not found) alist) |
25dbb4494147
Hold previous change until after the release.
Karl Heuer <kwzh@gnu.org>
parents:
15253
diff
changeset
|
122 (if (string-match (car (car alist)) filename) |
25dbb4494147
Hold previous change until after the release.
Karl Heuer <kwzh@gnu.org>
parents:
15253
diff
changeset
|
123 (setq code (cdr (car alist)) |
25dbb4494147
Hold previous change until after the release.
Karl Heuer <kwzh@gnu.org>
parents:
15253
diff
changeset
|
124 found t)) |
25dbb4494147
Hold previous change until after the release.
Karl Heuer <kwzh@gnu.org>
parents:
15253
diff
changeset
|
125 (setq alist (cdr alist)))) |
25dbb4494147
Hold previous change until after the release.
Karl Heuer <kwzh@gnu.org>
parents:
15253
diff
changeset
|
126 (if found |
25dbb4494147
Hold previous change until after the release.
Karl Heuer <kwzh@gnu.org>
parents:
15253
diff
changeset
|
127 (cond((memq code '(nil t)) code) |
25dbb4494147
Hold previous change until after the release.
Karl Heuer <kwzh@gnu.org>
parents:
15253
diff
changeset
|
128 ((and (symbolp code) (fboundp code)) |
25dbb4494147
Hold previous change until after the release.
Karl Heuer <kwzh@gnu.org>
parents:
15253
diff
changeset
|
129 (funcall code filename))) |
25dbb4494147
Hold previous change until after the release.
Karl Heuer <kwzh@gnu.org>
parents:
15253
diff
changeset
|
130 default-buffer-file-type))) |
25dbb4494147
Hold previous change until after the release.
Karl Heuer <kwzh@gnu.org>
parents:
15253
diff
changeset
|
131 |
25dbb4494147
Hold previous change until after the release.
Karl Heuer <kwzh@gnu.org>
parents:
15253
diff
changeset
|
132 (defun find-file-binary (filename) |
25dbb4494147
Hold previous change until after the release.
Karl Heuer <kwzh@gnu.org>
parents:
15253
diff
changeset
|
133 "Visit file FILENAME and treat it as binary." |
25dbb4494147
Hold previous change until after the release.
Karl Heuer <kwzh@gnu.org>
parents:
15253
diff
changeset
|
134 (interactive "FFind file binary: ") |
25dbb4494147
Hold previous change until after the release.
Karl Heuer <kwzh@gnu.org>
parents:
15253
diff
changeset
|
135 (let ((file-name-buffer-file-type-alist '(("" . t)))) |
25dbb4494147
Hold previous change until after the release.
Karl Heuer <kwzh@gnu.org>
parents:
15253
diff
changeset
|
136 (find-file filename))) |
25dbb4494147
Hold previous change until after the release.
Karl Heuer <kwzh@gnu.org>
parents:
15253
diff
changeset
|
137 |
25dbb4494147
Hold previous change until after the release.
Karl Heuer <kwzh@gnu.org>
parents:
15253
diff
changeset
|
138 (defun find-file-text (filename) |
25dbb4494147
Hold previous change until after the release.
Karl Heuer <kwzh@gnu.org>
parents:
15253
diff
changeset
|
139 "Visit file FILENAME and treat it as a text file." |
25dbb4494147
Hold previous change until after the release.
Karl Heuer <kwzh@gnu.org>
parents:
15253
diff
changeset
|
140 (interactive "FFind file text: ") |
25dbb4494147
Hold previous change until after the release.
Karl Heuer <kwzh@gnu.org>
parents:
15253
diff
changeset
|
141 (let ((file-name-buffer-file-type-alist '(("" . nil)))) |
25dbb4494147
Hold previous change until after the release.
Karl Heuer <kwzh@gnu.org>
parents:
15253
diff
changeset
|
142 (find-file filename))) |
25dbb4494147
Hold previous change until after the release.
Karl Heuer <kwzh@gnu.org>
parents:
15253
diff
changeset
|
143 |
25dbb4494147
Hold previous change until after the release.
Karl Heuer <kwzh@gnu.org>
parents:
15253
diff
changeset
|
144 (defun find-file-not-found-set-buffer-file-type () |
25dbb4494147
Hold previous change until after the release.
Karl Heuer <kwzh@gnu.org>
parents:
15253
diff
changeset
|
145 (save-excursion |
25dbb4494147
Hold previous change until after the release.
Karl Heuer <kwzh@gnu.org>
parents:
15253
diff
changeset
|
146 (set-buffer (current-buffer)) |
25dbb4494147
Hold previous change until after the release.
Karl Heuer <kwzh@gnu.org>
parents:
15253
diff
changeset
|
147 (setq buffer-file-type (find-buffer-file-type (buffer-file-name)))) |
25dbb4494147
Hold previous change until after the release.
Karl Heuer <kwzh@gnu.org>
parents:
15253
diff
changeset
|
148 nil) |
25dbb4494147
Hold previous change until after the release.
Karl Heuer <kwzh@gnu.org>
parents:
15253
diff
changeset
|
149 |
25dbb4494147
Hold previous change until after the release.
Karl Heuer <kwzh@gnu.org>
parents:
15253
diff
changeset
|
150 ;;; To set the default file type on new files. |
25dbb4494147
Hold previous change until after the release.
Karl Heuer <kwzh@gnu.org>
parents:
15253
diff
changeset
|
151 (add-hook 'find-file-not-found-hooks 'find-file-not-found-set-buffer-file-type) |
25dbb4494147
Hold previous change until after the release.
Karl Heuer <kwzh@gnu.org>
parents:
15253
diff
changeset
|
152 |
5443 | 153 (defvar msdos-shells '("command.com" "4dos.com" "ndos.com") |
154 "*List of shells that use `/c' instead of `-c' and a backslashed command.") | |
155 | |
7256
0f06f87f3c3b
(set-register-value): Setting the high byte of a
Richard M. Stallman <rms@gnu.org>
parents:
7087
diff
changeset
|
156 (defconst register-name-alist |
5443 | 157 '((ax . 0) (bx . 1) (cx . 2) (dx . 3) (si . 4) (di . 5) |
7256
0f06f87f3c3b
(set-register-value): Setting the high byte of a
Richard M. Stallman <rms@gnu.org>
parents:
7087
diff
changeset
|
158 (cflag . 6) (flags . 7) |
0f06f87f3c3b
(set-register-value): Setting the high byte of a
Richard M. Stallman <rms@gnu.org>
parents:
7087
diff
changeset
|
159 (al . (0 . 0)) (bl . (1 . 0)) (cl . (2 . 0)) (dl . (3 . 0)) |
0f06f87f3c3b
(set-register-value): Setting the high byte of a
Richard M. Stallman <rms@gnu.org>
parents:
7087
diff
changeset
|
160 (ah . (0 . 1)) (bh . (1 . 1)) (ch . (2 . 1)) (dh . (3 . 1)))) |
5443 | 161 |
162 (defun make-register () | |
163 (make-vector 8 0)) | |
164 | |
165 (defun register-value (regs name) | |
7256
0f06f87f3c3b
(set-register-value): Setting the high byte of a
Richard M. Stallman <rms@gnu.org>
parents:
7087
diff
changeset
|
166 (let ((where (cdr (assoc name register-name-alist)))) |
5443 | 167 (cond ((consp where) |
168 (let ((tem (aref regs (car where)))) | |
169 (if (zerop (cdr where)) | |
170 (% tem 256) | |
171 (/ tem 256)))) | |
172 ((numberp where) | |
173 (aref regs where)) | |
174 (t nil)))) | |
175 | |
176 (defun set-register-value (regs name value) | |
177 (and (numberp value) | |
7256
0f06f87f3c3b
(set-register-value): Setting the high byte of a
Richard M. Stallman <rms@gnu.org>
parents:
7087
diff
changeset
|
178 (>= value 0) |
0f06f87f3c3b
(set-register-value): Setting the high byte of a
Richard M. Stallman <rms@gnu.org>
parents:
7087
diff
changeset
|
179 (let ((where (cdr (assoc name register-name-alist)))) |
5443 | 180 (cond ((consp where) |
7256
0f06f87f3c3b
(set-register-value): Setting the high byte of a
Richard M. Stallman <rms@gnu.org>
parents:
7087
diff
changeset
|
181 (let ((tem (aref regs (car where))) |
0f06f87f3c3b
(set-register-value): Setting the high byte of a
Richard M. Stallman <rms@gnu.org>
parents:
7087
diff
changeset
|
182 (value (logand value 255))) |
0f06f87f3c3b
(set-register-value): Setting the high byte of a
Richard M. Stallman <rms@gnu.org>
parents:
7087
diff
changeset
|
183 (aset regs |
0f06f87f3c3b
(set-register-value): Setting the high byte of a
Richard M. Stallman <rms@gnu.org>
parents:
7087
diff
changeset
|
184 (car where) |
0f06f87f3c3b
(set-register-value): Setting the high byte of a
Richard M. Stallman <rms@gnu.org>
parents:
7087
diff
changeset
|
185 (if (zerop (cdr where)) |
0f06f87f3c3b
(set-register-value): Setting the high byte of a
Richard M. Stallman <rms@gnu.org>
parents:
7087
diff
changeset
|
186 (logior (logand tem 65280) value) |
0f06f87f3c3b
(set-register-value): Setting the high byte of a
Richard M. Stallman <rms@gnu.org>
parents:
7087
diff
changeset
|
187 (logior (logand tem 255) (lsh value 8)))))) |
5443 | 188 ((numberp where) |
7256
0f06f87f3c3b
(set-register-value): Setting the high byte of a
Richard M. Stallman <rms@gnu.org>
parents:
7087
diff
changeset
|
189 (aset regs where (logand value 65535)))))) |
5443 | 190 regs) |
191 | |
192 (defsubst intdos (regs) | |
193 (int86 33 regs)) | |
194 | |
14189
557b3d11a381
(ps-lpr-switches, ps-lpr-command): Just setq them;
Richard M. Stallman <rms@gnu.org>
parents:
14169
diff
changeset
|
195 ;; Support for printing under MS-DOS, see lpr.el and ps-print.el. |
557b3d11a381
(ps-lpr-switches, ps-lpr-command): Just setq them;
Richard M. Stallman <rms@gnu.org>
parents:
14169
diff
changeset
|
196 (defvar dos-printer "PRN" |
557b3d11a381
(ps-lpr-switches, ps-lpr-command): Just setq them;
Richard M. Stallman <rms@gnu.org>
parents:
14169
diff
changeset
|
197 "*The name of a local MS-DOS device to which data is sent for printing. |
557b3d11a381
(ps-lpr-switches, ps-lpr-command): Just setq them;
Richard M. Stallman <rms@gnu.org>
parents:
14169
diff
changeset
|
198 \(Note that PostScript files are sent to `dos-ps-printer', which see.\) |
557b3d11a381
(ps-lpr-switches, ps-lpr-command): Just setq them;
Richard M. Stallman <rms@gnu.org>
parents:
14169
diff
changeset
|
199 |
557b3d11a381
(ps-lpr-switches, ps-lpr-command): Just setq them;
Richard M. Stallman <rms@gnu.org>
parents:
14169
diff
changeset
|
200 Typical non-default settings would be \"LPT1\" to \"LPT3\" for |
557b3d11a381
(ps-lpr-switches, ps-lpr-command): Just setq them;
Richard M. Stallman <rms@gnu.org>
parents:
14169
diff
changeset
|
201 parallel printers, or \"COM1\" to \"COM4\" or \"AUX\" for serial |
557b3d11a381
(ps-lpr-switches, ps-lpr-command): Just setq them;
Richard M. Stallman <rms@gnu.org>
parents:
14169
diff
changeset
|
202 printers. You can also set it to a name of a file, in which |
557b3d11a381
(ps-lpr-switches, ps-lpr-command): Just setq them;
Richard M. Stallman <rms@gnu.org>
parents:
14169
diff
changeset
|
203 case the output gets appended to that file. |
557b3d11a381
(ps-lpr-switches, ps-lpr-command): Just setq them;
Richard M. Stallman <rms@gnu.org>
parents:
14169
diff
changeset
|
204 If you want to discard the printed output, set this to \"NUL\".") |
557b3d11a381
(ps-lpr-switches, ps-lpr-command): Just setq them;
Richard M. Stallman <rms@gnu.org>
parents:
14169
diff
changeset
|
205 |
557b3d11a381
(ps-lpr-switches, ps-lpr-command): Just setq them;
Richard M. Stallman <rms@gnu.org>
parents:
14169
diff
changeset
|
206 (defun dos-print-region-function (start end |
557b3d11a381
(ps-lpr-switches, ps-lpr-command): Just setq them;
Richard M. Stallman <rms@gnu.org>
parents:
14169
diff
changeset
|
207 &optional lpr-prog |
557b3d11a381
(ps-lpr-switches, ps-lpr-command): Just setq them;
Richard M. Stallman <rms@gnu.org>
parents:
14169
diff
changeset
|
208 delete-text buf display rest) |
557b3d11a381
(ps-lpr-switches, ps-lpr-command): Just setq them;
Richard M. Stallman <rms@gnu.org>
parents:
14169
diff
changeset
|
209 "MS-DOS-specific function to print the region on a printer. |
557b3d11a381
(ps-lpr-switches, ps-lpr-command): Just setq them;
Richard M. Stallman <rms@gnu.org>
parents:
14169
diff
changeset
|
210 Writes the region to the device or file which is a value of |
557b3d11a381
(ps-lpr-switches, ps-lpr-command): Just setq them;
Richard M. Stallman <rms@gnu.org>
parents:
14169
diff
changeset
|
211 `dos-printer' \(which see\). Ignores any arguments beyond |
557b3d11a381
(ps-lpr-switches, ps-lpr-command): Just setq them;
Richard M. Stallman <rms@gnu.org>
parents:
14169
diff
changeset
|
212 START and END." |
557b3d11a381
(ps-lpr-switches, ps-lpr-command): Just setq them;
Richard M. Stallman <rms@gnu.org>
parents:
14169
diff
changeset
|
213 |
557b3d11a381
(ps-lpr-switches, ps-lpr-command): Just setq them;
Richard M. Stallman <rms@gnu.org>
parents:
14169
diff
changeset
|
214 (write-region start end dos-printer t 0) |
557b3d11a381
(ps-lpr-switches, ps-lpr-command): Just setq them;
Richard M. Stallman <rms@gnu.org>
parents:
14169
diff
changeset
|
215 ;; Make each print-out start on a new page, but don't waste |
557b3d11a381
(ps-lpr-switches, ps-lpr-command): Just setq them;
Richard M. Stallman <rms@gnu.org>
parents:
14169
diff
changeset
|
216 ;; paper if there was a form-feed at the end of this file. |
557b3d11a381
(ps-lpr-switches, ps-lpr-command): Just setq them;
Richard M. Stallman <rms@gnu.org>
parents:
14169
diff
changeset
|
217 (if (not (char-equal (char-after (1- end)) ?\C-l)) |
557b3d11a381
(ps-lpr-switches, ps-lpr-command): Just setq them;
Richard M. Stallman <rms@gnu.org>
parents:
14169
diff
changeset
|
218 (write-region "\f" nil dos-printer t 0))) |
557b3d11a381
(ps-lpr-switches, ps-lpr-command): Just setq them;
Richard M. Stallman <rms@gnu.org>
parents:
14169
diff
changeset
|
219 |
557b3d11a381
(ps-lpr-switches, ps-lpr-command): Just setq them;
Richard M. Stallman <rms@gnu.org>
parents:
14169
diff
changeset
|
220 ;; Set this to nil if you have a port of the `lpr' program and |
557b3d11a381
(ps-lpr-switches, ps-lpr-command): Just setq them;
Richard M. Stallman <rms@gnu.org>
parents:
14169
diff
changeset
|
221 ;; you want to use it for printing. If the default setting is |
557b3d11a381
(ps-lpr-switches, ps-lpr-command): Just setq them;
Richard M. Stallman <rms@gnu.org>
parents:
14169
diff
changeset
|
222 ;; in effect, `lpr-command' and its switches are ignored when |
557b3d11a381
(ps-lpr-switches, ps-lpr-command): Just setq them;
Richard M. Stallman <rms@gnu.org>
parents:
14169
diff
changeset
|
223 ;; printing with `lpr-xxx' and `print-xxx'. |
557b3d11a381
(ps-lpr-switches, ps-lpr-command): Just setq them;
Richard M. Stallman <rms@gnu.org>
parents:
14169
diff
changeset
|
224 (setq print-region-function 'dos-print-region-function) |
557b3d11a381
(ps-lpr-switches, ps-lpr-command): Just setq them;
Richard M. Stallman <rms@gnu.org>
parents:
14169
diff
changeset
|
225 |
557b3d11a381
(ps-lpr-switches, ps-lpr-command): Just setq them;
Richard M. Stallman <rms@gnu.org>
parents:
14169
diff
changeset
|
226 ;; Set this to nil if you have a port of the `pr' program |
557b3d11a381
(ps-lpr-switches, ps-lpr-command): Just setq them;
Richard M. Stallman <rms@gnu.org>
parents:
14169
diff
changeset
|
227 ;; (e.g., from GNU Textutils), or if you have an `lpr' |
557b3d11a381
(ps-lpr-switches, ps-lpr-command): Just setq them;
Richard M. Stallman <rms@gnu.org>
parents:
14169
diff
changeset
|
228 ;; program (see above) that can print page headers. |
557b3d11a381
(ps-lpr-switches, ps-lpr-command): Just setq them;
Richard M. Stallman <rms@gnu.org>
parents:
14169
diff
changeset
|
229 ;; If `lpr-headers-switches' is non-nil (the default) and |
557b3d11a381
(ps-lpr-switches, ps-lpr-command): Just setq them;
Richard M. Stallman <rms@gnu.org>
parents:
14169
diff
changeset
|
230 ;; `print-region-function' is set to `dos-print-region-function', |
557b3d11a381
(ps-lpr-switches, ps-lpr-command): Just setq them;
Richard M. Stallman <rms@gnu.org>
parents:
14169
diff
changeset
|
231 ;; then requests to print page headers will be silently |
557b3d11a381
(ps-lpr-switches, ps-lpr-command): Just setq them;
Richard M. Stallman <rms@gnu.org>
parents:
14169
diff
changeset
|
232 ;; ignored, and `print-buffer' and `print-region' produce |
557b3d11a381
(ps-lpr-switches, ps-lpr-command): Just setq them;
Richard M. Stallman <rms@gnu.org>
parents:
14169
diff
changeset
|
233 ;; the same output as `lpr-buffer' and `lpr-region', accordingly. |
557b3d11a381
(ps-lpr-switches, ps-lpr-command): Just setq them;
Richard M. Stallman <rms@gnu.org>
parents:
14169
diff
changeset
|
234 (setq lpr-headers-switches "(page headers are not supported)") |
557b3d11a381
(ps-lpr-switches, ps-lpr-command): Just setq them;
Richard M. Stallman <rms@gnu.org>
parents:
14169
diff
changeset
|
235 |
557b3d11a381
(ps-lpr-switches, ps-lpr-command): Just setq them;
Richard M. Stallman <rms@gnu.org>
parents:
14169
diff
changeset
|
236 (defvar dos-ps-printer "PRN" |
557b3d11a381
(ps-lpr-switches, ps-lpr-command): Just setq them;
Richard M. Stallman <rms@gnu.org>
parents:
14169
diff
changeset
|
237 "*Method for printing PostScript files under MS-DOS. |
557b3d11a381
(ps-lpr-switches, ps-lpr-command): Just setq them;
Richard M. Stallman <rms@gnu.org>
parents:
14169
diff
changeset
|
238 |
557b3d11a381
(ps-lpr-switches, ps-lpr-command): Just setq them;
Richard M. Stallman <rms@gnu.org>
parents:
14169
diff
changeset
|
239 If the value is a string, then it is taken as the name of the |
557b3d11a381
(ps-lpr-switches, ps-lpr-command): Just setq them;
Richard M. Stallman <rms@gnu.org>
parents:
14169
diff
changeset
|
240 device to which PostScript files are written. By default it |
557b3d11a381
(ps-lpr-switches, ps-lpr-command): Just setq them;
Richard M. Stallman <rms@gnu.org>
parents:
14169
diff
changeset
|
241 is the default printer device; typical non-default settings |
557b3d11a381
(ps-lpr-switches, ps-lpr-command): Just setq them;
Richard M. Stallman <rms@gnu.org>
parents:
14169
diff
changeset
|
242 would be \"LPT1\" to \"LPT3\" for parallel printers, or \"COM1\" |
557b3d11a381
(ps-lpr-switches, ps-lpr-command): Just setq them;
Richard M. Stallman <rms@gnu.org>
parents:
14169
diff
changeset
|
243 to \"COM4\" or \"AUX\" for serial printers. You can also set it |
557b3d11a381
(ps-lpr-switches, ps-lpr-command): Just setq them;
Richard M. Stallman <rms@gnu.org>
parents:
14169
diff
changeset
|
244 to a name of a file, in which case the output gets appended |
557b3d11a381
(ps-lpr-switches, ps-lpr-command): Just setq them;
Richard M. Stallman <rms@gnu.org>
parents:
14169
diff
changeset
|
245 to that file. \(Note that `ps-print' package already has |
557b3d11a381
(ps-lpr-switches, ps-lpr-command): Just setq them;
Richard M. Stallman <rms@gnu.org>
parents:
14169
diff
changeset
|
246 facilities for printing to a file, so you might as well use |
557b3d11a381
(ps-lpr-switches, ps-lpr-command): Just setq them;
Richard M. Stallman <rms@gnu.org>
parents:
14169
diff
changeset
|
247 them instead of changing the setting of this variable.\) If |
557b3d11a381
(ps-lpr-switches, ps-lpr-command): Just setq them;
Richard M. Stallman <rms@gnu.org>
parents:
14169
diff
changeset
|
248 you want to silently discard the printed output, set this to \"NUL\". |
557b3d11a381
(ps-lpr-switches, ps-lpr-command): Just setq them;
Richard M. Stallman <rms@gnu.org>
parents:
14169
diff
changeset
|
249 |
557b3d11a381
(ps-lpr-switches, ps-lpr-command): Just setq them;
Richard M. Stallman <rms@gnu.org>
parents:
14169
diff
changeset
|
250 If the value is anything but a string, PostScript files will be |
557b3d11a381
(ps-lpr-switches, ps-lpr-command): Just setq them;
Richard M. Stallman <rms@gnu.org>
parents:
14169
diff
changeset
|
251 piped to the program given by `ps-lpr-command', with switches |
557b3d11a381
(ps-lpr-switches, ps-lpr-command): Just setq them;
Richard M. Stallman <rms@gnu.org>
parents:
14169
diff
changeset
|
252 given by `ps-lpr-switches', which see.") |
557b3d11a381
(ps-lpr-switches, ps-lpr-command): Just setq them;
Richard M. Stallman <rms@gnu.org>
parents:
14169
diff
changeset
|
253 |
557b3d11a381
(ps-lpr-switches, ps-lpr-command): Just setq them;
Richard M. Stallman <rms@gnu.org>
parents:
14169
diff
changeset
|
254 (setq ps-lpr-command "gs") |
557b3d11a381
(ps-lpr-switches, ps-lpr-command): Just setq them;
Richard M. Stallman <rms@gnu.org>
parents:
14169
diff
changeset
|
255 |
557b3d11a381
(ps-lpr-switches, ps-lpr-command): Just setq them;
Richard M. Stallman <rms@gnu.org>
parents:
14169
diff
changeset
|
256 (setq ps-lpr-switches '("-q" "-dNOPAUSE" "-sDEVICE=epson" "-r240x60" |
557b3d11a381
(ps-lpr-switches, ps-lpr-command): Just setq them;
Richard M. Stallman <rms@gnu.org>
parents:
14169
diff
changeset
|
257 "-sOutputFile=LPT1" "-")) |
557b3d11a381
(ps-lpr-switches, ps-lpr-command): Just setq them;
Richard M. Stallman <rms@gnu.org>
parents:
14169
diff
changeset
|
258 |
14380
874cd82cd2b4
(mode25): Moved from `src/dosfns.c' for backward compatibility.
Richard M. Stallman <rms@gnu.org>
parents:
14189
diff
changeset
|
259 ;; Backward compatibility for obsolescent functions which |
874cd82cd2b4
(mode25): Moved from `src/dosfns.c' for backward compatibility.
Richard M. Stallman <rms@gnu.org>
parents:
14189
diff
changeset
|
260 ;; set screen size. |
874cd82cd2b4
(mode25): Moved from `src/dosfns.c' for backward compatibility.
Richard M. Stallman <rms@gnu.org>
parents:
14189
diff
changeset
|
261 |
874cd82cd2b4
(mode25): Moved from `src/dosfns.c' for backward compatibility.
Richard M. Stallman <rms@gnu.org>
parents:
14189
diff
changeset
|
262 (defun mode25 () |
874cd82cd2b4
(mode25): Moved from `src/dosfns.c' for backward compatibility.
Richard M. Stallman <rms@gnu.org>
parents:
14189
diff
changeset
|
263 "Changes the number of screen rows to 25." |
874cd82cd2b4
(mode25): Moved from `src/dosfns.c' for backward compatibility.
Richard M. Stallman <rms@gnu.org>
parents:
14189
diff
changeset
|
264 (interactive) |
874cd82cd2b4
(mode25): Moved from `src/dosfns.c' for backward compatibility.
Richard M. Stallman <rms@gnu.org>
parents:
14189
diff
changeset
|
265 (set-frame-size (selected-frame) 80 25)) |
874cd82cd2b4
(mode25): Moved from `src/dosfns.c' for backward compatibility.
Richard M. Stallman <rms@gnu.org>
parents:
14189
diff
changeset
|
266 |
874cd82cd2b4
(mode25): Moved from `src/dosfns.c' for backward compatibility.
Richard M. Stallman <rms@gnu.org>
parents:
14189
diff
changeset
|
267 (defun mode4350 () |
874cd82cd2b4
(mode25): Moved from `src/dosfns.c' for backward compatibility.
Richard M. Stallman <rms@gnu.org>
parents:
14189
diff
changeset
|
268 "Changes the number of rows to 43 or 50. |
874cd82cd2b4
(mode25): Moved from `src/dosfns.c' for backward compatibility.
Richard M. Stallman <rms@gnu.org>
parents:
14189
diff
changeset
|
269 Emacs always tries to set the screen height to 50 rows first. |
874cd82cd2b4
(mode25): Moved from `src/dosfns.c' for backward compatibility.
Richard M. Stallman <rms@gnu.org>
parents:
14189
diff
changeset
|
270 If this fails, it will try to set it to 43 rows, on the assumption |
874cd82cd2b4
(mode25): Moved from `src/dosfns.c' for backward compatibility.
Richard M. Stallman <rms@gnu.org>
parents:
14189
diff
changeset
|
271 that your video hardware might not support 50-line mode." |
874cd82cd2b4
(mode25): Moved from `src/dosfns.c' for backward compatibility.
Richard M. Stallman <rms@gnu.org>
parents:
14189
diff
changeset
|
272 (interactive) |
874cd82cd2b4
(mode25): Moved from `src/dosfns.c' for backward compatibility.
Richard M. Stallman <rms@gnu.org>
parents:
14189
diff
changeset
|
273 (set-frame-size (selected-frame) 80 50) |
874cd82cd2b4
(mode25): Moved from `src/dosfns.c' for backward compatibility.
Richard M. Stallman <rms@gnu.org>
parents:
14189
diff
changeset
|
274 (if (eq (frame-height (selected-frame)) 50) |
874cd82cd2b4
(mode25): Moved from `src/dosfns.c' for backward compatibility.
Richard M. Stallman <rms@gnu.org>
parents:
14189
diff
changeset
|
275 nil ; the original built-in function returned nil |
874cd82cd2b4
(mode25): Moved from `src/dosfns.c' for backward compatibility.
Richard M. Stallman <rms@gnu.org>
parents:
14189
diff
changeset
|
276 (set-frame-size (selected-frame) 80 43))) |
874cd82cd2b4
(mode25): Moved from `src/dosfns.c' for backward compatibility.
Richard M. Stallman <rms@gnu.org>
parents:
14189
diff
changeset
|
277 |
14189
557b3d11a381
(ps-lpr-switches, ps-lpr-command): Just setq them;
Richard M. Stallman <rms@gnu.org>
parents:
14169
diff
changeset
|
278 (provide 'dos-fns) |
557b3d11a381
(ps-lpr-switches, ps-lpr-command): Just setq them;
Richard M. Stallman <rms@gnu.org>
parents:
14169
diff
changeset
|
279 |
557b3d11a381
(ps-lpr-switches, ps-lpr-command): Just setq them;
Richard M. Stallman <rms@gnu.org>
parents:
14169
diff
changeset
|
280 ; dos-fns.el ends here |