From mboxrd@z Thu Jan 1 00:00:00 1970 Path: news.gmane.io!.POSTED.blaine.gmane.org!not-for-mail From: Eli Zaretskii Newsgroups: gmane.emacs.bugs Subject: bug#72019: [PATCH] Add project argument to project-kill-buffers Date: Wed, 10 Jul 2024 20:32:12 +0300 Message-ID: <86zfqpm9ur.fsf@gnu.org> References: <86ed81o5oc.fsf@gnu.org> <8634ohnwpz.fsf@gnu.org> Mime-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: 8bit Injection-Info: ciao.gmane.io; posting-host="blaine.gmane.org:116.202.254.214"; logging-data="12290"; mail-complaints-to="usenet@ciao.gmane.io" Cc: 72019@debbugs.gnu.org To: Spencer Baugh Original-X-From: bug-gnu-emacs-bounces+geb-bug-gnu-emacs=m.gmane-mx.org@gnu.org Wed Jul 10 19:33:25 2024 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 1sRbC0-0002z6-My for geb-bug-gnu-emacs@m.gmane-mx.org; Wed, 10 Jul 2024 19:33:24 +0200 Original-Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1sRbBm-0007vv-0k; Wed, 10 Jul 2024 13:33:10 -0400 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 1sRbBc-0007v9-KK for bug-gnu-emacs@gnu.org; Wed, 10 Jul 2024 13:33:04 -0400 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 1sRbBZ-0006kZ-B0 for bug-gnu-emacs@gnu.org; Wed, 10 Jul 2024 13:32:58 -0400 Original-Received: from Debian-debbugs by debbugs.gnu.org with local (Exim 4.84_2) (envelope-from ) id 1sRbBe-0003pZ-Hk for bug-gnu-emacs@gnu.org; Wed, 10 Jul 2024 13:33:02 -0400 X-Loop: help-debbugs@gnu.org Resent-From: Eli Zaretskii Original-Sender: "Debbugs-submit" Resent-CC: bug-gnu-emacs@gnu.org Resent-Date: Wed, 10 Jul 2024 17:33:02 +0000 Resent-Message-ID: Resent-Sender: help-debbugs@gnu.org X-GNU-PR-Message: followup 72019 X-GNU-PR-Package: emacs X-GNU-PR-Keywords: patch Original-Received: via spool by 72019-submit@debbugs.gnu.org id=B72019.172063275314692 (code B ref 72019); Wed, 10 Jul 2024 17:33:02 +0000 Original-Received: (at 72019) by debbugs.gnu.org; 10 Jul 2024 17:32:33 +0000 Original-Received: from localhost ([127.0.0.1]:57076 helo=debbugs.gnu.org) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1sRbBB-0003ot-7p for submit@debbugs.gnu.org; Wed, 10 Jul 2024 13:32:33 -0400 Original-Received: from eggs.gnu.org ([209.51.188.92]:40010) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1sRbB8-0003of-HN for 72019@debbugs.gnu.org; Wed, 10 Jul 2024 13:32:31 -0400 Original-Received: from fencepost.gnu.org ([2001:470:142:3::e]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1sRbAv-0006gr-0N; Wed, 10 Jul 2024 13:32:17 -0400 DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=gnu.org; s=fencepost-gnu-org; h=MIME-version:References:Subject:In-Reply-To:To:From: Date; bh=uoflJqjWSgQp6nRDdaEnQEZhEauPMc8SbL0bzFAHeMo=; b=q/s/pcQAWD4Do8f5uXI/ yk4F/hyoBe/sqaMxvI7w4HR1H5FVVIe0Ex5DBwKdzK6bdr/O3TpThgftroYSy8kGStYJ0UYM6Ik8m u05dtw68931skhewpoLpNVohb7Nz9DfYmAFe+/C1cbMq5g9tP18IWU/Iw3JWXZHBFnUJfT3O4sqcv JS+i+ZV6uFC3vnT+FLbswRPePjHEmyU8lIhuOH9bwBj6258FunLvpOiIBP+NoyfyDAY9LK09QNCNs chJ7tzNdVRszBbfOcXT2FMGG7eanzR0MRdy7NdcZEnAISzKZCEPrXcNHNaehKhMRaa/PMDumYxTPm n9XFeAAU9/OirA==; In-Reply-To: (message from Spencer Baugh on Wed, 10 Jul 2024 11:47:48 -0400) 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:288690 Archived-At: > From: Spencer Baugh > Cc: 72019@debbugs.gnu.org > Date: Wed, 10 Jul 2024 11:47:48 -0400 > > Eli Zaretskii writes: > > >> From: Spencer Baugh > >> Date: Wed, 10 Jul 2024 09:27:06 -0400 > >> Cc: 72019@debbugs.gnu.org > >> > >> On Wed, Jul 10, 2024, 7:19 AM Eli Zaretskii wrote: > >> > >> > From: Spencer Baugh > >> > Date: Tue, 09 Jul 2024 14:31:11 -0400 > >> > > >> > Previously, project-kill-buffers always called (project-current t). A > >> > Lisp program could change what project project-kill-buffers operated > >> > on by binding project-current-directory-override. However, in some > >> > edge cases (for example, if the project was deleted between looking it > >> > up and calling project-kill-buffers) this might fail to detect a > >> > project, and so (project-current t) would prompt the user. > >> > > >> > To avoid this, accept the project to kill buffers for as an argument. > >> > >> That sounds like sweeping some minor bug under the carpet, or worse. > >> Why is it a good idea to silently second-guess what is TRT in these > >> marginal cases? Up front, I'd say asking the user is a safer bet. > >> > >> Suppose if some Lisp program runs (project-current t) to select a project to operate on, then does some > >> things, then runs project-kill-buffers. The p-k-b call should never prompt for a project again - it's intended to > >> operate on the project that was already selected. If the project that was already selected has disappeared, an > >> error is better than a confusing second prompt which might lead to the user selecting another different > >> project and killing all the buffers in that project. If the Lisp program wants to catch that error, it can. > > > > In my book, prompting the user with the like of > > > > Project FOO disappeared, continue killing its buffers? > > > > is better than silently doing the (potentially) wrong thing. IOW, > > when something that isn't supposed to happen did happen, let the human > > figure out the mess. Relying on project.el to signal an error is > > better, but might not be the best idea, either, because the error > > message is likely to be confusing and/or non-specific. > > Yes, that's all true. However, this is a minor edge case, which so far > I've only observed happen once, and then it was only due to a user's bad > configuration. I'd rather just signal an error for now (by avoiding the > call to (project-current t)), which the current patch will do, since > that improves on the situation without requiring us to invest more > effort on something very rare. If we want to signal an error, let's signal an error, but with an explicit error message explaining the problem. Doing that by adding an argument sounds risky, since it doesn't target this specific situation, and so installing on the release branch is not necessarily justified. Are you okay with diagnosing this specific situation and signaling an error explicitly in the code?