unofficial mirror of bug-gnu-emacs@gnu.org 
 help / color / mirror / code / Atom feed
From: Lars Ingebrigtsen <larsi@gnus.org>
To: dalanicolai@gmail.com
Cc: 47850@debbugs.gnu.org
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	[thread overview]
Message-ID: <875yzyal0n.fsf@gnus.org> (raw)
In-Reply-To: <98cdf91016b56d8b9b885e705fbcf6fed626912e.camel@gmail.com> (dalanicolai@gmail.com's message of "Sat, 17 Apr 2021 23:00:33 +0200")

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





      reply	other threads:[~2021-05-04  9:47 UTC|newest]

Thread overview: 2+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2021-04-17 21:00 bug#47850: 28.0.50; find-file-noselect non-nil nowarn argument effect in read-only buffers dalanicolai
2021-05-04  9:47 ` Lars Ingebrigtsen [this message]

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

  List information: https://www.gnu.org/software/emacs/

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=875yzyal0n.fsf@gnus.org \
    --to=larsi@gnus.org \
    --cc=47850@debbugs.gnu.org \
    --cc=dalanicolai@gmail.com \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
Code repositories for project(s) associated with this public inbox

	https://git.savannah.gnu.org/cgit/emacs.git

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).