aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorRichard M. Stallman1994-06-17 21:42:34 +0000
committerRichard M. Stallman1994-06-17 21:42:34 +0000
commit0a1763b4086dc5f989db9eed03fcc618b6b1831a (patch)
treec3593a1ac44306ac2f3991da41d0eed013c9c049
parent67a69ba62f3a845b185d0f88ef421eb489a0dac2 (diff)
downloademacs-0a1763b4086dc5f989db9eed03fcc618b6b1831a.tar.gz
emacs-0a1763b4086dc5f989db9eed03fcc618b6b1831a.zip
(make-auto-save-file-name): Convert slashes to \! and double the backslashes.
-rw-r--r--lisp/files.el27
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'."
1950 "#" 1950 "#"
1951 (file-name-nondirectory buffer-file-name) 1951 (file-name-nondirectory buffer-file-name)
1952 "#") 1952 "#")
1953 ;; For non-file bfr, use bfr name and Emacs pid. 1953
1954 ;; Don't allow slashes, though; auto-save would try to interpret it 1954 ;; Deal with buffers that don't have any associated files. (Mail
1955 ;; as a pathname, and it might not exist. 1955 ;; mode tends to create a good number of these.)
1956
1956 (let ((buffer-name (buffer-name)) 1957 (let ((buffer-name (buffer-name))
1957 (save-match-data (match-data))) 1958 (limit 0))
1958 (while (string-match "/" buffer-name) 1959 ;; Use technique from Sebastian Kremer's auto-save
1959 (aset buffer-name (match-beginning 0) ?-)) 1960 ;; package to turn slashes into \\!. This ensures that
1960 (store-match-data save-match-data) 1961 ;; the auto-save buffer name is unique.
1962
1963 (while (string-match "[/\\]" buffer-name limit)
1964 (setq buffer-name (concat (substring buffer-name 0 (match-beginning 0))
1965 (if (string= (substring buffer-name
1966 (match-beginning 0)
1967 (match-end 0))
1968 "/")
1969 "\\!"
1970 "\\\\")
1971 (substring buffer-name (match-end 0))))
1972 (setq limit (1+ (match-end 0))))
1973
1961 (expand-file-name (format "#%s#%s#" buffer-name (make-temp-name "")))))) 1974 (expand-file-name (format "#%s#%s#" buffer-name (make-temp-name ""))))))
1962 1975
1963(defun auto-save-file-name-p (filename) 1976(defun auto-save-file-name-p (filename)