Doc fix.
[bpt/emacs.git] / lisp / files.el
index 973f7bc..bd808dd 100644 (file)
@@ -535,10 +535,11 @@ colon-separated list of directories when resolving a relative directory name."
 
 (defun load-file (file)
   "Load the Lisp file named FILE."
-  (interactive "fLoad file: ")
-  (let ((completion-ignored-extensions
-        (delete ".elc" completion-ignored-extensions)))
-    (load (expand-file-name file) nil nil t)))
+  ;; This is a case where .elc makes a lot of sense.
+  (interactive (list (let ((completion-ignored-extensions
+                           (remove ".elc" completion-ignored-extensions)))
+                      (read-file-name "Load file: "))))
+  (load (expand-file-name file) nil nil t))
 
 (defun load-library (library)
   "Load the library named LIBRARY.
@@ -3014,7 +3015,7 @@ non-nil, it is called instead of rereading visited file contents."
                   (let ((coding-system-for-read
                          ;; Auto-saved file shoule be read without
                          ;; any code conversion.
-                         (if auto-save-p 'no-conversion
+                         (if auto-save-p 'emacs-mule-unix
                            coding-system-for-read)))
                     ;; Note that this preserves point in an intelligent way.
                     (insert-file-contents file-name (not auto-save-p)
@@ -3057,15 +3058,21 @@ non-nil, it is called instead of rereading visited file contents."
                   (if (file-symlink-p file)
                       (setq switches (concat switches "L")))
                   (set-buffer standard-output)
-                  (insert-directory file switches)
-                  (insert-directory file-name switches))))
+                  ;; Use insert-directory-safely, not insert-directory,
+                  ;; because these files might not exist.  In particular,
+                  ;; FILE might not exist if the auto-save file was for
+                  ;; a buffer that didn't visit a file, such as "*mail*".
+                  ;; The code in v20.x called `ls' directly, so we need
+                  ;; to emulate what `ls' did in that case.
+                  (insert-directory-safely file switches)
+                  (insert-directory-safely file-name switches))))
             (yes-or-no-p (format "Recover auto save file %s? " file-name)))
           (switch-to-buffer (find-file-noselect file t))
           (let ((buffer-read-only nil)
                 ;; Keep the current buffer-file-coding-system.
                 (coding-system buffer-file-coding-system)
                 ;; Auto-saved file shoule be read without any code conversion.
-                (coding-system-for-read 'no-conversion))
+                (coding-system-for-read 'emacs-mule-unix))
             (erase-buffer)
             (insert-file-contents file-name nil)
             (set-buffer-file-coding-system coding-system))
@@ -3619,6 +3626,17 @@ If WILDCARD, it also runs the shell specified by `shell-file-name'."
                      (setq available (buffer-substring (point) end))))
                  (insert " available " available))))))))))
 
+(defun insert-directory-safely (file switches
+                                    &optional wildcard full-directory-p)
+  "Insert directory listing for FILE, formatted according to SWITCHES.
+
+Like `insert-directory', but if FILE does not exist, it inserts a
+message to that effect instead of signaling an error."
+  (if (file-exists-p file)
+      (insert-directory file switches wildcard full-directory-p)
+    ;; Simulate the message printed by `ls'.
+    (insert (format "%s: No such file or directory\n" file))))
+
 (defvar kill-emacs-query-functions nil
   "Functions to call with no arguments to query about killing Emacs.
 If any of these functions returns nil, killing Emacs is cancelled.