annotate lisp/dos-fns.el @ 108555:c3df6042f1d6

Replace some msdos cpp. * src/Makefile.in (MSDOS_OBJ): Default to empty, let msdos scripts set it. (MSDOS_X_OBJ): New variable. (MSDOS_SUPPORT_REAL): New constant. (MSDOS_SUPPORT): Set as a variable, not with cpp. (obj): Use MSDOS_X_OBJ. (lisp): Use MSDOS_SUPPORT as a variable. * msdos/sed1v2.inp (MSDOS_OBJ): Edit to dosfns.o msdos.o. (MSDOS_SUPPORT): Edit to $(MSDOS_SUPPORT_REAL). * msdos/sed1x.inp (MSDOS_X_OBJ): Edit to w16select.o termcap.o.
author Glenn Morris <rgm@gnu.org>
date Thu, 13 May 2010 20:13:39 -0700
parents a4cdc6d33cc6
children a5969c855306
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
rev   line source
38436
b174db545cfd Some fixes to follow coding conventions.
Pavel Janík <Pavel@Janik.cz>
parents: 37262
diff changeset
1 ;;; dos-fns.el --- MS-Dos specific functions
5443
391bfbbb9c1d Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
2
104823
68150c643e2e Use default-value rather than default-enable-multibyte-characters.
Glenn Morris <rgm@gnu.org>
parents: 104712
diff changeset
3 ;; Copyright (C) 1991, 1993, 1995, 1996, 2001, 2002, 2003, 2004, 2005,
106815
1d1d5d9bd884 Add 2010 to copyright years.
Glenn Morris <rgm@gnu.org>
parents: 104982
diff changeset
4 ;; 2006, 2007, 2008, 2009, 2010 Free Software Foundation, Inc.
5443
391bfbbb9c1d Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
5
17977
727cf56647a4 Comment change.
Richard M. Stallman <rms@gnu.org>
parents: 16690
diff changeset
6 ;; Maintainer: Morten Welinder <terra@diku.dk>
5443
391bfbbb9c1d Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
7 ;; Keywords: internal
391bfbbb9c1d Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
8
391bfbbb9c1d Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
9 ;; This file is part of GNU Emacs.
391bfbbb9c1d Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
10
94678
ee5932bf781d Switch to recommended form of GPLv3 permissions notice.
Glenn Morris <rgm@gnu.org>
parents: 93975
diff changeset
11 ;; GNU Emacs is free software: you can redistribute it and/or modify
5443
391bfbbb9c1d Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
12 ;; it under the terms of the GNU General Public License as published by
94678
ee5932bf781d Switch to recommended form of GPLv3 permissions notice.
Glenn Morris <rgm@gnu.org>
parents: 93975
diff changeset
13 ;; the Free Software Foundation, either version 3 of the License, or
ee5932bf781d Switch to recommended form of GPLv3 permissions notice.
Glenn Morris <rgm@gnu.org>
parents: 93975
diff changeset
14 ;; (at your option) any later version.
5443
391bfbbb9c1d Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
15
391bfbbb9c1d Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
16 ;; GNU Emacs is distributed in the hope that it will be useful,
391bfbbb9c1d Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
17 ;; but WITHOUT ANY WARRANTY; without even the implied warranty of
391bfbbb9c1d Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
18 ;; MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
391bfbbb9c1d Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
19 ;; GNU General Public License for more details.
391bfbbb9c1d Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
20
391bfbbb9c1d Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
21 ;; You should have received a copy of the GNU General Public License
94678
ee5932bf781d Switch to recommended form of GPLv3 permissions notice.
Glenn Morris <rgm@gnu.org>
parents: 93975
diff changeset
22 ;; along with GNU Emacs. If not, see <http://www.gnu.org/licenses/>.
5443
391bfbbb9c1d Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
23
391bfbbb9c1d Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
24 ;;; Commentary:
391bfbbb9c1d Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
25
391bfbbb9c1d Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
26 ;; Part of this code is taken from (or derived from) demacs.
391bfbbb9c1d Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
27
391bfbbb9c1d Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
28 ;;; Code:
391bfbbb9c1d Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
29
86293
f68aca4b5962 (int86): Fix declaration.
Glenn Morris <rgm@gnu.org>
parents: 86289
diff changeset
30 (declare-function int86 "dosfns.c")
86289
8a7ed478f7bc * international/titdic-cnv.el (dos-8+3-filename):
Dan Nicolaescu <dann@ics.uci.edu>
parents: 86277
diff changeset
31 (declare-function msdos-long-file-names "msdos.c")
8a7ed478f7bc * international/titdic-cnv.el (dos-8+3-filename):
Dan Nicolaescu <dann@ics.uci.edu>
parents: 86277
diff changeset
32
13913
4e4201bcea5d (convert-standard-filename): New alternate definition.
Richard M. Stallman <rms@gnu.org>
parents: 13487
diff changeset
33 ;; This overrides a trivial definition in files.el.
108520
a4cdc6d33cc6 * dos-fns.el: Add "dos-" prefix for namespace control.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 106815
diff changeset
34 (defun dos-convert-standard-filename (filename)
13913
4e4201bcea5d (convert-standard-filename): New alternate definition.
Richard M. Stallman <rms@gnu.org>
parents: 13487
diff changeset
35 "Convert a standard file's name to something suitable for the current OS.
55865
ccd8cdf69359 Rework docstring (wording by Eli Zaretskii and Kai Grossjohann).
Juanma Barranquero <lekktu@gmail.com>
parents: 52401
diff changeset
36 This means to guarantee valid names and perhaps to canonicalize
ccd8cdf69359 Rework docstring (wording by Eli Zaretskii and Kai Grossjohann).
Juanma Barranquero <lekktu@gmail.com>
parents: 52401
diff changeset
37 certain patterns.
ccd8cdf69359 Rework docstring (wording by Eli Zaretskii and Kai Grossjohann).
Juanma Barranquero <lekktu@gmail.com>
parents: 52401
diff changeset
38
ccd8cdf69359 Rework docstring (wording by Eli Zaretskii and Kai Grossjohann).
Juanma Barranquero <lekktu@gmail.com>
parents: 52401
diff changeset
39 On Windows and DOS, replace invalid characters. On DOS, make
ccd8cdf69359 Rework docstring (wording by Eli Zaretskii and Kai Grossjohann).
Juanma Barranquero <lekktu@gmail.com>
parents: 52401
diff changeset
40 sure to obey the 8.3 limitations. On Windows, turn Cygwin names
ccd8cdf69359 Rework docstring (wording by Eli Zaretskii and Kai Grossjohann).
Juanma Barranquero <lekktu@gmail.com>
parents: 52401
diff changeset
41 into native names, and also turn slashes into backslashes if the
ccd8cdf69359 Rework docstring (wording by Eli Zaretskii and Kai Grossjohann).
Juanma Barranquero <lekktu@gmail.com>
parents: 52401
diff changeset
42 shell requires it (see `w32-shell-dos-semantics')."
29855
4a37c3f4cb29 (convert-standard-filename): Convert leading
Eli Zaretskii <eliz@gnu.org>
parents: 24515
diff changeset
43 (if (or (not (stringp filename))
29966
cf435e74e3ee (convert-standard-filename): Fix last change.
Eli Zaretskii <eliz@gnu.org>
parents: 29855
diff changeset
44 ;; This catches the case where FILENAME is "x:" or "x:/" or
cf435e74e3ee (convert-standard-filename): Fix last change.
Eli Zaretskii <eliz@gnu.org>
parents: 29855
diff changeset
45 ;; "/", thus preventing infinite recursion.
cf435e74e3ee (convert-standard-filename): Fix last change.
Eli Zaretskii <eliz@gnu.org>
parents: 29855
diff changeset
46 (string-match "\\`\\([a-zA-Z]:\\)?[/\\]?\\'" filename))
15187
d46c1e8bdb0d (convert-standard-filename): Test msdos-long-file-names.
Richard M. Stallman <rms@gnu.org>
parents: 14734
diff changeset
47 filename
29966
cf435e74e3ee (convert-standard-filename): Fix last change.
Eli Zaretskii <eliz@gnu.org>
parents: 29855
diff changeset
48 (let ((flen (length filename)))
cf435e74e3ee (convert-standard-filename): Fix last change.
Eli Zaretskii <eliz@gnu.org>
parents: 29855
diff changeset
49 ;; If FILENAME has a trailing slash, remove it and recurse.
cf435e74e3ee (convert-standard-filename): Fix last change.
Eli Zaretskii <eliz@gnu.org>
parents: 29855
diff changeset
50 (if (memq (aref filename (1- flen)) '(?/ ?\\))
108520
a4cdc6d33cc6 * dos-fns.el: Add "dos-" prefix for namespace control.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 106815
diff changeset
51 (concat (dos-convert-standard-filename
29966
cf435e74e3ee (convert-standard-filename): Fix last change.
Eli Zaretskii <eliz@gnu.org>
parents: 29855
diff changeset
52 (substring filename 0 (1- flen)))
cf435e74e3ee (convert-standard-filename): Fix last change.
Eli Zaretskii <eliz@gnu.org>
parents: 29855
diff changeset
53 "/")
cf435e74e3ee (convert-standard-filename): Fix last change.
Eli Zaretskii <eliz@gnu.org>
parents: 29855
diff changeset
54 (let* (;; ange-ftp gets in the way for names like "/foo:bar".
cf435e74e3ee (convert-standard-filename): Fix last change.
Eli Zaretskii <eliz@gnu.org>
parents: 29855
diff changeset
55 ;; We need to inhibit all magic file names, because
cf435e74e3ee (convert-standard-filename): Fix last change.
Eli Zaretskii <eliz@gnu.org>
parents: 29855
diff changeset
56 ;; remote file names should never be passed through
cf435e74e3ee (convert-standard-filename): Fix last change.
Eli Zaretskii <eliz@gnu.org>
parents: 29855
diff changeset
57 ;; this function, as they are not meant for the local
cf435e74e3ee (convert-standard-filename): Fix last change.
Eli Zaretskii <eliz@gnu.org>
parents: 29855
diff changeset
58 ;; filesystem!
cf435e74e3ee (convert-standard-filename): Fix last change.
Eli Zaretskii <eliz@gnu.org>
parents: 29855
diff changeset
59 (file-name-handler-alist nil)
cf435e74e3ee (convert-standard-filename): Fix last change.
Eli Zaretskii <eliz@gnu.org>
parents: 29855
diff changeset
60 (dir
cf435e74e3ee (convert-standard-filename): Fix last change.
Eli Zaretskii <eliz@gnu.org>
parents: 29855
diff changeset
61 ;; If FILENAME is "x:foo", file-name-directory returns
cf435e74e3ee (convert-standard-filename): Fix last change.
Eli Zaretskii <eliz@gnu.org>
parents: 29855
diff changeset
62 ;; "x:/bar/baz", substituting the current working
cf435e74e3ee (convert-standard-filename): Fix last change.
Eli Zaretskii <eliz@gnu.org>
parents: 29855
diff changeset
63 ;; directory on drive x:. We want to be left with "x:"
cf435e74e3ee (convert-standard-filename): Fix last change.
Eli Zaretskii <eliz@gnu.org>
parents: 29855
diff changeset
64 ;; instead.
cf435e74e3ee (convert-standard-filename): Fix last change.
Eli Zaretskii <eliz@gnu.org>
parents: 29855
diff changeset
65 (if (and (< 1 flen)
cf435e74e3ee (convert-standard-filename): Fix last change.
Eli Zaretskii <eliz@gnu.org>
parents: 29855
diff changeset
66 (eq (aref filename 1) ?:)
cf435e74e3ee (convert-standard-filename): Fix last change.
Eli Zaretskii <eliz@gnu.org>
parents: 29855
diff changeset
67 (null (string-match "[/\\]" filename)))
cf435e74e3ee (convert-standard-filename): Fix last change.
Eli Zaretskii <eliz@gnu.org>
parents: 29855
diff changeset
68 (substring filename 0 2)
cf435e74e3ee (convert-standard-filename): Fix last change.
Eli Zaretskii <eliz@gnu.org>
parents: 29855
diff changeset
69 (file-name-directory filename)))
cf435e74e3ee (convert-standard-filename): Fix last change.
Eli Zaretskii <eliz@gnu.org>
parents: 29855
diff changeset
70 (dlen-m-1 (1- (length dir)))
cf435e74e3ee (convert-standard-filename): Fix last change.
Eli Zaretskii <eliz@gnu.org>
parents: 29855
diff changeset
71 (string (copy-sequence (file-name-nondirectory filename)))
cf435e74e3ee (convert-standard-filename): Fix last change.
Eli Zaretskii <eliz@gnu.org>
parents: 29855
diff changeset
72 (lastchar (aref string (1- (length string))))
cf435e74e3ee (convert-standard-filename): Fix last change.
Eli Zaretskii <eliz@gnu.org>
parents: 29855
diff changeset
73 i firstdot)
cf435e74e3ee (convert-standard-filename): Fix last change.
Eli Zaretskii <eliz@gnu.org>
parents: 29855
diff changeset
74 (cond
cf435e74e3ee (convert-standard-filename): Fix last change.
Eli Zaretskii <eliz@gnu.org>
parents: 29855
diff changeset
75 ((msdos-long-file-names)
29855
4a37c3f4cb29 (convert-standard-filename): Convert leading
Eli Zaretskii <eliz@gnu.org>
parents: 24515
diff changeset
76 ;; Replace characters that are invalid even on Windows.
4a37c3f4cb29 (convert-standard-filename): Convert leading
Eli Zaretskii <eliz@gnu.org>
parents: 24515
diff changeset
77 (while (setq i (string-match "[?*:<>|\"\000-\037]" string))
29966
cf435e74e3ee (convert-standard-filename): Fix last change.
Eli Zaretskii <eliz@gnu.org>
parents: 29855
diff changeset
78 (aset string i ?!)))
cf435e74e3ee (convert-standard-filename): Fix last change.
Eli Zaretskii <eliz@gnu.org>
parents: 29855
diff changeset
79 ((not (member string '("" "." "..")))
cf435e74e3ee (convert-standard-filename): Fix last change.
Eli Zaretskii <eliz@gnu.org>
parents: 29855
diff changeset
80 ;; Change a leading period to a leading underscore.
cf435e74e3ee (convert-standard-filename): Fix last change.
Eli Zaretskii <eliz@gnu.org>
parents: 29855
diff changeset
81 (if (= (aref string 0) ?.)
cf435e74e3ee (convert-standard-filename): Fix last change.
Eli Zaretskii <eliz@gnu.org>
parents: 29855
diff changeset
82 (aset string 0 ?_))
39305
22c925655e32 (convert-standard-filename): Replace invalid
Eli Zaretskii <eliz@gnu.org>
parents: 39301
diff changeset
83 ;; If the name is longer than 8 chars, and doesn't have a
22c925655e32 (convert-standard-filename): Replace invalid
Eli Zaretskii <eliz@gnu.org>
parents: 39301
diff changeset
84 ;; period, and we have a dash or underscore that isn't too
22c925655e32 (convert-standard-filename): Replace invalid
Eli Zaretskii <eliz@gnu.org>
parents: 39301
diff changeset
85 ;; close to the beginning, change that to a period. This
22c925655e32 (convert-standard-filename): Replace invalid
Eli Zaretskii <eliz@gnu.org>
parents: 39301
diff changeset
86 ;; is so we could salvage more characters of the original
22c925655e32 (convert-standard-filename): Replace invalid
Eli Zaretskii <eliz@gnu.org>
parents: 39301
diff changeset
87 ;; name by pushing them into the extension.
22c925655e32 (convert-standard-filename): Replace invalid
Eli Zaretskii <eliz@gnu.org>
parents: 39301
diff changeset
88 (if (and (not (string-match "\\." string))
22c925655e32 (convert-standard-filename): Replace invalid
Eli Zaretskii <eliz@gnu.org>
parents: 39301
diff changeset
89 (> (length string) 8)
22c925655e32 (convert-standard-filename): Replace invalid
Eli Zaretskii <eliz@gnu.org>
parents: 39301
diff changeset
90 ;; We don't gain anything if we put the period closer
22c925655e32 (convert-standard-filename): Replace invalid
Eli Zaretskii <eliz@gnu.org>
parents: 39301
diff changeset
91 ;; than 5 chars from the beginning (5 + 3 = 8).
22c925655e32 (convert-standard-filename): Replace invalid
Eli Zaretskii <eliz@gnu.org>
parents: 39301
diff changeset
92 (setq i (string-match "[-_]" string 5)))
22c925655e32 (convert-standard-filename): Replace invalid
Eli Zaretskii <eliz@gnu.org>
parents: 39301
diff changeset
93 (aset string i ?\.))
29966
cf435e74e3ee (convert-standard-filename): Fix last change.
Eli Zaretskii <eliz@gnu.org>
parents: 29855
diff changeset
94 ;; Get rid of invalid characters.
cf435e74e3ee (convert-standard-filename): Fix last change.
Eli Zaretskii <eliz@gnu.org>
parents: 29855
diff changeset
95 (while (setq i (string-match
cf435e74e3ee (convert-standard-filename): Fix last change.
Eli Zaretskii <eliz@gnu.org>
parents: 29855
diff changeset
96 "[^-a-zA-Z0-9_.%~^$!#&{}@`'()\200-\376]"
cf435e74e3ee (convert-standard-filename): Fix last change.
Eli Zaretskii <eliz@gnu.org>
parents: 29855
diff changeset
97 string))
cf435e74e3ee (convert-standard-filename): Fix last change.
Eli Zaretskii <eliz@gnu.org>
parents: 29855
diff changeset
98 (aset string i ?_))
cf435e74e3ee (convert-standard-filename): Fix last change.
Eli Zaretskii <eliz@gnu.org>
parents: 29855
diff changeset
99 ;; If we don't have a period in the first 8 chars, insert one.
39305
22c925655e32 (convert-standard-filename): Replace invalid
Eli Zaretskii <eliz@gnu.org>
parents: 39301
diff changeset
100 ;; This enables to have 3 more characters from the original
22c925655e32 (convert-standard-filename): Replace invalid
Eli Zaretskii <eliz@gnu.org>
parents: 39301
diff changeset
101 ;; name in the extension.
29966
cf435e74e3ee (convert-standard-filename): Fix last change.
Eli Zaretskii <eliz@gnu.org>
parents: 29855
diff changeset
102 (if (> (or (string-match "\\." string) (length string))
cf435e74e3ee (convert-standard-filename): Fix last change.
Eli Zaretskii <eliz@gnu.org>
parents: 29855
diff changeset
103 8)
cf435e74e3ee (convert-standard-filename): Fix last change.
Eli Zaretskii <eliz@gnu.org>
parents: 29855
diff changeset
104 (setq string
cf435e74e3ee (convert-standard-filename): Fix last change.
Eli Zaretskii <eliz@gnu.org>
parents: 29855
diff changeset
105 (concat (substring string 0 8)
cf435e74e3ee (convert-standard-filename): Fix last change.
Eli Zaretskii <eliz@gnu.org>
parents: 29855
diff changeset
106 "."
cf435e74e3ee (convert-standard-filename): Fix last change.
Eli Zaretskii <eliz@gnu.org>
parents: 29855
diff changeset
107 (substring string 8))))
cf435e74e3ee (convert-standard-filename): Fix last change.
Eli Zaretskii <eliz@gnu.org>
parents: 29855
diff changeset
108 (setq firstdot (or (string-match "\\." string)
cf435e74e3ee (convert-standard-filename): Fix last change.
Eli Zaretskii <eliz@gnu.org>
parents: 29855
diff changeset
109 (1- (length string))))
cf435e74e3ee (convert-standard-filename): Fix last change.
Eli Zaretskii <eliz@gnu.org>
parents: 29855
diff changeset
110 ;; Truncate to 3 chars after the first period.
cf435e74e3ee (convert-standard-filename): Fix last change.
Eli Zaretskii <eliz@gnu.org>
parents: 29855
diff changeset
111 (if (> (length string) (+ firstdot 4))
cf435e74e3ee (convert-standard-filename): Fix last change.
Eli Zaretskii <eliz@gnu.org>
parents: 29855
diff changeset
112 (setq string (substring string 0 (+ firstdot 4))))
cf435e74e3ee (convert-standard-filename): Fix last change.
Eli Zaretskii <eliz@gnu.org>
parents: 29855
diff changeset
113 ;; Change all periods except the first one into underscores.
39305
22c925655e32 (convert-standard-filename): Replace invalid
Eli Zaretskii <eliz@gnu.org>
parents: 39301
diff changeset
114 ;; (DOS doesn't allow more than one period.)
29966
cf435e74e3ee (convert-standard-filename): Fix last change.
Eli Zaretskii <eliz@gnu.org>
parents: 29855
diff changeset
115 (while (string-match "\\." string (1+ firstdot))
cf435e74e3ee (convert-standard-filename): Fix last change.
Eli Zaretskii <eliz@gnu.org>
parents: 29855
diff changeset
116 (setq i (string-match "\\." string (1+ firstdot)))
cf435e74e3ee (convert-standard-filename): Fix last change.
Eli Zaretskii <eliz@gnu.org>
parents: 29855
diff changeset
117 (aset string i ?_))
39305
22c925655e32 (convert-standard-filename): Replace invalid
Eli Zaretskii <eliz@gnu.org>
parents: 39301
diff changeset
118 ;; If the last character of the original filename was `~' or `#',
22c925655e32 (convert-standard-filename): Replace invalid
Eli Zaretskii <eliz@gnu.org>
parents: 39301
diff changeset
119 ;; make sure the munged name ends with it also. This is so that
22c925655e32 (convert-standard-filename): Replace invalid
Eli Zaretskii <eliz@gnu.org>
parents: 39301
diff changeset
120 ;; backup and auto-save files retain their telltale form.
22c925655e32 (convert-standard-filename): Replace invalid
Eli Zaretskii <eliz@gnu.org>
parents: 39301
diff changeset
121 (if (memq lastchar '(?~ ?#))
29966
cf435e74e3ee (convert-standard-filename): Fix last change.
Eli Zaretskii <eliz@gnu.org>
parents: 29855
diff changeset
122 (aset string (1- (length string)) lastchar))))
cf435e74e3ee (convert-standard-filename): Fix last change.
Eli Zaretskii <eliz@gnu.org>
parents: 29855
diff changeset
123 (concat (if (and (stringp dir)
cf435e74e3ee (convert-standard-filename): Fix last change.
Eli Zaretskii <eliz@gnu.org>
parents: 29855
diff changeset
124 (memq (aref dir dlen-m-1) '(?/ ?\\)))
108520
a4cdc6d33cc6 * dos-fns.el: Add "dos-" prefix for namespace control.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 106815
diff changeset
125 (concat (dos-convert-standard-filename
29966
cf435e74e3ee (convert-standard-filename): Fix last change.
Eli Zaretskii <eliz@gnu.org>
parents: 29855
diff changeset
126 (substring dir 0 dlen-m-1))
cf435e74e3ee (convert-standard-filename): Fix last change.
Eli Zaretskii <eliz@gnu.org>
parents: 29855
diff changeset
127 "/")
108520
a4cdc6d33cc6 * dos-fns.el: Add "dos-" prefix for namespace control.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 106815
diff changeset
128 (dos-convert-standard-filename dir))
29966
cf435e74e3ee (convert-standard-filename): Fix last change.
Eli Zaretskii <eliz@gnu.org>
parents: 29855
diff changeset
129 string))))))
13913
4e4201bcea5d (convert-standard-filename): New alternate definition.
Richard M. Stallman <rms@gnu.org>
parents: 13487
diff changeset
130
108520
a4cdc6d33cc6 * dos-fns.el: Add "dos-" prefix for namespace control.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 106815
diff changeset
131 ;; Only redirect convert-standard-filename if it has a chance of working,
a4cdc6d33cc6 * dos-fns.el: Add "dos-" prefix for namespace control.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 106815
diff changeset
132 ;; otherwise loading dos-fns.el might make your non-DOS Emacs misbehave.
a4cdc6d33cc6 * dos-fns.el: Add "dos-" prefix for namespace control.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 106815
diff changeset
133 (when (fboundp 'msdos-long-file-names)
a4cdc6d33cc6 * dos-fns.el: Add "dos-" prefix for namespace control.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 106815
diff changeset
134 (defalias 'convert-standard-filename 'dos-convert-standard-filename))
a4cdc6d33cc6 * dos-fns.el: Add "dos-" prefix for namespace control.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 106815
diff changeset
135
37262
3e478bb3f389 (dos-8+3-filename): Rename from dos-truncate-to-8+3.
Eli Zaretskii <eliz@gnu.org>
parents: 37257
diff changeset
136 (defun dos-8+3-filename (filename)
37257
6bbf8e77d787 (dos-truncate-to-8+3): New function.
Eli Zaretskii <eliz@gnu.org>
parents: 29966
diff changeset
137 "Truncate FILENAME to DOS 8+3 limits."
6bbf8e77d787 (dos-truncate-to-8+3): New function.
Eli Zaretskii <eliz@gnu.org>
parents: 29966
diff changeset
138 (if (or (not (stringp filename))
6bbf8e77d787 (dos-truncate-to-8+3): New function.
Eli Zaretskii <eliz@gnu.org>
parents: 29966
diff changeset
139 (< (length filename) 5)) ; too short to give any trouble
6bbf8e77d787 (dos-truncate-to-8+3): New function.
Eli Zaretskii <eliz@gnu.org>
parents: 29966
diff changeset
140 filename
6bbf8e77d787 (dos-truncate-to-8+3): New function.
Eli Zaretskii <eliz@gnu.org>
parents: 29966
diff changeset
141 (let ((flen (length filename)))
6bbf8e77d787 (dos-truncate-to-8+3): New function.
Eli Zaretskii <eliz@gnu.org>
parents: 29966
diff changeset
142 ;; If FILENAME has a trailing slash, remove it and recurse.
6bbf8e77d787 (dos-truncate-to-8+3): New function.
Eli Zaretskii <eliz@gnu.org>
parents: 29966
diff changeset
143 (if (memq (aref filename (1- flen)) '(?/ ?\\))
37262
3e478bb3f389 (dos-8+3-filename): Rename from dos-truncate-to-8+3.
Eli Zaretskii <eliz@gnu.org>
parents: 37257
diff changeset
144 (concat (dos-8+3-filename (substring filename 0 (1- flen)))
37257
6bbf8e77d787 (dos-truncate-to-8+3): New function.
Eli Zaretskii <eliz@gnu.org>
parents: 29966
diff changeset
145 "/")
6bbf8e77d787 (dos-truncate-to-8+3): New function.
Eli Zaretskii <eliz@gnu.org>
parents: 29966
diff changeset
146 (let* (;; ange-ftp gets in the way for names like "/foo:bar".
6bbf8e77d787 (dos-truncate-to-8+3): New function.
Eli Zaretskii <eliz@gnu.org>
parents: 29966
diff changeset
147 ;; We need to inhibit all magic file names, because
6bbf8e77d787 (dos-truncate-to-8+3): New function.
Eli Zaretskii <eliz@gnu.org>
parents: 29966
diff changeset
148 ;; remote file names should never be passed through
6bbf8e77d787 (dos-truncate-to-8+3): New function.
Eli Zaretskii <eliz@gnu.org>
parents: 29966
diff changeset
149 ;; this function, as they are not meant for the local
6bbf8e77d787 (dos-truncate-to-8+3): New function.
Eli Zaretskii <eliz@gnu.org>
parents: 29966
diff changeset
150 ;; filesystem!
6bbf8e77d787 (dos-truncate-to-8+3): New function.
Eli Zaretskii <eliz@gnu.org>
parents: 29966
diff changeset
151 (file-name-handler-alist nil)
6bbf8e77d787 (dos-truncate-to-8+3): New function.
Eli Zaretskii <eliz@gnu.org>
parents: 29966
diff changeset
152 (dir
6bbf8e77d787 (dos-truncate-to-8+3): New function.
Eli Zaretskii <eliz@gnu.org>
parents: 29966
diff changeset
153 ;; If FILENAME is "x:foo", file-name-directory returns
6bbf8e77d787 (dos-truncate-to-8+3): New function.
Eli Zaretskii <eliz@gnu.org>
parents: 29966
diff changeset
154 ;; "x:/bar/baz", substituting the current working
6bbf8e77d787 (dos-truncate-to-8+3): New function.
Eli Zaretskii <eliz@gnu.org>
parents: 29966
diff changeset
155 ;; directory on drive x:. We want to be left with "x:"
6bbf8e77d787 (dos-truncate-to-8+3): New function.
Eli Zaretskii <eliz@gnu.org>
parents: 29966
diff changeset
156 ;; instead.
6bbf8e77d787 (dos-truncate-to-8+3): New function.
Eli Zaretskii <eliz@gnu.org>
parents: 29966
diff changeset
157 (if (and (< 1 flen)
6bbf8e77d787 (dos-truncate-to-8+3): New function.
Eli Zaretskii <eliz@gnu.org>
parents: 29966
diff changeset
158 (eq (aref filename 1) ?:)
6bbf8e77d787 (dos-truncate-to-8+3): New function.
Eli Zaretskii <eliz@gnu.org>
parents: 29966
diff changeset
159 (null (string-match "[/\\]" filename)))
6bbf8e77d787 (dos-truncate-to-8+3): New function.
Eli Zaretskii <eliz@gnu.org>
parents: 29966
diff changeset
160 (substring filename 0 2)
6bbf8e77d787 (dos-truncate-to-8+3): New function.
Eli Zaretskii <eliz@gnu.org>
parents: 29966
diff changeset
161 (file-name-directory filename)))
6bbf8e77d787 (dos-truncate-to-8+3): New function.
Eli Zaretskii <eliz@gnu.org>
parents: 29966
diff changeset
162 (dlen-m-1 (1- (length dir)))
6bbf8e77d787 (dos-truncate-to-8+3): New function.
Eli Zaretskii <eliz@gnu.org>
parents: 29966
diff changeset
163 (string (copy-sequence (file-name-nondirectory filename)))
6bbf8e77d787 (dos-truncate-to-8+3): New function.
Eli Zaretskii <eliz@gnu.org>
parents: 29966
diff changeset
164 (strlen (length string))
6bbf8e77d787 (dos-truncate-to-8+3): New function.
Eli Zaretskii <eliz@gnu.org>
parents: 29966
diff changeset
165 (lastchar (aref string (1- strlen)))
6bbf8e77d787 (dos-truncate-to-8+3): New function.
Eli Zaretskii <eliz@gnu.org>
parents: 29966
diff changeset
166 i firstdot)
6bbf8e77d787 (dos-truncate-to-8+3): New function.
Eli Zaretskii <eliz@gnu.org>
parents: 29966
diff changeset
167 (setq firstdot (string-match "\\." string))
6bbf8e77d787 (dos-truncate-to-8+3): New function.
Eli Zaretskii <eliz@gnu.org>
parents: 29966
diff changeset
168 (cond
6bbf8e77d787 (dos-truncate-to-8+3): New function.
Eli Zaretskii <eliz@gnu.org>
parents: 29966
diff changeset
169 (firstdot
6bbf8e77d787 (dos-truncate-to-8+3): New function.
Eli Zaretskii <eliz@gnu.org>
parents: 29966
diff changeset
170 ;; Truncate the extension to 3 characters.
6bbf8e77d787 (dos-truncate-to-8+3): New function.
Eli Zaretskii <eliz@gnu.org>
parents: 29966
diff changeset
171 (if (> strlen (+ firstdot 4))
6bbf8e77d787 (dos-truncate-to-8+3): New function.
Eli Zaretskii <eliz@gnu.org>
parents: 29966
diff changeset
172 (setq string (substring string 0 (+ firstdot 4))))
6bbf8e77d787 (dos-truncate-to-8+3): New function.
Eli Zaretskii <eliz@gnu.org>
parents: 29966
diff changeset
173 ;; Truncate the basename to 8 characters.
6bbf8e77d787 (dos-truncate-to-8+3): New function.
Eli Zaretskii <eliz@gnu.org>
parents: 29966
diff changeset
174 (if (> firstdot 8)
6bbf8e77d787 (dos-truncate-to-8+3): New function.
Eli Zaretskii <eliz@gnu.org>
parents: 29966
diff changeset
175 (setq string (concat (substring string 0 8)
6bbf8e77d787 (dos-truncate-to-8+3): New function.
Eli Zaretskii <eliz@gnu.org>
parents: 29966
diff changeset
176 "."
6bbf8e77d787 (dos-truncate-to-8+3): New function.
Eli Zaretskii <eliz@gnu.org>
parents: 29966
diff changeset
177 (substring string (1+ firstdot))))))
6bbf8e77d787 (dos-truncate-to-8+3): New function.
Eli Zaretskii <eliz@gnu.org>
parents: 29966
diff changeset
178 ((> strlen 8)
6bbf8e77d787 (dos-truncate-to-8+3): New function.
Eli Zaretskii <eliz@gnu.org>
parents: 29966
diff changeset
179 ;; No dot; truncate file name to 8 characters.
6bbf8e77d787 (dos-truncate-to-8+3): New function.
Eli Zaretskii <eliz@gnu.org>
parents: 29966
diff changeset
180 (setq string (substring string 0 8))))
6bbf8e77d787 (dos-truncate-to-8+3): New function.
Eli Zaretskii <eliz@gnu.org>
parents: 29966
diff changeset
181 ;; If the last character of the original filename was `~',
6bbf8e77d787 (dos-truncate-to-8+3): New function.
Eli Zaretskii <eliz@gnu.org>
parents: 29966
diff changeset
182 ;; make sure the munged name ends with it also. This is so
6bbf8e77d787 (dos-truncate-to-8+3): New function.
Eli Zaretskii <eliz@gnu.org>
parents: 29966
diff changeset
183 ;; a backup file retains its final `~'.
6bbf8e77d787 (dos-truncate-to-8+3): New function.
Eli Zaretskii <eliz@gnu.org>
parents: 29966
diff changeset
184 (if (equal lastchar ?~)
6bbf8e77d787 (dos-truncate-to-8+3): New function.
Eli Zaretskii <eliz@gnu.org>
parents: 29966
diff changeset
185 (aset string (1- (length string)) lastchar))
6bbf8e77d787 (dos-truncate-to-8+3): New function.
Eli Zaretskii <eliz@gnu.org>
parents: 29966
diff changeset
186 (concat (if (and (stringp dir)
6bbf8e77d787 (dos-truncate-to-8+3): New function.
Eli Zaretskii <eliz@gnu.org>
parents: 29966
diff changeset
187 (memq (aref dir dlen-m-1) '(?/ ?\\)))
37262
3e478bb3f389 (dos-8+3-filename): Rename from dos-truncate-to-8+3.
Eli Zaretskii <eliz@gnu.org>
parents: 37257
diff changeset
188 (concat (dos-8+3-filename (substring dir 0 dlen-m-1))
37257
6bbf8e77d787 (dos-truncate-to-8+3): New function.
Eli Zaretskii <eliz@gnu.org>
parents: 29966
diff changeset
189 "/")
6bbf8e77d787 (dos-truncate-to-8+3): New function.
Eli Zaretskii <eliz@gnu.org>
parents: 29966
diff changeset
190 ;; Recurse to truncate the leading directories.
37262
3e478bb3f389 (dos-8+3-filename): Rename from dos-truncate-to-8+3.
Eli Zaretskii <eliz@gnu.org>
parents: 37257
diff changeset
191 (dos-8+3-filename dir))
37257
6bbf8e77d787 (dos-truncate-to-8+3): New function.
Eli Zaretskii <eliz@gnu.org>
parents: 29966
diff changeset
192 string))))))
6bbf8e77d787 (dos-truncate-to-8+3): New function.
Eli Zaretskii <eliz@gnu.org>
parents: 29966
diff changeset
193
100691
89166beb2187 (dosified-file-name): New function.
Eli Zaretskii <eliz@gnu.org>
parents: 98874
diff changeset
194 ;; This is for the sake of standard file names elsewhere in Emacs that
89166beb2187 (dosified-file-name): New function.
Eli Zaretskii <eliz@gnu.org>
parents: 98874
diff changeset
195 ;; are defined as constant strings or via defconst, and whose
108520
a4cdc6d33cc6 * dos-fns.el: Add "dos-" prefix for namespace control.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 106815
diff changeset
196 ;; conversion via `dos-convert-standard-filename' does not give good
100691
89166beb2187 (dosified-file-name): New function.
Eli Zaretskii <eliz@gnu.org>
parents: 98874
diff changeset
197 ;; enough results.
89166beb2187 (dosified-file-name): New function.
Eli Zaretskii <eliz@gnu.org>
parents: 98874
diff changeset
198 (defun dosified-file-name (file-name)
89166beb2187 (dosified-file-name): New function.
Eli Zaretskii <eliz@gnu.org>
parents: 98874
diff changeset
199 "Return a variant of FILE-NAME that is valid on MS-DOS filesystems.
89166beb2187 (dosified-file-name): New function.
Eli Zaretskii <eliz@gnu.org>
parents: 98874
diff changeset
200
108520
a4cdc6d33cc6 * dos-fns.el: Add "dos-" prefix for namespace control.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 106815
diff changeset
201 This function is for those rare cases where `dos-convert-standard-filename'
100691
89166beb2187 (dosified-file-name): New function.
Eli Zaretskii <eliz@gnu.org>
parents: 98874
diff changeset
202 does not do a job that is good enough, e.g. if you need to preserve the
89166beb2187 (dosified-file-name): New function.
Eli Zaretskii <eliz@gnu.org>
parents: 98874
diff changeset
203 file-name extension. It recognizes only certain specific file names
89166beb2187 (dosified-file-name): New function.
Eli Zaretskii <eliz@gnu.org>
parents: 98874
diff changeset
204 that are used in Emacs Lisp sources; any other file name will be
89166beb2187 (dosified-file-name): New function.
Eli Zaretskii <eliz@gnu.org>
parents: 98874
diff changeset
205 returned unaltered."
89166beb2187 (dosified-file-name): New function.
Eli Zaretskii <eliz@gnu.org>
parents: 98874
diff changeset
206 (cond
89166beb2187 (dosified-file-name): New function.
Eli Zaretskii <eliz@gnu.org>
parents: 98874
diff changeset
207 ;; See files.el:dir-locals-file.
89166beb2187 (dosified-file-name): New function.
Eli Zaretskii <eliz@gnu.org>
parents: 98874
diff changeset
208 ((string= file-name ".dir-locals.el")
89166beb2187 (dosified-file-name): New function.
Eli Zaretskii <eliz@gnu.org>
parents: 98874
diff changeset
209 "_dir-locals.el")
89166beb2187 (dosified-file-name): New function.
Eli Zaretskii <eliz@gnu.org>
parents: 98874
diff changeset
210 (t
89166beb2187 (dosified-file-name): New function.
Eli Zaretskii <eliz@gnu.org>
parents: 98874
diff changeset
211 file-name)))
89166beb2187 (dosified-file-name): New function.
Eli Zaretskii <eliz@gnu.org>
parents: 98874
diff changeset
212
22070
d8e53123116c (dos-ps-printer, dos-printer, msdos-shells):
Richard M. Stallman <rms@gnu.org>
parents: 21568
diff changeset
213 ;; See dos-vars.el for defcustom.
d8e53123116c (dos-ps-printer, dos-printer, msdos-shells):
Richard M. Stallman <rms@gnu.org>
parents: 21568
diff changeset
214 (defvar msdos-shells)
5443
391bfbbb9c1d Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
215
98859
ff71052e3573 (dos-reevaluate-defcustoms): New function. Add it to before-init-hook.
Eli Zaretskii <eliz@gnu.org>
parents: 94678
diff changeset
216 ;; Override settings chosen at startup.
108520
a4cdc6d33cc6 * dos-fns.el: Add "dos-" prefix for namespace control.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 106815
diff changeset
217 (defun dos-set-default-process-coding-system ()
24515
ef4a540c34ff (set-default-process-coding-system): Copied from dos-w32.el.
Andrew Innes <andrewi@gnu.org>
parents: 22676
diff changeset
218 (setq default-process-coding-system
104823
68150c643e2e Use default-value rather than default-enable-multibyte-characters.
Glenn Morris <rgm@gnu.org>
parents: 104712
diff changeset
219 (if (default-value 'enable-multibyte-characters)
24515
ef4a540c34ff (set-default-process-coding-system): Copied from dos-w32.el.
Andrew Innes <andrewi@gnu.org>
parents: 22676
diff changeset
220 '(undecided-dos . undecided-dos)
ef4a540c34ff (set-default-process-coding-system): Copied from dos-w32.el.
Andrew Innes <andrewi@gnu.org>
parents: 22676
diff changeset
221 '(raw-text-dos . raw-text-dos))))
ef4a540c34ff (set-default-process-coding-system): Copied from dos-w32.el.
Andrew Innes <andrewi@gnu.org>
parents: 22676
diff changeset
222
108520
a4cdc6d33cc6 * dos-fns.el: Add "dos-" prefix for namespace control.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 106815
diff changeset
223 (add-hook 'before-init-hook 'dos-set-default-process-coding-system)
24515
ef4a540c34ff (set-default-process-coding-system): Copied from dos-w32.el.
Andrew Innes <andrewi@gnu.org>
parents: 22676
diff changeset
224
98859
ff71052e3573 (dos-reevaluate-defcustoms): New function. Add it to before-init-hook.
Eli Zaretskii <eliz@gnu.org>
parents: 94678
diff changeset
225 ;; File names defined in preloaded packages can be incorrect or
ff71052e3573 (dos-reevaluate-defcustoms): New function. Add it to before-init-hook.
Eli Zaretskii <eliz@gnu.org>
parents: 94678
diff changeset
226 ;; invalid if long file names were available during dumping, but not
98874
d42cab7ccc5d (dos-reevaluate-defcustoms): Fix last change.
Eli Zaretskii <eliz@gnu.org>
parents: 98859
diff changeset
227 ;; at runtime, or vice versa, and if the default file name begins with
d42cab7ccc5d (dos-reevaluate-defcustoms): Fix last change.
Eli Zaretskii <eliz@gnu.org>
parents: 98859
diff changeset
228 ;; a period. Their defcustom's need to be reevaluated at startup. To
d42cab7ccc5d (dos-reevaluate-defcustoms): Fix last change.
Eli Zaretskii <eliz@gnu.org>
parents: 98859
diff changeset
229 ;; see if the list of defcustom's below is up to date, run the command
d42cab7ccc5d (dos-reevaluate-defcustoms): Fix last change.
Eli Zaretskii <eliz@gnu.org>
parents: 98859
diff changeset
230 ;; "M-x apropos-value RET ~/\. RET".
98859
ff71052e3573 (dos-reevaluate-defcustoms): New function. Add it to before-init-hook.
Eli Zaretskii <eliz@gnu.org>
parents: 94678
diff changeset
231 (defun dos-reevaluate-defcustoms ()
104982
f26e1b8ad86e (dos-reevaluate-defcustoms): Comment out the reevaluation of trash-directory.
Eli Zaretskii <eliz@gnu.org>
parents: 104823
diff changeset
232 ;; This is not needed in Emacs 23.2 and later, as trash-directory is
f26e1b8ad86e (dos-reevaluate-defcustoms): Comment out the reevaluation of trash-directory.
Eli Zaretskii <eliz@gnu.org>
parents: 104823
diff changeset
233 ;; initialized as nil. But something like this might become
f26e1b8ad86e (dos-reevaluate-defcustoms): Comment out the reevaluation of trash-directory.
Eli Zaretskii <eliz@gnu.org>
parents: 104823
diff changeset
234 ;; necessary in the future, so I'm keeping it here as a reminder.
f26e1b8ad86e (dos-reevaluate-defcustoms): Comment out the reevaluation of trash-directory.
Eli Zaretskii <eliz@gnu.org>
parents: 104823
diff changeset
235 ;(custom-reevaluate-setting 'trash-directory)
f26e1b8ad86e (dos-reevaluate-defcustoms): Comment out the reevaluation of trash-directory.
Eli Zaretskii <eliz@gnu.org>
parents: 104823
diff changeset
236 )
98859
ff71052e3573 (dos-reevaluate-defcustoms): New function. Add it to before-init-hook.
Eli Zaretskii <eliz@gnu.org>
parents: 94678
diff changeset
237
ff71052e3573 (dos-reevaluate-defcustoms): New function. Add it to before-init-hook.
Eli Zaretskii <eliz@gnu.org>
parents: 94678
diff changeset
238 (add-hook 'before-init-hook 'dos-reevaluate-defcustoms)
ff71052e3573 (dos-reevaluate-defcustoms): New function. Add it to before-init-hook.
Eli Zaretskii <eliz@gnu.org>
parents: 94678
diff changeset
239
108520
a4cdc6d33cc6 * dos-fns.el: Add "dos-" prefix for namespace control.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 106815
diff changeset
240 (defvar dos-register-name-alist
5443
391bfbbb9c1d Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
241 '((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
242 (cflag . 6) (flags . 7)
0f06f87f3c3b (set-register-value): Setting the high byte of a
Richard M. Stallman <rms@gnu.org>
parents: 7087
diff changeset
243 (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
244 (ah . (0 . 1)) (bh . (1 . 1)) (ch . (2 . 1)) (dh . (3 . 1))))
5443
391bfbbb9c1d Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
245
108520
a4cdc6d33cc6 * dos-fns.el: Add "dos-" prefix for namespace control.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 106815
diff changeset
246 (defun dos-make-register ()
5443
391bfbbb9c1d Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
247 (make-vector 8 0))
391bfbbb9c1d Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
248
108520
a4cdc6d33cc6 * dos-fns.el: Add "dos-" prefix for namespace control.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 106815
diff changeset
249 (defun dos-register-value (regs name)
a4cdc6d33cc6 * dos-fns.el: Add "dos-" prefix for namespace control.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 106815
diff changeset
250 (let ((where (cdr (assoc name dos-register-name-alist))))
5443
391bfbbb9c1d Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
251 (cond ((consp where)
391bfbbb9c1d Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
252 (let ((tem (aref regs (car where))))
391bfbbb9c1d Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
253 (if (zerop (cdr where))
391bfbbb9c1d Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
254 (% tem 256)
391bfbbb9c1d Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
255 (/ tem 256))))
391bfbbb9c1d Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
256 ((numberp where)
391bfbbb9c1d Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
257 (aref regs where))
391bfbbb9c1d Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
258 (t nil))))
391bfbbb9c1d Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
259
108520
a4cdc6d33cc6 * dos-fns.el: Add "dos-" prefix for namespace control.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 106815
diff changeset
260 (defun dos-set-register-value (regs name value)
5443
391bfbbb9c1d Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
261 (and (numberp value)
7256
0f06f87f3c3b (set-register-value): Setting the high byte of a
Richard M. Stallman <rms@gnu.org>
parents: 7087
diff changeset
262 (>= value 0)
108520
a4cdc6d33cc6 * dos-fns.el: Add "dos-" prefix for namespace control.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 106815
diff changeset
263 (let ((where (cdr (assoc name dos-register-name-alist))))
5443
391bfbbb9c1d Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
264 (cond ((consp where)
7256
0f06f87f3c3b (set-register-value): Setting the high byte of a
Richard M. Stallman <rms@gnu.org>
parents: 7087
diff changeset
265 (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
266 (value (logand value 255)))
0f06f87f3c3b (set-register-value): Setting the high byte of a
Richard M. Stallman <rms@gnu.org>
parents: 7087
diff changeset
267 (aset regs
0f06f87f3c3b (set-register-value): Setting the high byte of a
Richard M. Stallman <rms@gnu.org>
parents: 7087
diff changeset
268 (car where)
0f06f87f3c3b (set-register-value): Setting the high byte of a
Richard M. Stallman <rms@gnu.org>
parents: 7087
diff changeset
269 (if (zerop (cdr where))
0f06f87f3c3b (set-register-value): Setting the high byte of a
Richard M. Stallman <rms@gnu.org>
parents: 7087
diff changeset
270 (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
271 (logior (logand tem 255) (lsh value 8))))))
5443
391bfbbb9c1d Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
272 ((numberp where)
7256
0f06f87f3c3b (set-register-value): Setting the high byte of a
Richard M. Stallman <rms@gnu.org>
parents: 7087
diff changeset
273 (aset regs where (logand value 65535))))))
5443
391bfbbb9c1d Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
274 regs)
391bfbbb9c1d Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
275
108520
a4cdc6d33cc6 * dos-fns.el: Add "dos-" prefix for namespace control.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 106815
diff changeset
276 (defsubst dos-intdos (regs)
5443
391bfbbb9c1d Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
277 (int86 33 regs))
391bfbbb9c1d Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
278
14380
874cd82cd2b4 (mode25): Moved from `src/dosfns.c' for backward compatibility.
Richard M. Stallman <rms@gnu.org>
parents: 14189
diff changeset
279 ;; 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
280 ;; set screen size.
874cd82cd2b4 (mode25): Moved from `src/dosfns.c' for backward compatibility.
Richard M. Stallman <rms@gnu.org>
parents: 14189
diff changeset
281
108520
a4cdc6d33cc6 * dos-fns.el: Add "dos-" prefix for namespace control.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 106815
diff changeset
282 (defun dos-mode25 ()
14380
874cd82cd2b4 (mode25): Moved from `src/dosfns.c' for backward compatibility.
Richard M. Stallman <rms@gnu.org>
parents: 14189
diff changeset
283 "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
284 (interactive)
874cd82cd2b4 (mode25): Moved from `src/dosfns.c' for backward compatibility.
Richard M. Stallman <rms@gnu.org>
parents: 14189
diff changeset
285 (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
286
108520
a4cdc6d33cc6 * dos-fns.el: Add "dos-" prefix for namespace control.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 106815
diff changeset
287 (defun dos-mode4350 ()
14380
874cd82cd2b4 (mode25): Moved from `src/dosfns.c' for backward compatibility.
Richard M. Stallman <rms@gnu.org>
parents: 14189
diff changeset
288 "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
289 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
290 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
291 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
292 (interactive)
874cd82cd2b4 (mode25): Moved from `src/dosfns.c' for backward compatibility.
Richard M. Stallman <rms@gnu.org>
parents: 14189
diff changeset
293 (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
294 (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
295 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
296 (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
297
14189
557b3d11a381 (ps-lpr-switches, ps-lpr-command): Just setq them;
Richard M. Stallman <rms@gnu.org>
parents: 14169
diff changeset
298 (provide 'dos-fns)
557b3d11a381 (ps-lpr-switches, ps-lpr-command): Just setq them;
Richard M. Stallman <rms@gnu.org>
parents: 14169
diff changeset
299
93975
1e3a407766b9 Fix up comment convention on the arch-tag lines.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 87649
diff changeset
300 ;; arch-tag: 00b03579-8ebb-4a02-8762-5c5a929774ad
38436
b174db545cfd Some fixes to follow coding conventions.
Pavel Janík <Pavel@Janik.cz>
parents: 37262
diff changeset
301 ;;; dos-fns.el ends here