Commit e6341306 authored by Lars Ingebrigtsen's avatar Lars Ingebrigtsen
Browse files

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.
parent ed42afd4
Pipeline #10627 failed with stages
in 10 minutes and 24 seconds
......@@ -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))
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment