From mboxrd@z Thu Jan 1 00:00:00 1970 Path: news.gmane.io!.POSTED.blaine.gmane.org!not-for-mail From: Spencer Baugh Newsgroups: gmane.emacs.bugs Subject: bug#66993: [PATCH] project.el: avoid asking user about project-list-file lock Date: Thu, 09 Nov 2023 11:38:26 -0500 Message-ID: References: <83sf5g1lko.fsf@gnu.org> <9d460f36-6035-da54-3abc-12171ac8977f@gutov.dev> <83jzqs1hhx.fsf@gnu.org> <57c079bf-e3a3-db45-c45a-ad6925335e2f@gutov.dev> <83il6c1ct3.fsf@gnu.org> <83fs1g19vn.fsf@gnu.org> <83bkc416q3.fsf@gnu.org> <835y2b1lnp.fsf@gnu.org> Mime-Version: 1.0 Content-Type: text/plain Injection-Info: ciao.gmane.io; posting-host="blaine.gmane.org:116.202.254.214"; logging-data="33649"; mail-complaints-to="usenet@ciao.gmane.io" User-Agent: Gnus/5.13 (Gnus v5.13) Cc: dmitry@gutov.dev, 66993@debbugs.gnu.org To: Eli Zaretskii Original-X-From: bug-gnu-emacs-bounces+geb-bug-gnu-emacs=m.gmane-mx.org@gnu.org Thu Nov 09 17:39:43 2023 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 1r184F-0008VF-CH for geb-bug-gnu-emacs@m.gmane-mx.org; Thu, 09 Nov 2023 17:39:43 +0100 Original-Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1r183x-0006ls-OD; Thu, 09 Nov 2023 11:39:25 -0500 Original-Received: from eggs.gnu.org ([2001:470:142:3::10]) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1r183v-0006lO-MQ for bug-gnu-emacs@gnu.org; Thu, 09 Nov 2023 11:39:23 -0500 Original-Received: from debbugs.gnu.org ([2001:470:142:5::43]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1r183v-0008Q6-EI for bug-gnu-emacs@gnu.org; Thu, 09 Nov 2023 11:39:23 -0500 Original-Received: from Debian-debbugs by debbugs.gnu.org with local (Exim 4.84_2) (envelope-from ) id 1r184Y-00050F-9q for bug-gnu-emacs@gnu.org; Thu, 09 Nov 2023 11:40:02 -0500 X-Loop: help-debbugs@gnu.org Resent-From: Spencer Baugh Original-Sender: "Debbugs-submit" Resent-CC: bug-gnu-emacs@gnu.org Resent-Date: Thu, 09 Nov 2023 16:40:02 +0000 Resent-Message-ID: Resent-Sender: help-debbugs@gnu.org X-GNU-PR-Message: followup 66993 X-GNU-PR-Package: emacs X-GNU-PR-Keywords: patch Original-Received: via spool by 66993-submit@debbugs.gnu.org id=B66993.169954795419169 (code B ref 66993); Thu, 09 Nov 2023 16:40:02 +0000 Original-Received: (at 66993) by debbugs.gnu.org; 9 Nov 2023 16:39:14 +0000 Original-Received: from localhost ([127.0.0.1]:48628 helo=debbugs.gnu.org) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1r183l-0004z7-Pr for submit@debbugs.gnu.org; Thu, 09 Nov 2023 11:39:14 -0500 Original-Received: from mxout5.mail.janestreet.com ([64.215.233.18]:34365) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1r183j-0004yr-5w for 66993@debbugs.gnu.org; Thu, 09 Nov 2023 11:39:12 -0500 In-Reply-To: <835y2b1lnp.fsf@gnu.org> (Eli Zaretskii's message of "Thu, 09 Nov 2023 08:32:58 +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-bounces+geb-bug-gnu-emacs=m.gmane-mx.org@gnu.org Xref: news.gmane.io gmane.emacs.bugs:274057 Archived-At: Eli Zaretskii writes: >> From: Spencer Baugh >> Cc: dmitry@gutov.dev, 66993@debbugs.gnu.org >> Date: Wed, 08 Nov 2023 15:43:53 -0500 >> >> Eli Zaretskii writes: >> >> >> (if noninteractive (error "Cannot resolve lock conflict in batch mode")) >> > >> > And that is not specific enough? >> >> Are you suggesting that we should condition-case and check the string >> inside the error is "Cannot resolve lock conflict in batch mode"? > > That's one way, yes. Another one is to use define-error to define a > new error type for this case. Instead of defining a new error type, how about just signaling file-locked instead? e.g. the following patch: diff --git a/lisp/userlock.el b/lisp/userlock.el index 61f061d3e54..e4d23c56249 100644 --- a/lisp/userlock.el +++ b/lisp/userlock.el @@ -67,7 +67,7 @@ ask-user-about-lock (message (substitute-command-keys "%s locked by %s: (\\`s', \\`q', \\`p', \\`?')? ") short-file short-opponent) - (if noninteractive (error "Cannot resolve lock conflict in batch mode")) + (if noninteractive (signal 'file-locked (list file opponent))) (let ((tem (let ((inhibit-quit t) (cursor-in-echo-area t)) (prog1 (downcase (read-char)) Including also a documentation update to explain that when noninteractive=t, a file lock conflict always signals file-locked instead of prompting the user. >> > And why the noninteractive=t case is relevant here, btw? >> >> Because we don't want to prompt the user, we just want to signal an >> error if there's a lock conflict. > > ??? Is project-current always used in a non-interactive context? I > don't think so. When some interactive program calls it, > noninteractive will be nil, and what userlock.el does in that case is > not what you describe. Right. > And if you are saying that some program binds noninteractive to a > non-nil value to avoid asking the file-locked question, then with the > error-catching as discussed above in place, that program won't need to > do that anymore, right? (Also see below for why this binding is > problematic in a more general sense.) Yes, that's what I'm saying. That's all correct.