From mboxrd@z Thu Jan 1 00:00:00 1970 Path: news.gmane.io!.POSTED.blaine.gmane.org!not-for-mail From: Lars Ingebrigtsen Newsgroups: gmane.emacs.bugs 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 Message-ID: <875yzyal0n.fsf@gnus.org> References: <98cdf91016b56d8b9b885e705fbcf6fed626912e.camel@gmail.com> Mime-Version: 1.0 Content-Type: text/plain Injection-Info: ciao.gmane.io; posting-host="blaine.gmane.org:116.202.254.214"; logging-data="35731"; mail-complaints-to="usenet@ciao.gmane.io" User-Agent: Gnus/5.13 (Gnus v5.13) Emacs/28.0.50 (gnu/linux) Cc: 47850@debbugs.gnu.org To: dalanicolai@gmail.com Original-X-From: bug-gnu-emacs-bounces+geb-bug-gnu-emacs=m.gmane-mx.org@gnu.org Tue May 04 11:51:16 2021 Return-path: Envelope-to: geb-bug-gnu-emacs@m.gmane-mx.org Original-Received: from lists.gnu.org ([209.51.188.17]) by ciao.gmane.io with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.92) (envelope-from ) id 1ldrhz-0009AK-GI for geb-bug-gnu-emacs@m.gmane-mx.org; Tue, 04 May 2021 11:51:15 +0200 Original-Received: from localhost ([::1]:47996 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1ldrhy-0004Ds-J3 for geb-bug-gnu-emacs@m.gmane-mx.org; Tue, 04 May 2021 05:51:14 -0400 Original-Received: from eggs.gnu.org ([2001:470:142:3::10]:51708) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1ldres-00012X-OP for bug-gnu-emacs@gnu.org; Tue, 04 May 2021 05:48:02 -0400 Original-Received: from debbugs.gnu.org ([209.51.188.43]:40612) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1ldres-0002tz-GB for bug-gnu-emacs@gnu.org; Tue, 04 May 2021 05:48:02 -0400 Original-Received: from Debian-debbugs by debbugs.gnu.org with local (Exim 4.84_2) (envelope-from ) id 1ldres-0003Bi-Ei for bug-gnu-emacs@gnu.org; Tue, 04 May 2021 05:48:02 -0400 X-Loop: help-debbugs@gnu.org Resent-From: Lars Ingebrigtsen Original-Sender: "Debbugs-submit" Resent-CC: bug-gnu-emacs@gnu.org Resent-Date: Tue, 04 May 2021 09:48:02 +0000 Resent-Message-ID: Resent-Sender: help-debbugs@gnu.org X-GNU-PR-Message: followup 47850 X-GNU-PR-Package: emacs Original-Received: via spool by 47850-submit@debbugs.gnu.org id=B47850.162012163711128 (code B ref 47850); Tue, 04 May 2021 09:48:02 +0000 Original-Received: (at 47850) by debbugs.gnu.org; 4 May 2021 09:47:17 +0000 Original-Received: from localhost ([127.0.0.1]:52155 helo=debbugs.gnu.org) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1ldre9-0002tA-2P for submit@debbugs.gnu.org; Tue, 04 May 2021 05:47:17 -0400 Original-Received: from quimby.gnus.org ([95.216.78.240]:51690) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1ldre7-0002oC-IL for 47850@debbugs.gnu.org; Tue, 04 May 2021 05:47:16 -0400 DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=gnus.org; s=20200322; h=Content-Type:MIME-Version:Message-ID:In-Reply-To:Date: References:Subject:Cc:To:From:Sender:Reply-To:Content-Transfer-Encoding: Content-ID:Content-Description:Resent-Date:Resent-From:Resent-Sender: Resent-To:Resent-Cc:Resent-Message-ID:List-Id:List-Help:List-Unsubscribe: List-Subscribe:List-Post:List-Owner:List-Archive; bh=/UstDGKkqVt50jBPbiN5bIwEiI10MDIGMoEr2HZdUPE=; b=e7MzCaczt7Zj7k1oaMXP3h9SBj Z8aXADhJz9bEyYJVMsD0Hf+6nQ5Xg0BcRH9MGriLrfCdLNgIgvu7ISSUHnRhRkFmItJwZts5Fitxs YBhZU+WxgUgsIwYwzU3c4OJdkn6tlyfm5ZVBV4U8Rs/GUXj2Qh83JNHxeLu2E2D4+Ecw=; Original-Received: from cm-84.212.220.105.getinternet.no ([84.212.220.105] helo=xo) by quimby.gnus.org with esmtpsa (TLS1.3:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.92) (envelope-from ) id 1ldrdy-0000jD-GG; Tue, 04 May 2021 11:47:08 +0200 X-Now-Playing: Zola Jesus's _New Amsterdam_: "Orthodox" In-Reply-To: <98cdf91016b56d8b9b885e705fbcf6fed626912e.camel@gmail.com> (dalanicolai@gmail.com's message of "Sat, 17 Apr 2021 23:00:33 +0200") X-BeenThere: debbugs-submit@debbugs.gnu.org X-Mailman-Version: 2.1.18 Precedence: list X-BeenThere: bug-gnu-emacs@gnu.org List-Id: "Bug reports for GNU Emacs, the Swiss army knife of text editors" List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: bug-gnu-emacs-bounces+geb-bug-gnu-emacs=m.gmane-mx.org@gnu.org Original-Sender: "bug-gnu-emacs" Xref: news.gmane.io gmane.emacs.bugs:205589 Archived-At: 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