diff options
| author | Richard M. Stallman <rms@gnu.org> | 1997-03-29 00:32:54 +0000 |
|---|---|---|
| committer | Richard M. Stallman <rms@gnu.org> | 1997-03-29 00:32:54 +0000 |
| commit | c3348e101b351f985ee6492b2dabfdacac22913d (patch) | |
| tree | 02cdb0d10f6c093bece81e1a3f6e91826aed8b50 | |
| parent | 9201fa0683b880f1ff0101f471b4b2243449ea51 (diff) | |
| download | emacs-c3348e101b351f985ee6492b2dabfdacac22913d.tar.gz | |
(make-auto-save-file-name): Replace both / and \
with sequences starting with %.
| -rw-r--r-- | lisp/files.el | 25 |
1 files changed, 11 insertions, 14 deletions
diff --git a/lisp/files.el b/lisp/files.el index eabb70377cb..6d36275e365 100644 --- a/lisp/files.el +++ b/lisp/files.el @@ -2578,20 +2578,17 @@ See also `auto-save-file-name-p'." (let ((buffer-name (buffer-name)) (limit 0)) - ;; Use technique from Sebastian Kremer's auto-save - ;; package to turn slashes into \\!. This ensures that - ;; the auto-save buffer name is unique. - - (while (string-match "[/\\]" buffer-name limit) - (setq buffer-name (concat (substring buffer-name 0 (match-beginning 0)) - (if (string= (substring buffer-name - (match-beginning 0) - (match-end 0)) - "/") - "\\!" - "\\\\") - (substring buffer-name (match-end 0)))) - (setq limit (1+ (match-end 0)))) + ;; Eliminate all slashes and backslashes by + ;; replacing them with sequences that start with %. + ;; Quote % also, to keep distinct names distinct. + (while (string-match "[/\\%]" buffer-name limit) + (let* ((character (aref buffer-name (match-beginning 0))) + (replacement + (cond ((eq character ?%) "%%") + ((eq character ?/) "%+") + ((eq character ?\\) "%-")))) + (setq buffer-name (replace-match replacement t t buffer-name)) + (setq limit (1+ (match-end 0))))) ;; Generate the file name. (expand-file-name (format "#%s#%s#" buffer-name (make-temp-name "")) |
