Mercurial > emacs
annotate lisp/dos-fns.el @ 37591:0858ec0fee79
(rmail-sort-by-labels): Renamed from
rmail-sort-by-keywords.
author | Gerd Moellmann <gerd@gnu.org> |
---|---|
date | Mon, 07 May 2001 10:06:15 +0000 |
parents | 3e478bb3f389 |
children | b174db545cfd |
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 |
17977 | 5 ;; Maintainer: Morten Welinder <terra@diku.dk> |
5443 | 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 | |
13913
4e4201bcea5d
(convert-standard-filename): New alternate definition.
Richard M. Stallman <rms@gnu.org>
parents:
13487
diff
changeset
|
31 ;; 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
|
32 (defun convert-standard-filename (filename) |
4e4201bcea5d
(convert-standard-filename): New alternate definition.
Richard M. Stallman <rms@gnu.org>
parents:
13487
diff
changeset
|
33 "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
|
34 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
|
35 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
|
36 with a definition that really does change some file names." |
29855
4a37c3f4cb29
(convert-standard-filename): Convert leading
Eli Zaretskii <eliz@gnu.org>
parents:
24515
diff
changeset
|
37 (if (or (not (stringp filename)) |
29966
cf435e74e3ee
(convert-standard-filename): Fix last change.
Eli Zaretskii <eliz@gnu.org>
parents:
29855
diff
changeset
|
38 ;; 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
|
39 ;; "/", thus preventing infinite recursion. |
cf435e74e3ee
(convert-standard-filename): Fix last change.
Eli Zaretskii <eliz@gnu.org>
parents:
29855
diff
changeset
|
40 (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
|
41 filename |
29966
cf435e74e3ee
(convert-standard-filename): Fix last change.
Eli Zaretskii <eliz@gnu.org>
parents:
29855
diff
changeset
|
42 (let ((flen (length filename))) |
cf435e74e3ee
(convert-standard-filename): Fix last change.
Eli Zaretskii <eliz@gnu.org>
parents:
29855
diff
changeset
|
43 ;; 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
|
44 (if (memq (aref filename (1- flen)) '(?/ ?\\)) |
cf435e74e3ee
(convert-standard-filename): Fix last change.
Eli Zaretskii <eliz@gnu.org>
parents:
29855
diff
changeset
|
45 (concat (convert-standard-filename |
cf435e74e3ee
(convert-standard-filename): Fix last change.
Eli Zaretskii <eliz@gnu.org>
parents:
29855
diff
changeset
|
46 (substring filename 0 (1- flen))) |
cf435e74e3ee
(convert-standard-filename): Fix last change.
Eli Zaretskii <eliz@gnu.org>
parents:
29855
diff
changeset
|
47 "/") |
cf435e74e3ee
(convert-standard-filename): Fix last change.
Eli Zaretskii <eliz@gnu.org>
parents:
29855
diff
changeset
|
48 (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
|
49 ;; 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
|
50 ;; remote file names should never be passed through |
cf435e74e3ee
(convert-standard-filename): Fix last change.
Eli Zaretskii <eliz@gnu.org>
parents:
29855
diff
changeset
|
51 ;; 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
|
52 ;; filesystem! |
cf435e74e3ee
(convert-standard-filename): Fix last change.
Eli Zaretskii <eliz@gnu.org>
parents:
29855
diff
changeset
|
53 (file-name-handler-alist nil) |
cf435e74e3ee
(convert-standard-filename): Fix last change.
Eli Zaretskii <eliz@gnu.org>
parents:
29855
diff
changeset
|
54 (dir |
cf435e74e3ee
(convert-standard-filename): Fix last change.
Eli Zaretskii <eliz@gnu.org>
parents:
29855
diff
changeset
|
55 ;; 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
|
56 ;; "x:/bar/baz", substituting the current working |
cf435e74e3ee
(convert-standard-filename): Fix last change.
Eli Zaretskii <eliz@gnu.org>
parents:
29855
diff
changeset
|
57 ;; 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
|
58 ;; instead. |
cf435e74e3ee
(convert-standard-filename): Fix last change.
Eli Zaretskii <eliz@gnu.org>
parents:
29855
diff
changeset
|
59 (if (and (< 1 flen) |
cf435e74e3ee
(convert-standard-filename): Fix last change.
Eli Zaretskii <eliz@gnu.org>
parents:
29855
diff
changeset
|
60 (eq (aref filename 1) ?:) |
cf435e74e3ee
(convert-standard-filename): Fix last change.
Eli Zaretskii <eliz@gnu.org>
parents:
29855
diff
changeset
|
61 (null (string-match "[/\\]" filename))) |
cf435e74e3ee
(convert-standard-filename): Fix last change.
Eli Zaretskii <eliz@gnu.org>
parents:
29855
diff
changeset
|
62 (substring filename 0 2) |
cf435e74e3ee
(convert-standard-filename): Fix last change.
Eli Zaretskii <eliz@gnu.org>
parents:
29855
diff
changeset
|
63 (file-name-directory filename))) |
cf435e74e3ee
(convert-standard-filename): Fix last change.
Eli Zaretskii <eliz@gnu.org>
parents:
29855
diff
changeset
|
64 (dlen-m-1 (1- (length dir))) |
cf435e74e3ee
(convert-standard-filename): Fix last change.
Eli Zaretskii <eliz@gnu.org>
parents:
29855
diff
changeset
|
65 (string (copy-sequence (file-name-nondirectory filename))) |
cf435e74e3ee
(convert-standard-filename): Fix last change.
Eli Zaretskii <eliz@gnu.org>
parents:
29855
diff
changeset
|
66 (lastchar (aref string (1- (length string)))) |
cf435e74e3ee
(convert-standard-filename): Fix last change.
Eli Zaretskii <eliz@gnu.org>
parents:
29855
diff
changeset
|
67 i firstdot) |
cf435e74e3ee
(convert-standard-filename): Fix last change.
Eli Zaretskii <eliz@gnu.org>
parents:
29855
diff
changeset
|
68 (cond |
cf435e74e3ee
(convert-standard-filename): Fix last change.
Eli Zaretskii <eliz@gnu.org>
parents:
29855
diff
changeset
|
69 ((msdos-long-file-names) |
29855
4a37c3f4cb29
(convert-standard-filename): Convert leading
Eli Zaretskii <eliz@gnu.org>
parents:
24515
diff
changeset
|
70 ;; Replace characters that are invalid even on Windows. |
4a37c3f4cb29
(convert-standard-filename): Convert leading
Eli Zaretskii <eliz@gnu.org>
parents:
24515
diff
changeset
|
71 (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
|
72 (aset string i ?!))) |
cf435e74e3ee
(convert-standard-filename): Fix last change.
Eli Zaretskii <eliz@gnu.org>
parents:
29855
diff
changeset
|
73 ((not (member string '("" "." ".."))) |
cf435e74e3ee
(convert-standard-filename): Fix last change.
Eli Zaretskii <eliz@gnu.org>
parents:
29855
diff
changeset
|
74 ;; Change a leading period to a leading underscore. |
cf435e74e3ee
(convert-standard-filename): Fix last change.
Eli Zaretskii <eliz@gnu.org>
parents:
29855
diff
changeset
|
75 (if (= (aref string 0) ?.) |
cf435e74e3ee
(convert-standard-filename): Fix last change.
Eli Zaretskii <eliz@gnu.org>
parents:
29855
diff
changeset
|
76 (aset string 0 ?_)) |
cf435e74e3ee
(convert-standard-filename): Fix last change.
Eli Zaretskii <eliz@gnu.org>
parents:
29855
diff
changeset
|
77 ;; Get rid of invalid characters. |
cf435e74e3ee
(convert-standard-filename): Fix last change.
Eli Zaretskii <eliz@gnu.org>
parents:
29855
diff
changeset
|
78 (while (setq i (string-match |
cf435e74e3ee
(convert-standard-filename): Fix last change.
Eli Zaretskii <eliz@gnu.org>
parents:
29855
diff
changeset
|
79 "[^-a-zA-Z0-9_.%~^$!#&{}@`'()\200-\376]" |
cf435e74e3ee
(convert-standard-filename): Fix last change.
Eli Zaretskii <eliz@gnu.org>
parents:
29855
diff
changeset
|
80 string)) |
cf435e74e3ee
(convert-standard-filename): Fix last change.
Eli Zaretskii <eliz@gnu.org>
parents:
29855
diff
changeset
|
81 (aset string i ?_)) |
cf435e74e3ee
(convert-standard-filename): Fix last change.
Eli Zaretskii <eliz@gnu.org>
parents:
29855
diff
changeset
|
82 ;; If we don't have a period, |
cf435e74e3ee
(convert-standard-filename): Fix last change.
Eli Zaretskii <eliz@gnu.org>
parents:
29855
diff
changeset
|
83 ;; and we have a dash or underscore that isn't the first char, |
cf435e74e3ee
(convert-standard-filename): Fix last change.
Eli Zaretskii <eliz@gnu.org>
parents:
29855
diff
changeset
|
84 ;; change that to a period. |
cf435e74e3ee
(convert-standard-filename): Fix last change.
Eli Zaretskii <eliz@gnu.org>
parents:
29855
diff
changeset
|
85 (if (and (not (string-match "\\." string)) |
cf435e74e3ee
(convert-standard-filename): Fix last change.
Eli Zaretskii <eliz@gnu.org>
parents:
29855
diff
changeset
|
86 (setq i (string-match "[-_]" string 1))) |
cf435e74e3ee
(convert-standard-filename): Fix last change.
Eli Zaretskii <eliz@gnu.org>
parents:
29855
diff
changeset
|
87 (aset string i ?\.)) |
cf435e74e3ee
(convert-standard-filename): Fix last change.
Eli Zaretskii <eliz@gnu.org>
parents:
29855
diff
changeset
|
88 ;; If we don't have a period in the first 8 chars, insert one. |
cf435e74e3ee
(convert-standard-filename): Fix last change.
Eli Zaretskii <eliz@gnu.org>
parents:
29855
diff
changeset
|
89 (if (> (or (string-match "\\." string) (length string)) |
cf435e74e3ee
(convert-standard-filename): Fix last change.
Eli Zaretskii <eliz@gnu.org>
parents:
29855
diff
changeset
|
90 8) |
cf435e74e3ee
(convert-standard-filename): Fix last change.
Eli Zaretskii <eliz@gnu.org>
parents:
29855
diff
changeset
|
91 (setq string |
cf435e74e3ee
(convert-standard-filename): Fix last change.
Eli Zaretskii <eliz@gnu.org>
parents:
29855
diff
changeset
|
92 (concat (substring string 0 8) |
cf435e74e3ee
(convert-standard-filename): Fix last change.
Eli Zaretskii <eliz@gnu.org>
parents:
29855
diff
changeset
|
93 "." |
cf435e74e3ee
(convert-standard-filename): Fix last change.
Eli Zaretskii <eliz@gnu.org>
parents:
29855
diff
changeset
|
94 (substring string 8)))) |
cf435e74e3ee
(convert-standard-filename): Fix last change.
Eli Zaretskii <eliz@gnu.org>
parents:
29855
diff
changeset
|
95 (setq firstdot (or (string-match "\\." string) |
cf435e74e3ee
(convert-standard-filename): Fix last change.
Eli Zaretskii <eliz@gnu.org>
parents:
29855
diff
changeset
|
96 (1- (length string)))) |
cf435e74e3ee
(convert-standard-filename): Fix last change.
Eli Zaretskii <eliz@gnu.org>
parents:
29855
diff
changeset
|
97 ;; Truncate to 3 chars after the first period. |
cf435e74e3ee
(convert-standard-filename): Fix last change.
Eli Zaretskii <eliz@gnu.org>
parents:
29855
diff
changeset
|
98 (if (> (length string) (+ firstdot 4)) |
cf435e74e3ee
(convert-standard-filename): Fix last change.
Eli Zaretskii <eliz@gnu.org>
parents:
29855
diff
changeset
|
99 (setq string (substring string 0 (+ firstdot 4)))) |
cf435e74e3ee
(convert-standard-filename): Fix last change.
Eli Zaretskii <eliz@gnu.org>
parents:
29855
diff
changeset
|
100 ;; Change all periods except the first one into underscores. |
cf435e74e3ee
(convert-standard-filename): Fix last change.
Eli Zaretskii <eliz@gnu.org>
parents:
29855
diff
changeset
|
101 (while (string-match "\\." string (1+ firstdot)) |
cf435e74e3ee
(convert-standard-filename): Fix last change.
Eli Zaretskii <eliz@gnu.org>
parents:
29855
diff
changeset
|
102 (setq i (string-match "\\." string (1+ firstdot))) |
cf435e74e3ee
(convert-standard-filename): Fix last change.
Eli Zaretskii <eliz@gnu.org>
parents:
29855
diff
changeset
|
103 (aset string i ?_)) |
cf435e74e3ee
(convert-standard-filename): Fix last change.
Eli Zaretskii <eliz@gnu.org>
parents:
29855
diff
changeset
|
104 ;; If the last character of the original filename was `~', |
cf435e74e3ee
(convert-standard-filename): Fix last change.
Eli Zaretskii <eliz@gnu.org>
parents:
29855
diff
changeset
|
105 ;; make sure the munged name ends with it also. This is so |
cf435e74e3ee
(convert-standard-filename): Fix last change.
Eli Zaretskii <eliz@gnu.org>
parents:
29855
diff
changeset
|
106 ;; a backup file retains its final `~'. |
cf435e74e3ee
(convert-standard-filename): Fix last change.
Eli Zaretskii <eliz@gnu.org>
parents:
29855
diff
changeset
|
107 (if (equal lastchar ?~) |
cf435e74e3ee
(convert-standard-filename): Fix last change.
Eli Zaretskii <eliz@gnu.org>
parents:
29855
diff
changeset
|
108 (aset string (1- (length string)) lastchar)))) |
cf435e74e3ee
(convert-standard-filename): Fix last change.
Eli Zaretskii <eliz@gnu.org>
parents:
29855
diff
changeset
|
109 (concat (if (and (stringp dir) |
cf435e74e3ee
(convert-standard-filename): Fix last change.
Eli Zaretskii <eliz@gnu.org>
parents:
29855
diff
changeset
|
110 (memq (aref dir dlen-m-1) '(?/ ?\\))) |
cf435e74e3ee
(convert-standard-filename): Fix last change.
Eli Zaretskii <eliz@gnu.org>
parents:
29855
diff
changeset
|
111 (concat (convert-standard-filename |
cf435e74e3ee
(convert-standard-filename): Fix last change.
Eli Zaretskii <eliz@gnu.org>
parents:
29855
diff
changeset
|
112 (substring dir 0 dlen-m-1)) |
cf435e74e3ee
(convert-standard-filename): Fix last change.
Eli Zaretskii <eliz@gnu.org>
parents:
29855
diff
changeset
|
113 "/") |
cf435e74e3ee
(convert-standard-filename): Fix last change.
Eli Zaretskii <eliz@gnu.org>
parents:
29855
diff
changeset
|
114 (convert-standard-filename dir)) |
cf435e74e3ee
(convert-standard-filename): Fix last change.
Eli Zaretskii <eliz@gnu.org>
parents:
29855
diff
changeset
|
115 string)))))) |
13913
4e4201bcea5d
(convert-standard-filename): New alternate definition.
Richard M. Stallman <rms@gnu.org>
parents:
13487
diff
changeset
|
116 |
37262
3e478bb3f389
(dos-8+3-filename): Rename from dos-truncate-to-8+3.
Eli Zaretskii <eliz@gnu.org>
parents:
37257
diff
changeset
|
117 (defun dos-8+3-filename (filename) |
37257
6bbf8e77d787
(dos-truncate-to-8+3): New function.
Eli Zaretskii <eliz@gnu.org>
parents:
29966
diff
changeset
|
118 "Truncate FILENAME to DOS 8+3 limits." |
6bbf8e77d787
(dos-truncate-to-8+3): New function.
Eli Zaretskii <eliz@gnu.org>
parents:
29966
diff
changeset
|
119 (if (or (not (stringp filename)) |
6bbf8e77d787
(dos-truncate-to-8+3): New function.
Eli Zaretskii <eliz@gnu.org>
parents:
29966
diff
changeset
|
120 (< (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
|
121 filename |
6bbf8e77d787
(dos-truncate-to-8+3): New function.
Eli Zaretskii <eliz@gnu.org>
parents:
29966
diff
changeset
|
122 (let ((flen (length filename))) |
6bbf8e77d787
(dos-truncate-to-8+3): New function.
Eli Zaretskii <eliz@gnu.org>
parents:
29966
diff
changeset
|
123 ;; 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
|
124 (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
|
125 (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
|
126 "/") |
6bbf8e77d787
(dos-truncate-to-8+3): New function.
Eli Zaretskii <eliz@gnu.org>
parents:
29966
diff
changeset
|
127 (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
|
128 ;; 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
|
129 ;; 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
|
130 ;; 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
|
131 ;; filesystem! |
6bbf8e77d787
(dos-truncate-to-8+3): New function.
Eli Zaretskii <eliz@gnu.org>
parents:
29966
diff
changeset
|
132 (file-name-handler-alist nil) |
6bbf8e77d787
(dos-truncate-to-8+3): New function.
Eli Zaretskii <eliz@gnu.org>
parents:
29966
diff
changeset
|
133 (dir |
6bbf8e77d787
(dos-truncate-to-8+3): New function.
Eli Zaretskii <eliz@gnu.org>
parents:
29966
diff
changeset
|
134 ;; 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
|
135 ;; "x:/bar/baz", substituting the current working |
6bbf8e77d787
(dos-truncate-to-8+3): New function.
Eli Zaretskii <eliz@gnu.org>
parents:
29966
diff
changeset
|
136 ;; 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
|
137 ;; instead. |
6bbf8e77d787
(dos-truncate-to-8+3): New function.
Eli Zaretskii <eliz@gnu.org>
parents:
29966
diff
changeset
|
138 (if (and (< 1 flen) |
6bbf8e77d787
(dos-truncate-to-8+3): New function.
Eli Zaretskii <eliz@gnu.org>
parents:
29966
diff
changeset
|
139 (eq (aref filename 1) ?:) |
6bbf8e77d787
(dos-truncate-to-8+3): New function.
Eli Zaretskii <eliz@gnu.org>
parents:
29966
diff
changeset
|
140 (null (string-match "[/\\]" filename))) |
6bbf8e77d787
(dos-truncate-to-8+3): New function.
Eli Zaretskii <eliz@gnu.org>
parents:
29966
diff
changeset
|
141 (substring filename 0 2) |
6bbf8e77d787
(dos-truncate-to-8+3): New function.
Eli Zaretskii <eliz@gnu.org>
parents:
29966
diff
changeset
|
142 (file-name-directory filename))) |
6bbf8e77d787
(dos-truncate-to-8+3): New function.
Eli Zaretskii <eliz@gnu.org>
parents:
29966
diff
changeset
|
143 (dlen-m-1 (1- (length dir))) |
6bbf8e77d787
(dos-truncate-to-8+3): New function.
Eli Zaretskii <eliz@gnu.org>
parents:
29966
diff
changeset
|
144 (string (copy-sequence (file-name-nondirectory filename))) |
6bbf8e77d787
(dos-truncate-to-8+3): New function.
Eli Zaretskii <eliz@gnu.org>
parents:
29966
diff
changeset
|
145 (strlen (length string)) |
6bbf8e77d787
(dos-truncate-to-8+3): New function.
Eli Zaretskii <eliz@gnu.org>
parents:
29966
diff
changeset
|
146 (lastchar (aref string (1- strlen))) |
6bbf8e77d787
(dos-truncate-to-8+3): New function.
Eli Zaretskii <eliz@gnu.org>
parents:
29966
diff
changeset
|
147 i firstdot) |
6bbf8e77d787
(dos-truncate-to-8+3): New function.
Eli Zaretskii <eliz@gnu.org>
parents:
29966
diff
changeset
|
148 (setq firstdot (string-match "\\." string)) |
6bbf8e77d787
(dos-truncate-to-8+3): New function.
Eli Zaretskii <eliz@gnu.org>
parents:
29966
diff
changeset
|
149 (cond |
6bbf8e77d787
(dos-truncate-to-8+3): New function.
Eli Zaretskii <eliz@gnu.org>
parents:
29966
diff
changeset
|
150 (firstdot |
6bbf8e77d787
(dos-truncate-to-8+3): New function.
Eli Zaretskii <eliz@gnu.org>
parents:
29966
diff
changeset
|
151 ;; Truncate the extension to 3 characters. |
6bbf8e77d787
(dos-truncate-to-8+3): New function.
Eli Zaretskii <eliz@gnu.org>
parents:
29966
diff
changeset
|
152 (if (> strlen (+ firstdot 4)) |
6bbf8e77d787
(dos-truncate-to-8+3): New function.
Eli Zaretskii <eliz@gnu.org>
parents:
29966
diff
changeset
|
153 (setq string (substring string 0 (+ firstdot 4)))) |
6bbf8e77d787
(dos-truncate-to-8+3): New function.
Eli Zaretskii <eliz@gnu.org>
parents:
29966
diff
changeset
|
154 ;; Truncate the basename to 8 characters. |
6bbf8e77d787
(dos-truncate-to-8+3): New function.
Eli Zaretskii <eliz@gnu.org>
parents:
29966
diff
changeset
|
155 (if (> firstdot 8) |
6bbf8e77d787
(dos-truncate-to-8+3): New function.
Eli Zaretskii <eliz@gnu.org>
parents:
29966
diff
changeset
|
156 (setq string (concat (substring string 0 8) |
6bbf8e77d787
(dos-truncate-to-8+3): New function.
Eli Zaretskii <eliz@gnu.org>
parents:
29966
diff
changeset
|
157 "." |
6bbf8e77d787
(dos-truncate-to-8+3): New function.
Eli Zaretskii <eliz@gnu.org>
parents:
29966
diff
changeset
|
158 (substring string (1+ firstdot)))))) |
6bbf8e77d787
(dos-truncate-to-8+3): New function.
Eli Zaretskii <eliz@gnu.org>
parents:
29966
diff
changeset
|
159 ((> strlen 8) |
6bbf8e77d787
(dos-truncate-to-8+3): New function.
Eli Zaretskii <eliz@gnu.org>
parents:
29966
diff
changeset
|
160 ;; 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
|
161 (setq string (substring string 0 8)))) |
6bbf8e77d787
(dos-truncate-to-8+3): New function.
Eli Zaretskii <eliz@gnu.org>
parents:
29966
diff
changeset
|
162 ;; 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
|
163 ;; 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
|
164 ;; a backup file retains its final `~'. |
6bbf8e77d787
(dos-truncate-to-8+3): New function.
Eli Zaretskii <eliz@gnu.org>
parents:
29966
diff
changeset
|
165 (if (equal lastchar ?~) |
6bbf8e77d787
(dos-truncate-to-8+3): New function.
Eli Zaretskii <eliz@gnu.org>
parents:
29966
diff
changeset
|
166 (aset string (1- (length string)) lastchar)) |
6bbf8e77d787
(dos-truncate-to-8+3): New function.
Eli Zaretskii <eliz@gnu.org>
parents:
29966
diff
changeset
|
167 (concat (if (and (stringp dir) |
6bbf8e77d787
(dos-truncate-to-8+3): New function.
Eli Zaretskii <eliz@gnu.org>
parents:
29966
diff
changeset
|
168 (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
|
169 (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
|
170 "/") |
6bbf8e77d787
(dos-truncate-to-8+3): New function.
Eli Zaretskii <eliz@gnu.org>
parents:
29966
diff
changeset
|
171 ;; 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
|
172 (dos-8+3-filename dir)) |
37257
6bbf8e77d787
(dos-truncate-to-8+3): New function.
Eli Zaretskii <eliz@gnu.org>
parents:
29966
diff
changeset
|
173 string)))))) |
6bbf8e77d787
(dos-truncate-to-8+3): New function.
Eli Zaretskii <eliz@gnu.org>
parents:
29966
diff
changeset
|
174 |
22070
d8e53123116c
(dos-ps-printer, dos-printer, msdos-shells):
Richard M. Stallman <rms@gnu.org>
parents:
21568
diff
changeset
|
175 ;; See dos-vars.el for defcustom. |
d8e53123116c
(dos-ps-printer, dos-printer, msdos-shells):
Richard M. Stallman <rms@gnu.org>
parents:
21568
diff
changeset
|
176 (defvar msdos-shells) |
5443 | 177 |
24515
ef4a540c34ff
(set-default-process-coding-system): Copied from dos-w32.el.
Andrew Innes <andrewi@gnu.org>
parents:
22676
diff
changeset
|
178 ;;; Override setting chosen at startup. |
ef4a540c34ff
(set-default-process-coding-system): Copied from dos-w32.el.
Andrew Innes <andrewi@gnu.org>
parents:
22676
diff
changeset
|
179 (defun set-default-process-coding-system () |
ef4a540c34ff
(set-default-process-coding-system): Copied from dos-w32.el.
Andrew Innes <andrewi@gnu.org>
parents:
22676
diff
changeset
|
180 (setq default-process-coding-system |
ef4a540c34ff
(set-default-process-coding-system): Copied from dos-w32.el.
Andrew Innes <andrewi@gnu.org>
parents:
22676
diff
changeset
|
181 (if default-enable-multibyte-characters |
ef4a540c34ff
(set-default-process-coding-system): Copied from dos-w32.el.
Andrew Innes <andrewi@gnu.org>
parents:
22676
diff
changeset
|
182 '(undecided-dos . undecided-dos) |
ef4a540c34ff
(set-default-process-coding-system): Copied from dos-w32.el.
Andrew Innes <andrewi@gnu.org>
parents:
22676
diff
changeset
|
183 '(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
|
184 |
ef4a540c34ff
(set-default-process-coding-system): Copied from dos-w32.el.
Andrew Innes <andrewi@gnu.org>
parents:
22676
diff
changeset
|
185 (add-hook 'before-init-hook 'set-default-process-coding-system) |
ef4a540c34ff
(set-default-process-coding-system): Copied from dos-w32.el.
Andrew Innes <andrewi@gnu.org>
parents:
22676
diff
changeset
|
186 |
16690
97029c2699a7
(register-name-alist): Use defvar.
Richard M. Stallman <rms@gnu.org>
parents:
16027
diff
changeset
|
187 (defvar register-name-alist |
5443 | 188 '((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
|
189 (cflag . 6) (flags . 7) |
0f06f87f3c3b
(set-register-value): Setting the high byte of a
Richard M. Stallman <rms@gnu.org>
parents:
7087
diff
changeset
|
190 (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
|
191 (ah . (0 . 1)) (bh . (1 . 1)) (ch . (2 . 1)) (dh . (3 . 1)))) |
5443 | 192 |
193 (defun make-register () | |
194 (make-vector 8 0)) | |
195 | |
196 (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
|
197 (let ((where (cdr (assoc name register-name-alist)))) |
5443 | 198 (cond ((consp where) |
199 (let ((tem (aref regs (car where)))) | |
200 (if (zerop (cdr where)) | |
201 (% tem 256) | |
202 (/ tem 256)))) | |
203 ((numberp where) | |
204 (aref regs where)) | |
205 (t nil)))) | |
206 | |
207 (defun set-register-value (regs name value) | |
208 (and (numberp value) | |
7256
0f06f87f3c3b
(set-register-value): Setting the high byte of a
Richard M. Stallman <rms@gnu.org>
parents:
7087
diff
changeset
|
209 (>= value 0) |
0f06f87f3c3b
(set-register-value): Setting the high byte of a
Richard M. Stallman <rms@gnu.org>
parents:
7087
diff
changeset
|
210 (let ((where (cdr (assoc name register-name-alist)))) |
5443 | 211 (cond ((consp where) |
7256
0f06f87f3c3b
(set-register-value): Setting the high byte of a
Richard M. Stallman <rms@gnu.org>
parents:
7087
diff
changeset
|
212 (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
|
213 (value (logand value 255))) |
0f06f87f3c3b
(set-register-value): Setting the high byte of a
Richard M. Stallman <rms@gnu.org>
parents:
7087
diff
changeset
|
214 (aset regs |
0f06f87f3c3b
(set-register-value): Setting the high byte of a
Richard M. Stallman <rms@gnu.org>
parents:
7087
diff
changeset
|
215 (car where) |
0f06f87f3c3b
(set-register-value): Setting the high byte of a
Richard M. Stallman <rms@gnu.org>
parents:
7087
diff
changeset
|
216 (if (zerop (cdr where)) |
0f06f87f3c3b
(set-register-value): Setting the high byte of a
Richard M. Stallman <rms@gnu.org>
parents:
7087
diff
changeset
|
217 (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
|
218 (logior (logand tem 255) (lsh value 8)))))) |
5443 | 219 ((numberp where) |
7256
0f06f87f3c3b
(set-register-value): Setting the high byte of a
Richard M. Stallman <rms@gnu.org>
parents:
7087
diff
changeset
|
220 (aset regs where (logand value 65535)))))) |
5443 | 221 regs) |
222 | |
223 (defsubst intdos (regs) | |
224 (int86 33 regs)) | |
225 | |
14380
874cd82cd2b4
(mode25): Moved from `src/dosfns.c' for backward compatibility.
Richard M. Stallman <rms@gnu.org>
parents:
14189
diff
changeset
|
226 ;; 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
|
227 ;; set screen size. |
874cd82cd2b4
(mode25): Moved from `src/dosfns.c' for backward compatibility.
Richard M. Stallman <rms@gnu.org>
parents:
14189
diff
changeset
|
228 |
874cd82cd2b4
(mode25): Moved from `src/dosfns.c' for backward compatibility.
Richard M. Stallman <rms@gnu.org>
parents:
14189
diff
changeset
|
229 (defun mode25 () |
874cd82cd2b4
(mode25): Moved from `src/dosfns.c' for backward compatibility.
Richard M. Stallman <rms@gnu.org>
parents:
14189
diff
changeset
|
230 "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
|
231 (interactive) |
874cd82cd2b4
(mode25): Moved from `src/dosfns.c' for backward compatibility.
Richard M. Stallman <rms@gnu.org>
parents:
14189
diff
changeset
|
232 (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
|
233 |
874cd82cd2b4
(mode25): Moved from `src/dosfns.c' for backward compatibility.
Richard M. Stallman <rms@gnu.org>
parents:
14189
diff
changeset
|
234 (defun mode4350 () |
874cd82cd2b4
(mode25): Moved from `src/dosfns.c' for backward compatibility.
Richard M. Stallman <rms@gnu.org>
parents:
14189
diff
changeset
|
235 "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
|
236 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
|
237 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
|
238 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
|
239 (interactive) |
874cd82cd2b4
(mode25): Moved from `src/dosfns.c' for backward compatibility.
Richard M. Stallman <rms@gnu.org>
parents:
14189
diff
changeset
|
240 (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
|
241 (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
|
242 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
|
243 (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
|
244 |
14189
557b3d11a381
(ps-lpr-switches, ps-lpr-command): Just setq them;
Richard M. Stallman <rms@gnu.org>
parents:
14169
diff
changeset
|
245 (provide 'dos-fns) |
557b3d11a381
(ps-lpr-switches, ps-lpr-command): Just setq them;
Richard M. Stallman <rms@gnu.org>
parents:
14169
diff
changeset
|
246 |
557b3d11a381
(ps-lpr-switches, ps-lpr-command): Just setq them;
Richard M. Stallman <rms@gnu.org>
parents:
14169
diff
changeset
|
247 ; dos-fns.el ends here |