]> git.eshelyaron.com Git - emacs.git/commitdiff
Fix inconsistent behaviour in find-file-noselect when using nowarn
authorLars Ingebrigtsen <larsi@gnus.org>
Tue, 4 May 2021 09:48:27 +0000 (11:48 +0200)
committerLars Ingebrigtsen <larsi@gnus.org>
Tue, 4 May 2021 09:48:27 +0000 (11:48 +0200)
* lisp/files.el (after-find-file): Behave the same in when
warning/not warning (bug#47850).  This fixes this test case:
(switch-to-buffer (find-file-noselect "non-existing-dir/test.el" t))
which would leave the buffer read-only.

lisp/files.el

index 2c5017a2fdcaeda6bddbd6ce3395fd27940dcc44..16ebe744b98303dd16ac2d7f032ad5806a3538c6 100644 (file)
@@ -2537,21 +2537,20 @@ unless NOMODES is non-nil."
     (let* (not-serious
           (msg
            (cond
-            ((not warn) nil)
             ((and error (file-exists-p buffer-file-name))
              (setq buffer-read-only t)
              "File exists, but cannot be read")
             ((and error (file-symlink-p buffer-file-name))
              "Symbolic link that points to nonexistent file")
             ((not buffer-read-only)
-             (if (and warn
-                      ;; No need to warn if buffer is auto-saved
-                      ;; under the name of the visited file.
-                      (not (and buffer-file-name
-                                auto-save-visited-file-name))
-                      (file-newer-than-file-p (or buffer-auto-save-file-name
-                                                  (make-auto-save-file-name))
-                                              buffer-file-name))
+             (if (and
+                   ;; No need to warn if buffer is auto-saved
+                  ;; under the name of the visited file.
+                  (not (and buffer-file-name
+                            auto-save-visited-file-name))
+                  (file-newer-than-file-p (or buffer-auto-save-file-name
+                                              (make-auto-save-file-name))
+                                          buffer-file-name))
                  (format "%s has auto save data; consider M-x recover-this-file"
                          (file-name-nondirectory buffer-file-name))
                (setq not-serious t)
@@ -2565,7 +2564,7 @@ unless NOMODES is non-nil."
              (setq buffer-read-only nil)
              (unless (file-directory-p default-directory)
                "Use M-x make-directory RET RET to create the directory and its parents")))))
-      (when msg
+      (when (and warn msg)
        (message "%s" msg)
        (or not-serious (sit-for 1 t))))
     (when (and auto-save-default (not noauto))