Mercurial > emacs
comparison lisp/dos-fns.el @ 14380:874cd82cd2b4
(mode25): Moved from `src/dosfns.c' for backward compatibility.
(mode4350): Moved from `src/dosfns.c' for backward compatibility.
(convert-standard-filename): Preserve ~ as last char.
(convert-standard-filename): Don't do anything if the
argument is empty, or isn't a string; leave alone characters with
ASCII codes above 127 and special characters legal in DOS filenames.
author | Richard M. Stallman <rms@gnu.org> |
---|---|
date | Fri, 26 Jan 1996 19:49:01 +0000 |
parents | 557b3d11a381 |
children | 20f4c4a078b2 |
comparison
equal
deleted
inserted
replaced
14379:ea15aa9bae36 | 14380:874cd82cd2b4 |
---|---|
47 (defun convert-standard-filename (filename) | 47 (defun convert-standard-filename (filename) |
48 "Convert a standard file's name to something suitable for the current OS. | 48 "Convert a standard file's name to something suitable for the current OS. |
49 This function's standard definition is trivial; it just returns the argument. | 49 This function's standard definition is trivial; it just returns the argument. |
50 However, on some systems, the function is redefined | 50 However, on some systems, the function is redefined |
51 with a definition that really does change some file names." | 51 with a definition that really does change some file names." |
52 (let ((dir (file-name-directory filename)) | 52 (let* ((dir (file-name-directory filename)) |
53 (string (copy-sequence (file-name-nondirectory filename))) | 53 (string (copy-sequence (file-name-nondirectory filename))) |
54 i firstdot) | 54 (lastchar (aref string (1- (length string)))) |
55 ;; Change a leading period to a leading underscore. | 55 i firstdot) |
56 (if (= (aref string 0) ?.) | 56 ;; If the argument is empty, just return it. |
57 (aset string 0 ?_)) | 57 (if (or (not (stringp filename)) |
58 ;; Get rid of invalid characters. | 58 (string= filename "") |
59 (while (setq i (string-match "[^a-zA-Z0-9_.%~]" string)) | 59 (string= string "")) |
60 (aset string i ?_)) | 60 filename |
61 ;; If we don't have a period, | 61 (progn |
62 ;; and we have a dash or underscore that isn't the first char, | 62 ;; Change a leading period to a leading underscore. |
63 ;; change that to a period. | 63 (if (= (aref string 0) ?.) |
64 (if (and (not (string-match "\\." string)) | 64 (aset string 0 ?_)) |
65 (setq i (string-match "[-_]" string 1))) | 65 ;; Get rid of invalid characters. |
66 (aset string i ?\.)) | 66 (while (setq i (string-match |
67 ;; If we don't have a period in the first 8 chars, insert one. | 67 "[^-a-zA-Z0-9_.%~^$!#&{}@`'()\200-\376]" |
68 (if (> (or (string-match "\\." string) | 68 string)) |
69 (length string)) | 69 (aset string i ?_)) |
70 8) | 70 ;; If we don't have a period, |
71 (setq string | 71 ;; and we have a dash or underscore that isn't the first char, |
72 (concat (substring string 0 8) | 72 ;; change that to a period. |
73 "." | 73 (if (and (not (string-match "\\." string)) |
74 (substring string 8)))) | 74 (setq i (string-match "[-_]" string 1))) |
75 (setq firstdot (or (string-match "\\." string) (1- (length string)))) | 75 (aset string i ?\.)) |
76 ;; Truncate to 3 chars after the first period. | 76 ;; If we don't have a period in the first 8 chars, insert one. |
77 (if (> (length string) (+ firstdot 4)) | 77 (if (> (or (string-match "\\." string) |
78 (setq string (substring string 0 (+ firstdot 4)))) | 78 (length string)) |
79 ;; Change all periods except the first one into underscores. | 79 8) |
80 (while (string-match "\\." string (1+ firstdot)) | 80 (setq string |
81 (setq i (string-match "\\." string (1+ firstdot))) | 81 (concat (substring string 0 8) |
82 (aset string i ?_)) | 82 "." |
83 (concat dir string))) | 83 (substring string 8)))) |
84 (setq firstdot (or (string-match "\\." string) (1- (length string)))) | |
85 ;; Truncate to 3 chars after the first period. | |
86 (if (> (length string) (+ firstdot 4)) | |
87 (setq string (substring string 0 (+ firstdot 4)))) | |
88 ;; Change all periods except the first one into underscores. | |
89 (while (string-match "\\." string (1+ firstdot)) | |
90 (setq i (string-match "\\." string (1+ firstdot))) | |
91 (aset string i ?_)) | |
92 ;; If the last character of the original filename was `~', | |
93 ;; make sure the munged name ends with it also. | |
94 (if (equal lastchar ?~) | |
95 (aset string (1- (length string)) lastchar)) | |
96 (concat dir string))))) | |
84 | 97 |
85 (defvar file-name-buffer-file-type-alist | 98 (defvar file-name-buffer-file-type-alist |
86 '( | 99 '( |
87 ("[:/].*config.sys$" . nil) ; config.sys text | 100 ("[:/].*config.sys$" . nil) ; config.sys text |
88 ("\\.elc$" . t) ; emacs stuff | 101 ("\\.elc$" . t) ; emacs stuff |
255 (setq ps-lpr-command "gs") | 268 (setq ps-lpr-command "gs") |
256 | 269 |
257 (setq ps-lpr-switches '("-q" "-dNOPAUSE" "-sDEVICE=epson" "-r240x60" | 270 (setq ps-lpr-switches '("-q" "-dNOPAUSE" "-sDEVICE=epson" "-r240x60" |
258 "-sOutputFile=LPT1" "-")) | 271 "-sOutputFile=LPT1" "-")) |
259 | 272 |
273 ;; Backward compatibility for obsolescent functions which | |
274 ;; set screen size. | |
275 | |
276 (defun mode25 () | |
277 "Changes the number of screen rows to 25." | |
278 (interactive) | |
279 (set-frame-size (selected-frame) 80 25)) | |
280 | |
281 (defun mode4350 () | |
282 "Changes the number of rows to 43 or 50. | |
283 Emacs always tries to set the screen height to 50 rows first. | |
284 If this fails, it will try to set it to 43 rows, on the assumption | |
285 that your video hardware might not support 50-line mode." | |
286 (interactive) | |
287 (set-frame-size (selected-frame) 80 50) | |
288 (if (eq (frame-height (selected-frame)) 50) | |
289 nil ; the original built-in function returned nil | |
290 (set-frame-size (selected-frame) 80 43))) | |
291 | |
260 (provide 'dos-fns) | 292 (provide 'dos-fns) |
261 | 293 |
262 ; dos-fns.el ends here | 294 ; dos-fns.el ends here |