From: Lars Ingebrigtsen Date: Tue, 4 May 2021 09:48:27 +0000 (+0200) Subject: Fix inconsistent behaviour in find-file-noselect when using nowarn X-Git-Tag: emacs-28.0.90~2621 X-Git-Url: http://git.eshelyaron.com/gitweb/?a=commitdiff_plain;h=e634130607b844a0b428c826b205ede05edeedfc;p=emacs.git Fix inconsistent behaviour in find-file-noselect when using nowarn * 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. --- diff --git a/lisp/files.el b/lisp/files.el index 2c5017a2fdc..16ebe744b98 100644 --- a/lisp/files.el +++ b/lisp/files.el @@ -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))