aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--lisp/files.el25
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'."
2578 2578
2579 (let ((buffer-name (buffer-name)) 2579 (let ((buffer-name (buffer-name))
2580 (limit 0)) 2580 (limit 0))
2581 ;; Use technique from Sebastian Kremer's auto-save 2581 ;; Eliminate all slashes and backslashes by
2582 ;; package to turn slashes into \\!. This ensures that 2582 ;; replacing them with sequences that start with %.
2583 ;; the auto-save buffer name is unique. 2583 ;; Quote % also, to keep distinct names distinct.
2584 2584 (while (string-match "[/\\%]" buffer-name limit)
2585 (while (string-match "[/\\]" buffer-name limit) 2585 (let* ((character (aref buffer-name (match-beginning 0)))
2586 (setq buffer-name (concat (substring buffer-name 0 (match-beginning 0)) 2586 (replacement
2587 (if (string= (substring buffer-name 2587 (cond ((eq character ?%) "%%")
2588 (match-beginning 0) 2588 ((eq character ?/) "%+")
2589 (match-end 0)) 2589 ((eq character ?\\) "%-"))))
2590 "/") 2590 (setq buffer-name (replace-match replacement t t buffer-name))
2591 "\\!" 2591 (setq limit (1+ (match-end 0)))))
2592 "\\\\")
2593 (substring buffer-name (match-end 0))))
2594 (setq limit (1+ (match-end 0))))
2595 ;; Generate the file name. 2592 ;; Generate the file name.
2596 (expand-file-name 2593 (expand-file-name
2597 (format "#%s#%s#" buffer-name (make-temp-name "")) 2594 (format "#%s#%s#" buffer-name (make-temp-name ""))