[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
bug#47850: 28.0.50; find-file-noselect non-nil nowarn argument effect in
From: |
Lars Ingebrigtsen |
Subject: |
bug#47850: 28.0.50; find-file-noselect non-nil nowarn argument effect in read-only buffers |
Date: |
Tue, 04 May 2021 11:47:04 +0200 |
User-agent: |
Gnus/5.13 (Gnus v5.13) Emacs/28.0.50 (gnu/linux) |
dalanicolai@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
[Prev in Thread] |
Current Thread |
[Next in Thread] |
- bug#47850: 28.0.50; find-file-noselect non-nil nowarn argument effect in read-only buffers,
Lars Ingebrigtsen <=