diff options
| -rw-r--r-- | lisp/ChangeLog | 4 | ||||
| -rw-r--r-- | lisp/dos-fns.el | 28 |
2 files changed, 21 insertions, 11 deletions
diff --git a/lisp/ChangeLog b/lisp/ChangeLog index e69e04dd552..9d618fe0c5b 100644 --- a/lisp/ChangeLog +++ b/lisp/ChangeLog | |||
| @@ -1,6 +1,8 @@ | |||
| 1 | 2001-09-16 Eli Zaretskii <eliz@is.elta.co.il> | 1 | 2001-09-16 Eli Zaretskii <eliz@is.elta.co.il> |
| 2 | 2 | ||
| 3 | * dos-fns.el (original-make-auto-save-file-name): New. | 3 | * dos-fns.el (convert-standard-filename): Replace invalid |
| 4 | characters only after converting dash/underscore to a period. | ||
| 5 | (original-make-auto-save-file-name): New. | ||
| 4 | (make-auto-save-file-name): New function, overrides the definition | 6 | (make-auto-save-file-name): New function, overrides the definition |
| 5 | on files.el and calls the original function via | 7 | on files.el and calls the original function via |
| 6 | original-make-auto-save-file-name. | 8 | original-make-auto-save-file-name. |
diff --git a/lisp/dos-fns.el b/lisp/dos-fns.el index 3751cc76d24..4b91cdf7a1b 100644 --- a/lisp/dos-fns.el +++ b/lisp/dos-fns.el | |||
| @@ -74,18 +74,25 @@ with a definition that really does change some file names." | |||
| 74 | ;; Change a leading period to a leading underscore. | 74 | ;; Change a leading period to a leading underscore. |
| 75 | (if (= (aref string 0) ?.) | 75 | (if (= (aref string 0) ?.) |
| 76 | (aset string 0 ?_)) | 76 | (aset string 0 ?_)) |
| 77 | ;; If the name is longer than 8 chars, and doesn't have a | ||
| 78 | ;; period, and we have a dash or underscore that isn't too | ||
| 79 | ;; close to the beginning, change that to a period. This | ||
| 80 | ;; is so we could salvage more characters of the original | ||
| 81 | ;; name by pushing them into the extension. | ||
| 82 | (if (and (not (string-match "\\." string)) | ||
| 83 | (> (length string) 8) | ||
| 84 | ;; We don't gain anything if we put the period closer | ||
| 85 | ;; than 5 chars from the beginning (5 + 3 = 8). | ||
| 86 | (setq i (string-match "[-_]" string 5))) | ||
| 87 | (aset string i ?\.)) | ||
| 77 | ;; Get rid of invalid characters. | 88 | ;; Get rid of invalid characters. |
| 78 | (while (setq i (string-match | 89 | (while (setq i (string-match |
| 79 | "[^-a-zA-Z0-9_.%~^$!#&{}@`'()\200-\376]" | 90 | "[^-a-zA-Z0-9_.%~^$!#&{}@`'()\200-\376]" |
| 80 | string)) | 91 | string)) |
| 81 | (aset string i ?_)) | 92 | (aset string i ?_)) |
| 82 | ;; If we don't have a period, | ||
| 83 | ;; and we have a dash or underscore that isn't the first char, | ||
| 84 | ;; change that to a period. | ||
| 85 | (if (and (not (string-match "\\." string)) | ||
| 86 | (setq i (string-match "[-_]" string 1))) | ||
| 87 | (aset string i ?\.)) | ||
| 88 | ;; If we don't have a period in the first 8 chars, insert one. | 93 | ;; If we don't have a period in the first 8 chars, insert one. |
| 94 | ;; This enables to have 3 more characters from the original | ||
| 95 | ;; name in the extension. | ||
| 89 | (if (> (or (string-match "\\." string) (length string)) | 96 | (if (> (or (string-match "\\." string) (length string)) |
| 90 | 8) | 97 | 8) |
| 91 | (setq string | 98 | (setq string |
| @@ -98,13 +105,14 @@ with a definition that really does change some file names." | |||
| 98 | (if (> (length string) (+ firstdot 4)) | 105 | (if (> (length string) (+ firstdot 4)) |
| 99 | (setq string (substring string 0 (+ firstdot 4)))) | 106 | (setq string (substring string 0 (+ firstdot 4)))) |
| 100 | ;; Change all periods except the first one into underscores. | 107 | ;; Change all periods except the first one into underscores. |
| 108 | ;; (DOS doesn't allow more than one period.) | ||
| 101 | (while (string-match "\\." string (1+ firstdot)) | 109 | (while (string-match "\\." string (1+ firstdot)) |
| 102 | (setq i (string-match "\\." string (1+ firstdot))) | 110 | (setq i (string-match "\\." string (1+ firstdot))) |
| 103 | (aset string i ?_)) | 111 | (aset string i ?_)) |
| 104 | ;; If the last character of the original filename was `~', | 112 | ;; If the last character of the original filename was `~' or `#', |
| 105 | ;; make sure the munged name ends with it also. This is so | 113 | ;; make sure the munged name ends with it also. This is so that |
| 106 | ;; a backup file retains its final `~'. | 114 | ;; backup and auto-save files retain their telltale form. |
| 107 | (if (equal lastchar ?~) | 115 | (if (memq lastchar '(?~ ?#)) |
| 108 | (aset string (1- (length string)) lastchar)))) | 116 | (aset string (1- (length string)) lastchar)))) |
| 109 | (concat (if (and (stringp dir) | 117 | (concat (if (and (stringp dir) |
| 110 | (memq (aref dir dlen-m-1) '(?/ ?\\))) | 118 | (memq (aref dir dlen-m-1) '(?/ ?\\))) |