]> code.delx.au - gnu-emacs/blobdiff - lisp/files.el
(substitute-key-definition): Add comment describing
[gnu-emacs] / lisp / files.el
index f3af7b9e511d96172cc5b0c382e1680513351f40..daf1341357d28a4c5e39e8bba75f473839f6b608 100644 (file)
@@ -134,17 +134,19 @@ This variable is relevant only if `backup-by-copying' and
   :group 'backup)
 
 (defvar backup-enable-predicate
-  '(lambda (name)
-     (and (let ((comp (compare-strings temporary-file-directory 0 nil
-                                      name 0 nil)))
-           (and (not (eq comp t))
-                (< comp -1)))
-         (if small-temporary-file-directory
-             (let ((comp (compare-strings small-temporary-file-directory 0 nil
-                                          name 0 nil)))
-               (and (not (eq comp t))
-                    (< comp -1)))
-           t)))
+  (lambda (name)
+    (not (or (let ((comp (compare-strings temporary-file-directory 0 nil
+                                     name 0 nil)))
+              ;; Directory is under temporary-file-directory.
+              (and (not (eq comp t))
+                   (< comp -1)))
+            (if small-temporary-file-directory
+                (let ((comp (compare-strings small-temporary-file-directory
+                                             0 nil
+                                             name 0 nil)))
+                  ;; Directory is under small-temporary-file-directory.
+                  (and (not (eq comp t))
+                       (< comp -1)))))))
   "Predicate that looks at a file name and decides whether to make backups.
 Called with an absolute file name as argument, it returns t to enable backup.
 The default version checks for files in `temporary-file-directory' or
@@ -277,6 +279,23 @@ Normally auto-save files are written under other names."
   :type 'boolean
   :group 'auto-save)
 
+(defcustom auto-save-file-name-transforms
+  '(("\\`/[^/]*:\\(.+/\\)*\\(.*\\)" "/tmp/\\2"))
+  "*Transforms to apply to buffer file name before making auto-save file name.
+Each transform is a list (REGEXP REPLACEMENT):
+REGEXP is a regular expression to match against the file name.
+If it matches, `replace-match' is used to replace the
+matching part with REPLACEMENT.
+All the transforms in the list are tried, in the order they are listed.
+When one transform applies, its result is final;
+no further transforms are tried.
+
+The default value is set up to put the auto-save file into `/tmp'
+for editing a remote file."
+  :group 'auto-save
+  :type '(repeat (list (string :tag "Regexp") (string :tag "Replacement")))
+  :version "21.1")
+
 (defcustom save-abbrevs nil
   "*Non-nil means save word abbrevs too when files are saved.
 Loading an abbrev file sets this to t."
@@ -1415,7 +1434,9 @@ in that case, this function acts as if `enable-local-variables' were t."
     ("\\.sm2$" . snmpv2-mode)
     ("\\.\\(diffs?\\|patch\\|rej\\)\\'" . diff-mode)
     ("\\.[eE]?[pP][sS]$" . ps-mode)
-    ("configure\\.in\\'" . autoconf-mode))
+    ("configure\\.in\\'" . autoconf-mode)
+    ("BROWSE\\'" . ebrowse-tree-mode)
+    ("\\.ebrowse\\'" . ebrowse-tree-mode))
   "\
 Alist of filename patterns vs corresponding major mode functions.
 Each element looks like (REGEXP . FUNCTION) or (REGEXP FUNCTION NON-NIL).
@@ -2586,7 +2607,9 @@ After saving the buffer, this function runs `after-save-hook'."
                              (if (and (eq system-type 'ms-dos)
                                       (not (msdos-long-file-names)))
                                  "%s#%d.tm#" ; MSDOS limits files to 8+3
-                               "%s#tmp#%d")
+                               (if (memq system-type '(vax-vms axp-vms))
+                                   "%s$tmp$%d"
+                                 "%s#tmp#%d"))
                              dir i))
              (setq nogood (file-exists-p tempname))
              (setq i (1+ i)))
@@ -2988,6 +3011,9 @@ Then you'll be asked about a number of files to recover."
   (interactive)
   (if (null auto-save-list-file-prefix)
       (error "You set `auto-save-list-file-prefix' to disable making session files"))
+  (let ((dir (file-name-directory auto-save-list-file-prefix)))
+    (unless (file-directory-p dir)
+      (make-directory dir t)))
   (let ((ls-lisp-support-shell-wildcards t))
     (dired (concat auto-save-list-file-prefix "*")
           (concat dired-listing-switches "t")))
@@ -3137,17 +3163,29 @@ Does not consider `auto-save-visited-file-name' as that variable is checked
 before calling this function.  You can redefine this for customization.
 See also `auto-save-file-name-p'."
   (if buffer-file-name
-      (if (and (eq system-type 'ms-dos)
-              (not (msdos-long-file-names)))
-         (let ((fn (file-name-nondirectory buffer-file-name)))
-           (string-match "\\`\\([^.]+\\)\\(\\.\\(..?\\)?.?\\|\\)\\'" fn)
-           (concat (file-name-directory buffer-file-name)
-                   "#" (match-string 1 fn)
-                   "." (match-string 3 fn) "#"))
-       (concat (file-name-directory buffer-file-name)
-               "#"
-               (file-name-nondirectory buffer-file-name)
-               "#"))
+      (let ((list auto-save-file-name-transforms)
+           (filename buffer-file-name)
+           result)
+       ;; Apply user-specified translations
+       ;; to the file name.
+       (while (and list (not result))
+         (if (string-match (car (car list)) filename)
+             (setq result (replace-match (cadr (car list)) t nil
+                                         filename)))
+         (setq list (cdr list)))
+       (if result (setq filename result))
+
+       (if (and (eq system-type 'ms-dos)
+                (not (msdos-long-file-names)))
+           (let ((fn (file-name-nondirectory buffer-file-name)))
+             (string-match "\\`\\([^.]+\\)\\(\\.\\(..?\\)?.?\\|\\)\\'" fn)
+             (concat (file-name-directory buffer-file-name)
+                     "#" (match-string 1 fn) 
+                     "." (match-string 3 fn) "#"))
+         (concat (file-name-directory filename)
+                 "#"
+                 (file-name-nondirectory filename)
+                 "#")))
 
     ;; Deal with buffers that don't have any associated files.  (Mail
     ;; mode tends to create a good number of these.)