diff options
author | Richard M. Stallman <rms@gnu.org> | 1994-06-17 21:42:34 +0000 |
---|---|---|
committer | Richard M. Stallman <rms@gnu.org> | 1994-06-17 21:42:34 +0000 |
commit | 0a1763b4086dc5f989db9eed03fcc618b6b1831a (patch) | |
tree | c3593a1ac44306ac2f3991da41d0eed013c9c049 /lisp/files.el | |
parent | 67a69ba62f3a845b185d0f88ef421eb489a0dac2 (diff) | |
download | emacs-0a1763b4086dc5f989db9eed03fcc618b6b1831a.tar.gz |
(make-auto-save-file-name): Convert slashes to \! and double the backslashes.
Diffstat (limited to 'lisp/files.el')
-rw-r--r-- | lisp/files.el | 27 |
1 files changed, 20 insertions, 7 deletions
diff --git a/lisp/files.el b/lisp/files.el index b0aabd9eebf..b46b2294d05 100644 --- a/lisp/files.el +++ b/lisp/files.el @@ -1950,14 +1950,27 @@ See also `auto-save-file-name-p'." "#" (file-name-nondirectory buffer-file-name) "#") - ;; For non-file bfr, use bfr name and Emacs pid. - ;; Don't allow slashes, though; auto-save would try to interpret it - ;; as a pathname, and it might not exist. + + ;; Deal with buffers that don't have any associated files. (Mail + ;; mode tends to create a good number of these.) + (let ((buffer-name (buffer-name)) - (save-match-data (match-data))) - (while (string-match "/" buffer-name) - (aset buffer-name (match-beginning 0) ?-)) - (store-match-data save-match-data) + (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)))) + (expand-file-name (format "#%s#%s#" buffer-name (make-temp-name "")))))) (defun auto-save-file-name-p (filename) |