(rmail-output): Check file can be read before trying to read part of it.
authorRichard M. Stallman <rms@gnu.org>
Sat, 19 Jun 1993 01:23:59 +0000 (01:23 +0000)
committerRichard M. Stallman <rms@gnu.org>
Sat, 19 Jun 1993 01:23:59 +0000 (01:23 +0000)
lisp/mail/rmailout.el

index fa6bf01..f97cb2d 100644 (file)
@@ -162,13 +162,14 @@ When called from lisp code, N may be omitted."
        ;; If we can do it, read a little of the file
        ;; to check whether it is an RMAIL file.
        ;; If it is, don't mess it up.
-       (insert-file-contents file-name nil 0 20)
-       (if (looking-at "BABYL OPTIONS:\n")
-           (error (save-excursion
-                    (set-buffer rmailbuf)
-                    (substitute-command-keys
-                     "Use \\[rmail-output-to-rmail-file] to output to Rmail file `%s'"))
-                  (file-name-nondirectory file-name)))
+       (and (file-readable-p file-name)
+            (progn (insert-file-contents file-name nil 0 20)
+                   (looking-at "BABYL OPTIONS:\n"))
+            (error (save-excursion
+                     (set-buffer rmailbuf)
+                     (substitute-command-keys
+                      "Use \\[rmail-output-to-rmail-file] to output to Rmail file `%s'"))
+                   (file-name-nondirectory file-name)))
        (erase-buffer)
        (insert-buffer-substring rmailbuf)
        (insert "\n")