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 13:01:09 -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> <83bkc2zx6k.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="32437"; 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 19:02:02 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 1r19Lt-00088K-03 for geb-bug-gnu-emacs@m.gmane-mx.org; Thu, 09 Nov 2023 19:02:01 +0100 Original-Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1r19LW-0004xT-8Z; Thu, 09 Nov 2023 13:01:38 -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 1r19LG-0004pV-ST for bug-gnu-emacs@gnu.org; Thu, 09 Nov 2023 13:01: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 1r19LG-0001Fi-KQ for bug-gnu-emacs@gnu.org; Thu, 09 Nov 2023 13:01:22 -0500 Original-Received: from Debian-debbugs by debbugs.gnu.org with local (Exim 4.84_2) (envelope-from ) id 1r19Lt-0003rM-Jw for bug-gnu-emacs@gnu.org; Thu, 09 Nov 2023 13:02:01 -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 18:02:01 +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.169955291914825 (code B ref 66993); Thu, 09 Nov 2023 18:02:01 +0000 Original-Received: (at 66993) by debbugs.gnu.org; 9 Nov 2023 18:01:59 +0000 Original-Received: from localhost ([127.0.0.1]:48690 helo=debbugs.gnu.org) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1r19Lr-0003r3-4Z for submit@debbugs.gnu.org; Thu, 09 Nov 2023 13:01:59 -0500 Original-Received: from mxout5.mail.janestreet.com ([64.215.233.18]:45663) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1r19Lm-0003ql-FI for 66993@debbugs.gnu.org; Thu, 09 Nov 2023 13:01:57 -0500 In-Reply-To: <83bkc2zx6k.fsf@gnu.org> (Eli Zaretskii's message of "Thu, 09 Nov 2023 18:52:19 +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:274065 Archived-At: Eli Zaretskii writes: >> From: Spencer Baugh >> Cc: dmitry@gutov.dev, 66993@debbugs.gnu.org >> Date: Thu, 09 Nov 2023 11:38:26 -0500 >> >> > 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)) > > Please show the result of this change on what Emacs prints in batch > mode when this error is signaled. Before: $ ./src/emacs -Q --batch --eval '(write-region "foo" nil "~/file")' /home/sbaugh/file locked by sbaugh@igm-qw... (pid 3781848): (s, q, p, ?)? Error: error ("Cannot resolve lock conflict in batch mode") mapbacktrace(#f(compiled-function (evald func args flags) #)) debug-early-backtrace() debug-early(error (error "Cannot resolve lock conflict in batch mode")) signal(error ("Cannot resolve lock conflict in batch mode")) error("Cannot resolve lock conflict in batch mode") ask-user-about-lock("/home/sbaugh/file" "sbaugh@igm-qws-u22796a (pid 3781848)") write-region("foo" nil "~/file") eval((write-region "foo" nil "~/file") t) command-line-1(("--eval" "(write-region \"foo\" nil \"~/file\")")) command-line() normal-top-level() Cannot resolve lock conflict in batch mode After: $ ./src/emacs -Q --batch --eval '(write-region "foo" nil "~/file")' /home/sbaugh/file locked by sbaugh@igm-qw... (pid 3781848): (s, q, p, ?)? Error: file-locked ("/home/sbaugh/file" "sbaugh@igm-qws-u22796a (pid 3781848)") mapbacktrace(#f(compiled-function (evald func args flags) #)) debug-early-backtrace() debug-early(error (file-locked "/home/sbaugh/file" "sbaugh@igm-qws-u22796a (pid 3781848)")) signal(file-locked ("/home/sbaugh/file" "sbaugh@igm-qws-u22796a (pid 3781848)")) ask-user-about-lock("/home/sbaugh/file" "sbaugh@igm-qws-u22796a (pid 3781848)") write-region("foo" nil "~/file") eval((write-region "foo" nil "~/file") t) command-line-1(("--eval" "(write-region \"foo\" nil \"~/file\")")) command-line() normal-top-level() /home/sbaugh/file: sbaugh@igm-qws-u22796a (pid 3781848)