(show_help_echo): Update prototype of show_help_echo.
[bpt/emacs.git] / lisp / files.el
index b56d15a..570a31b 100644 (file)
@@ -133,24 +133,26 @@ This variable is relevant only if `backup-by-copying' and
   :type '(choice (const nil) integer)
   :group 'backup)
 
-(defvar backup-enable-predicate
-  (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)))))))
+(defun normal-backup-enable-predicate (name)
+  "Default `backup-enable-predicate' function.
+Checks for files in `temporary-file-directory' or
+`small-temporary-file-directory'."
+  (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)))))))
+
+(defvar backup-enable-predicate 'normal-backup-enable-predicate
   "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
-`small-temporary-file-directory'.")
+Called with an absolute file name as argument, it returns t to enable backup.")
 
 (defcustom buffer-offer-save nil
   "*Non-nil in a buffer means always offer to save buffer on exit.
@@ -458,8 +460,9 @@ Runs the usual ange-ftp hook, but only for completion operations."
 (defun convert-standard-filename (filename)
   "Convert a standard file's name to something suitable for the current OS.
 This function's standard definition is trivial; it just returns the argument.
-However, on some systems, the function is redefined
-with a definition that really does change some file names."
+However, on some systems, the function is redefined with a definition
+that really does change some file names to canonicalize certain
+patterns and to guarantee valid names."
   filename)
 \f
 (defun pwd ()
@@ -2294,6 +2297,9 @@ doesn't exist, it is created."
              ;; and replace the leading "x:" with "/drive_x".
              (or (file-name-absolute-p file)
                  (setq file (expand-file-name file))) ; make defaults explicit
+             ;; Replace any invalid file-name characters (for the
+             ;; case of backing up remote files).
+             (setq file (convert-standard-filename file))
              (setq dir-sep-string (char-to-string directory-sep-char))
              (or (eq directory-sep-char ?/)
                  (subst-char-in-string ?/ ?\\ file))
@@ -2492,8 +2498,11 @@ the last real save, but optional arg FORCE non-nil means delete anyway."
 (defvar auto-save-hook nil
   "Normal hook run just before auto-saving.")
 
-(defvar after-save-hook nil
-  "Normal hook that is run after a buffer is saved to its file.")
+(defcustom after-save-hook nil
+  "Normal hook that is run after a buffer is saved to its file."
+  :options '(executable-make-buffer-file-executable-if-script-p)
+  :type 'hook
+  :group 'files)
 
 (defvar save-buffer-coding-system nil
   "If non-nil, use this coding system for saving the buffer.
@@ -2667,7 +2676,7 @@ After saving the buffer, this function runs `after-save-hook'."
        (cond ((and tempsetmodes (not setmodes))
               ;; Change the mode back, after writing.
               (setq setmodes (file-modes buffer-file-name))
-              (set-file-modes buffer-file-name 511)))
+              (set-file-modes buffer-file-name (logior setmodes 128))))
        (write-region (point-min) (point-max)
                      buffer-file-name nil t buffer-file-truename)))
     setmodes))