GNU bug report logs -
#47850
28.0.50; find-file-noselect non-nil nowarn argument effect in read-only buffers
Previous Next
Reported by: dalanicolai <at> gmail.com
Date: Sat, 17 Apr 2021 21:01:03 UTC
Severity: normal
Tags: fixed
Found in version 28.0.50
Fixed in version 28.1
Done: Lars Ingebrigtsen <larsi <at> gnus.org>
Bug is archived. No further changes may be made.
Full log
Message #8 received at 47850 <at> debbugs.gnu.org (full text, mbox):
dalanicolai <at> gmail.com writes:
> Find-file-noselect buffer in non-existing directory with non-nil nowarn
> argument e.g:
>
> (switch-to-buffer (find-file-noselect "non-existing-dir/test.el" t))
>
> the buffer will open in read-only mode.
>
> Note that with a nowarn is nil argument, the buffer opens in an
> editable mode as expected.
>
> If it is not considered a technical bug then I would consider it a
> documentation bug.
I think it's a bug. It stems from this thing:
(defun after-find-file (&optional error warn noauto
_after-find-file-from-revert-buffer
nomodes)
[...]
(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
Already here the code is pretty dubious, because we've already skipped
all this if warn is non-nil... Anyway, here's the problem:
[...]
(t
(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")))))
We should do this action even if warn is non-nil, I think? Or more
generally, we should do all the actions in that cond, but not actually
issue the warning.
I've now done this on the trunk... this means that those file-exists-p
things are run in the nil WARN case, so the behaviour is slightly
different than before, and it's possible that this may lead to
regressions, I think, but it seems unlikely to me.
--
(domestic pets only, the antidote for overdose, milk.)
bloggy blog: http://lars.ingebrigtsen.no
This bug report was last modified 4 years and 19 days ago.
Previous Next
GNU bug tracking system
Copyright (C) 1999 Darren O. Benham,
1997,2003 nCipher Corporation Ltd,
1994-97 Ian Jackson.