aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorRichard M. Stallman1996-01-01 23:53:33 +0000
committerRichard M. Stallman1996-01-01 23:53:33 +0000
commit44998f5b9cba75ca6c2441cda96ba4afd1591b0a (patch)
tree6d4340fb0ab096c58c600fe5fd6762df5dd5ced2
parent1f7f78f1abb5db40a6b04a51fe481a3bc5f4cea6 (diff)
downloademacs-44998f5b9cba75ca6c2441cda96ba4afd1591b0a.tar.gz
emacs-44998f5b9cba75ca6c2441cda96ba4afd1591b0a.zip
(convert-standard-filename): New alternate definition.
-rw-r--r--lisp/dos-fns.el39
1 files changed, 39 insertions, 0 deletions
diff --git a/lisp/dos-fns.el b/lisp/dos-fns.el
index 1f2a7153ef9..50e32863602 100644
--- a/lisp/dos-fns.el
+++ b/lisp/dos-fns.el
@@ -42,6 +42,45 @@
42(setq grep-regexp-alist 42(setq grep-regexp-alist
43 '(("^\\(\\([a-zA-Z]:\\)?[^:( \t\n]+\\)[:( \t]+\\([0-9]+\\)[:) \t]" 1 3))) 43 '(("^\\(\\([a-zA-Z]:\\)?[^:( \t\n]+\\)[:( \t]+\\([0-9]+\\)[:) \t]" 1 3)))
44 44
45;; This overrides a trivial definition in files.el.
46(defun convert-standard-filename (filename)
47 "Convert a standard file's name to something suitable for the current OS.
48This function's standard definition is trivial; it just returns the argument.
49However, on some systems, the function is redefined
50with a definition that really does change some file names."
51 (let ((dir (file-name-directory filename))
52 (string (copy-sequence (file-name-nondirectory filename)))
53 i firstdot)
54 ;; Change a leading period to a leading underscore.
55 (if (= (aref string 0) ?.)
56 (aset string 0 ?_))
57 ;; Get rid of invalid characters.
58 (while (setq i (string-match "[^a-zA-Z0-9_.%~]" string))
59 (aset string i ?_))
60 ;; If we don't have a period,
61 ;; and we have a dash or underscore that isn't the first char,
62 ;; change that to a period.
63 (if (and (not (string-match "\\." string))
64 (setq i (string-match "[-_]" string 1)))
65 (aset string i ?\.))
66 ;; If we don't have a period in the first 8 chars, insert one.
67 (if (> (or (string-match "\\." string)
68 (length string))
69 8)
70 (setq string
71 (concat (substring string 0 8)
72 "."
73 (substring string 8))))
74 (setq firstdot (string-match "\\." string))
75 ;; Truncate to 3 chars after the first period.
76 (if (> (length string) (+ firstdot 4))
77 (setq string (substring string 0 (+ firstdot 4))))
78 ;; Change all periods except the first one into underscores.
79 (while (string-match "\\." string (1+ firstdot))
80 (setq i (string-match "\\." string (1+ firstdot)))
81 (aset string i ?_))
82 (concat dir string)))
83
45(defvar file-name-buffer-file-type-alist 84(defvar file-name-buffer-file-type-alist
46 '( 85 '(
47 ("[:/].*config.sys$" . nil) ; config.sys text 86 ("[:/].*config.sys$" . nil) ; config.sys text