Mercurial > emacs
comparison lisp/files.el @ 28758:8ab223e4ce03
(make-auto-save-file-name):
Apply auto-save-file-name-transforms to visited file name
before generating auto save file name.
(auto-save-file-name-transforms): New variable.
(backup-enable-predicate):
Correctly test for a file under a temporary directory.
author | Gerd Moellmann <gerd@gnu.org> |
---|---|
date | Sat, 29 Apr 2000 13:17:48 +0000 |
parents | 6d94533af241 |
children | b4439d3505f3 |
comparison
equal
deleted
inserted
replaced
28757:2fb6dbfe29f6 | 28758:8ab223e4ce03 |
---|---|
133 :type '(choice (const nil) integer) | 133 :type '(choice (const nil) integer) |
134 :group 'backup) | 134 :group 'backup) |
135 | 135 |
136 (defvar backup-enable-predicate | 136 (defvar backup-enable-predicate |
137 (lambda (name) | 137 (lambda (name) |
138 (and (let ((comp (compare-strings temporary-file-directory 0 nil | 138 (not (or (let ((comp (compare-strings temporary-file-directory 0 nil |
139 name 0 nil))) | 139 name 0 nil))) |
140 (and (not (eq comp t)) | 140 ;; Directory is under temporary-file-directory. |
141 (< comp -1))) | 141 (and (not (eq comp t)) |
142 (if small-temporary-file-directory | 142 (< comp -1))) |
143 (let ((comp (compare-strings small-temporary-file-directory 0 nil | 143 (if small-temporary-file-directory |
144 name 0 nil))) | 144 (let ((comp (compare-strings small-temporary-file-directory |
145 (and (not (eq comp t)) | 145 0 nil |
146 (< comp -1))) | 146 name 0 nil))) |
147 t))) | 147 ;; Directory is under small-temporary-file-directory. |
148 (and (not (eq comp t)) | |
149 (< comp -1))))))) | |
148 "Predicate that looks at a file name and decides whether to make backups. | 150 "Predicate that looks at a file name and decides whether to make backups. |
149 Called with an absolute file name as argument, it returns t to enable backup. | 151 Called with an absolute file name as argument, it returns t to enable backup. |
150 The default version checks for files in `temporary-file-directory' or | 152 The default version checks for files in `temporary-file-directory' or |
151 `small-temporary-file-directory'.") | 153 `small-temporary-file-directory'.") |
152 | 154 |
274 (defcustom auto-save-visited-file-name nil | 276 (defcustom auto-save-visited-file-name nil |
275 "*Non-nil says auto-save a buffer in the file it is visiting, when practical. | 277 "*Non-nil says auto-save a buffer in the file it is visiting, when practical. |
276 Normally auto-save files are written under other names." | 278 Normally auto-save files are written under other names." |
277 :type 'boolean | 279 :type 'boolean |
278 :group 'auto-save) | 280 :group 'auto-save) |
281 | |
282 (defcustom auto-save-file-name-transforms | |
283 '(("\\`/[^/]*:\\(.+/\\)*\\(.*\\)" "/tmp/\\2")) | |
284 "*Transforms to apply to buffer file name before making auto-save file name. | |
285 Each transform is a list (REGEXP REPLACEMENT): | |
286 REGEXP is a regular expression to match against the file name. | |
287 If it matches, `replace-match' is used to replace the | |
288 matching part with REPLACEMENT. | |
289 All the transforms in the list are tried, in the order they are listed. | |
290 When one transform applies, its result is final; | |
291 no further transforms are tried. | |
292 | |
293 The default value is set up to put the auto-save file into `/tmp' | |
294 for editing a remote file." | |
295 :group 'auto-save | |
296 :type '(repeat (list (string :tag "Regexp") (string :tag "Replacement"))) | |
297 :version "21.1") | |
279 | 298 |
280 (defcustom save-abbrevs nil | 299 (defcustom save-abbrevs nil |
281 "*Non-nil means save word abbrevs too when files are saved. | 300 "*Non-nil means save word abbrevs too when files are saved. |
282 Loading an abbrev file sets this to t." | 301 Loading an abbrev file sets this to t." |
283 :type 'boolean | 302 :type 'boolean |
3139 "Return file name to use for auto-saves of current buffer. | 3158 "Return file name to use for auto-saves of current buffer. |
3140 Does not consider `auto-save-visited-file-name' as that variable is checked | 3159 Does not consider `auto-save-visited-file-name' as that variable is checked |
3141 before calling this function. You can redefine this for customization. | 3160 before calling this function. You can redefine this for customization. |
3142 See also `auto-save-file-name-p'." | 3161 See also `auto-save-file-name-p'." |
3143 (if buffer-file-name | 3162 (if buffer-file-name |
3144 (if (and (eq system-type 'ms-dos) | 3163 (let ((list auto-save-file-name-transforms) |
3145 (not (msdos-long-file-names))) | 3164 (filename buffer-file-name) |
3146 (let ((fn (file-name-nondirectory buffer-file-name))) | 3165 result) |
3147 (string-match "\\`\\([^.]+\\)\\(\\.\\(..?\\)?.?\\|\\)\\'" fn) | 3166 ;; Apply user-specified translations |
3148 (concat (file-name-directory buffer-file-name) | 3167 ;; to the file name. |
3149 "#" (match-string 1 fn) | 3168 (while (and list (not result)) |
3150 "." (match-string 3 fn) "#")) | 3169 (if (string-match (car (car list)) filename) |
3151 (concat (file-name-directory buffer-file-name) | 3170 (setq result (replace-match (cadr (car list)) t nil |
3152 "#" | 3171 filename))) |
3153 (file-name-nondirectory buffer-file-name) | 3172 (setq list (cdr list))) |
3154 "#")) | 3173 (if result (setq filename result)) |
3174 | |
3175 (if (and (eq system-type 'ms-dos) | |
3176 (not (msdos-long-file-names))) | |
3177 (let ((fn (file-name-nondirectory buffer-file-name))) | |
3178 (string-match "\\`\\([^.]+\\)\\(\\.\\(..?\\)?.?\\|\\)\\'" fn) | |
3179 (concat (file-name-directory buffer-file-name) | |
3180 "#" (match-string 1 fn) | |
3181 "." (match-string 3 fn) "#")) | |
3182 (concat (file-name-directory filename) | |
3183 "#" | |
3184 (file-name-nondirectory filename) | |
3185 "#"))) | |
3155 | 3186 |
3156 ;; Deal with buffers that don't have any associated files. (Mail | 3187 ;; Deal with buffers that don't have any associated files. (Mail |
3157 ;; mode tends to create a good number of these.) | 3188 ;; mode tends to create a good number of these.) |
3158 | 3189 |
3159 (let ((buffer-name (buffer-name)) | 3190 (let ((buffer-name (buffer-name)) |