diff options
| -rw-r--r-- | lisp/files.el | 34 |
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. |
| 301 | Each transform is a list (REGEXP REPLACEMENT): | 301 | Each transform is a list (REGEXP REPLACEMENT UNIQUIFY): |
| 302 | REGEXP is a regular expression to match against the file name. | 302 | REGEXP is a regular expression to match against the file name. |
| 303 | If it matches, `replace-match' is used to replace the | 303 | If it matches, `replace-match' is used to replace the |
| 304 | matching part with REPLACEMENT. | 304 | matching part with REPLACEMENT. |
| 305 | If the optional element UNIQUIFY is non-nil, the auto-save file name is | ||
| 306 | constructed by taking the directory part of the replaced file-name, | ||
| 307 | concatenated with the buffer file name with all directory separators | ||
| 308 | changed to `!' to prevent clashes. This will not work | ||
| 309 | correctly if your filesystem truncates the resulting name. | ||
| 310 | |||
| 305 | All the transforms in the list are tried, in the order they are listed. | 311 | All the transforms in the list are tried, in the order they are listed. |
| 306 | When one transform applies, its result is final; | 312 | When one transform applies, its result is final; |
| 307 | no further transforms are tried. | 313 | no further transforms are tried. |
| 308 | 314 | ||
| 309 | The default value is set up to put the auto-save file into the | 315 | The default value is set up to put the auto-save file into the |
| 310 | temporary directory (see the variable `temporary-file-directory') for | 316 | temporary directory (see the variable `temporary-file-directory') for |
| 311 | editing a remote file." | 317 | editing a remote file. |
| 318 | |||
| 319 | On MS-DOS filesystems without long names this variable is always | ||
| 320 | ignored." | ||
| 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))) |