aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorGlenn Morris2002-04-20 22:22:57 +0000
committerGlenn Morris2002-04-20 22:22:57 +0000
commita0b60c3317182b1f50a4530fc5eb237c07b8df85 (patch)
tree0669d21086288b4c8933ca9a4d01388e93c247aa
parent7769818bc992fc0e3d413e34921a371b60ad9463 (diff)
downloademacs-a0b60c3317182b1f50a4530fc5eb237c07b8df85.tar.gz
emacs-a0b60c3317182b1f50a4530fc5eb237c07b8df85.zip
(auto-save-file-name-transforms): Doc string addition - no effect for
MS-DOS systems without long file names. Add third element for uniquifying filenames. (make-auto-save-file-name): Make a unique filename if indicated by new element of auto-save-file-name-transforms.
-rw-r--r--lisp/files.el34
1 files changed, 26 insertions, 8 deletions
diff --git a/lisp/files.el b/lisp/files.el
index 1c97aaac71f..da2d9c1655b 100644
--- a/lisp/files.el
+++ b/lisp/files.el
@@ -296,21 +296,31 @@ Normally auto-save files are written under other names."
296 `(("\\`/[^/]*:\\(.+/\\)*\\(.*\\)" 296 `(("\\`/[^/]*:\\(.+/\\)*\\(.*\\)"
297 ;; Don't put "\\2" inside expand-file-name, since it will be 297 ;; Don't put "\\2" inside expand-file-name, since it will be
298 ;; transformed to "/2" on DOS/Windows. 298 ;; transformed to "/2" on DOS/Windows.
299 ,(concat temporary-file-directory "\\2"))) 299 ,(concat temporary-file-directory "\\2") t))
300 "*Transforms to apply to buffer file name before making auto-save file name. 300 "*Transforms to apply to buffer file name before making auto-save file name.
301Each transform is a list (REGEXP REPLACEMENT): 301Each transform is a list (REGEXP REPLACEMENT UNIQUIFY):
302REGEXP is a regular expression to match against the file name. 302REGEXP is a regular expression to match against the file name.
303If it matches, `replace-match' is used to replace the 303If it matches, `replace-match' is used to replace the
304matching part with REPLACEMENT. 304matching part with REPLACEMENT.
305If the optional element UNIQUIFY is non-nil, the auto-save file name is
306constructed by taking the directory part of the replaced file-name,
307concatenated with the buffer file name with all directory separators
308changed to `!' to prevent clashes. This will not work
309correctly if your filesystem truncates the resulting name.
310
305All the transforms in the list are tried, in the order they are listed. 311All the transforms in the list are tried, in the order they are listed.
306When one transform applies, its result is final; 312When one transform applies, its result is final;
307no further transforms are tried. 313no further transforms are tried.
308 314
309The default value is set up to put the auto-save file into the 315The default value is set up to put the auto-save file into the
310temporary directory (see the variable `temporary-file-directory') for 316temporary directory (see the variable `temporary-file-directory') for
311editing a remote file." 317editing a remote file.
318
319On MS-DOS filesystems without long names this variable is always
320ignored."
312 :group 'auto-save 321 :group 'auto-save
313 :type '(repeat (list (string :tag "Regexp") (string :tag "Replacement"))) 322 :type '(repeat (list (string :tag "Regexp") (string :tag "Replacement")
323 (boolean :tag "Uniquify")))
314 :version "21.1") 324 :version "21.1")
315 325
316(defcustom save-abbrevs t 326(defcustom save-abbrevs t
@@ -3354,16 +3364,24 @@ See also `auto-save-file-name-p'."
3354 (if buffer-file-name 3364 (if buffer-file-name
3355 (let ((list auto-save-file-name-transforms) 3365 (let ((list auto-save-file-name-transforms)
3356 (filename buffer-file-name) 3366 (filename buffer-file-name)
3357 result) 3367 result uniq)
3358 ;; Apply user-specified translations 3368 ;; Apply user-specified translations
3359 ;; to the file name. 3369 ;; to the file name.
3360 (while (and list (not result)) 3370 (while (and list (not result))
3361 (if (string-match (car (car list)) filename) 3371 (if (string-match (car (car list)) filename)
3362 (setq result (replace-match (cadr (car list)) t nil 3372 (setq result (replace-match (cadr (car list)) t nil
3363 filename))) 3373 filename)
3374 uniq (caddr (car list))))
3364 (setq list (cdr list))) 3375 (setq list (cdr list)))
3365 (if result (setq filename result)) 3376 (if result
3366 3377 (if uniq
3378 (setq filename (concat
3379 (file-name-directory result)
3380 (subst-char-in-string
3381 directory-sep-char ?!
3382 (replace-regexp-in-string "!" "!!"
3383 filename))))
3384 (setq filename result)))
3367 (setq result 3385 (setq result
3368 (if (and (eq system-type 'ms-dos) 3386 (if (and (eq system-type 'ms-dos)
3369 (not (msdos-long-file-names))) 3387 (not (msdos-long-file-names)))