From mboxrd@z Thu Jan 1 00:00:00 1970 Path: news.gmane.io!.POSTED.blaine.gmane.org!not-for-mail From: Dmitry Gutov Newsgroups: gmane.emacs.bugs Subject: bug#58839: [Patch] Re: bug#58839: 29.0.50; project-kill-buffer fails when Eglot is running Date: Mon, 31 Oct 2022 19:24:02 +0200 Message-ID: <787a4362-7ff5-7dbb-9118-16e4bee5f328@yandex.ru> References: <87sfj8umwb.fsf@posteo.net> <87edur3lil.fsf@posteo.net> <87a65f3j40.fsf@posteo.net> <213f3549-de4e-25a7-5e27-d13893e557bc@yandex.ru> <87zgdfwkle.fsf@gmail.com> <8e31a89d-e35e-6dd0-a8e3-f0b9684c8bfa@yandex.ru> <87v8o3wgq1.fsf@gmail.com> <87ilk2x1si.fsf@gmail.com> <871qqq7l9p.fsf@posteo.net> <87eduqwekz.fsf@gmail.com> <87wn8invbx.fsf@posteo.net> <877d0iw8iq.fsf@gmail.com> <837d0hhlke.fsf@gnu.org> <46ff0065-5645-ef1e-2621-242fb6a73f98@yandex.ru> <87v8o0uxn5.fsf@gmail.com> Mime-Version: 1.0 Content-Type: text/plain; charset=UTF-8; format=flowed Content-Transfer-Encoding: 8bit Injection-Info: ciao.gmane.io; posting-host="blaine.gmane.org:116.202.254.214"; logging-data="21173"; mail-complaints-to="usenet@ciao.gmane.io" User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:102.0) Gecko/20100101 Thunderbird/102.2.2 Cc: Eli Zaretskii , 58839@debbugs.gnu.org, manuel.uberti@inventati.org, philipk@posteo.net To: =?UTF-8?Q?Jo=C3=A3o_?= =?UTF-8?Q?T=C3=A1vora?= Original-X-From: bug-gnu-emacs-bounces+geb-bug-gnu-emacs=m.gmane-mx.org+geb-bug-gnu-emacs=m.gmane-mx.org@gnu.org Mon Oct 31 18:25:43 2022 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 1opYXe-0005ML-Re for geb-bug-gnu-emacs@m.gmane-mx.org; Mon, 31 Oct 2022 18:25:42 +0100 Original-Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1opYXB-0008KP-5t; Mon, 31 Oct 2022 13:25:13 -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 1opYX2-0008Hg-CD for bug-gnu-emacs@gnu.org; Mon, 31 Oct 2022 13:25:05 -0400 Original-Received: from debbugs.gnu.org ([209.51.188.43]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1opYX0-0001Zj-Hr for bug-gnu-emacs@gnu.org; Mon, 31 Oct 2022 13:25:04 -0400 Original-Received: from Debian-debbugs by debbugs.gnu.org with local (Exim 4.84_2) (envelope-from ) id 1opYWz-00046W-Vb for bug-gnu-emacs@gnu.org; Mon, 31 Oct 2022 13:25:01 -0400 X-Loop: help-debbugs@gnu.org Resent-From: Dmitry Gutov Original-Sender: "Debbugs-submit" Resent-CC: bug-gnu-emacs@gnu.org Resent-Date: Mon, 31 Oct 2022 17:25:01 +0000 Resent-Message-ID: Resent-Sender: help-debbugs@gnu.org X-GNU-PR-Message: followup 58839 X-GNU-PR-Package: emacs Original-Received: via spool by 58839-submit@debbugs.gnu.org id=B58839.166723705415716 (code B ref 58839); Mon, 31 Oct 2022 17:25:01 +0000 Original-Received: (at 58839) by debbugs.gnu.org; 31 Oct 2022 17:24:14 +0000 Original-Received: from localhost ([127.0.0.1]:41668 helo=debbugs.gnu.org) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1opYWD-00045Q-Mk for submit@debbugs.gnu.org; Mon, 31 Oct 2022 13:24:14 -0400 Original-Received: from mail-wm1-f48.google.com ([209.85.128.48]:44554) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1opYWB-00045C-EO for 58839@debbugs.gnu.org; Mon, 31 Oct 2022 13:24:11 -0400 Original-Received: by mail-wm1-f48.google.com with SMTP id bg9-20020a05600c3c8900b003bf249616b0so8451468wmb.3 for <58839@debbugs.gnu.org>; Mon, 31 Oct 2022 10:24:11 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20210112; h=content-transfer-encoding:in-reply-to:from:references:cc:to :content-language:subject:user-agent:mime-version:date:message-id :sender:from:to:cc:subject:date:message-id:reply-to; bh=Ta2WQZhnjG0Uso3my7ceKcuo6U8JLjjVMTlWcFbr45g=; b=m+it+D5cDrtyrhvPZ/ekjiRLo2G3f+/mzzvSNP3g41LJabyUH5zR+49leZo1RgMO78 6QLXBVb4NW0FwWkXhTnGD3BiKK0ykKx954hp3TXDczOaoEJ5/pA28zkUdAQCuezdKXRz 2YKTM3Nww93VxCYRhxx/vhiO2CA3jfcXFt43ENuwLKRxhCU50R5HzvjfOH8fb5V5djdj nUV0h34YccG8eSI3SUZKE9hsnHmZ3JJrEnV4iywNQ5XGDezQ+OP0ZVyEPb3UydQUVF4S IDZfcIE/VNcRnbxiLNX4iijqMQaqbDuslqiRnUiP0HTuNbO+WLUQb+Tq6OCp6Ppp+f33 ya3g== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=content-transfer-encoding:in-reply-to:from:references:cc:to :content-language:subject:user-agent:mime-version:date:message-id :sender:x-gm-message-state:from:to:cc:subject:date:message-id :reply-to; bh=Ta2WQZhnjG0Uso3my7ceKcuo6U8JLjjVMTlWcFbr45g=; b=ndj+7gAaxITYRcmGuuE92C3UXvTdZCGqpOUaGU4gbbK5WUjcarffR3qvgFUxF6z5dV i1UqX1NDsTilHdLYv0Su8btaJXYvGMPUp1JwAlTK6qLfXhJ9bQyExHff8MAXCaNJzZo+ 0SJbCEw1hmSAYbLB/wNmVacg3QGGbCwtXzucOYaZCq2rivl0DIJZJgudfaLG6xSu3pzV UUx94p4k3fp66Dj9qERBsp7++BtVS4ZCYiukJmmf4iDYyXacysa6mQ2UqGN/ZIxwDKF3 vZOtwmfNKrvHwNzeVBrzqwHSStXON52BXe7FoC4ely/bbuKAl4q+NeJ44UHQk5eI2Kjl WIWg== X-Gm-Message-State: ACrzQf3K9yLm3ITWHqrzENsm6LUIp9HjtAzvanAElcc9sWuTmLHEeFxR WjfM5X0C9BDuMCNlfWzNAM8= X-Google-Smtp-Source: AMsMyM7swsttZIPLfpBG/DqT5CcHxjKWCeWcPoB9/C3eflvtYmMXcycCfm6a6Qwul9oSyS6mcXlvKw== X-Received: by 2002:a1c:5454:0:b0:3cf:7521:3543 with SMTP id p20-20020a1c5454000000b003cf75213543mr2713287wmi.172.1667237045157; Mon, 31 Oct 2022 10:24:05 -0700 (PDT) Original-Received: from [192.168.0.6] ([46.251.119.176]) by smtp.googlemail.com with ESMTPSA id y10-20020a5d620a000000b0023657e1b97esm7744171wru.11.2022.10.31.10.24.04 (version=TLS1_3 cipher=TLS_AES_128_GCM_SHA256 bits=128/128); Mon, 31 Oct 2022 10:24:05 -0700 (PDT) Content-Language: en-US In-Reply-To: <87v8o0uxn5.fsf@gmail.com> 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: , Original-Sender: "bug-gnu-emacs" Errors-To: bug-gnu-emacs-bounces+geb-bug-gnu-emacs=m.gmane-mx.org+geb-bug-gnu-emacs=m.gmane-mx.org@gnu.org Xref: news.gmane.io gmane.emacs.bugs:246705 Archived-At: On 31.10.2022 11:53, João Távora wrote: > Dmitry Gutov writes: > >> Anyway, if we do decide to flip the switch, it should be through >> project-kill-buffer-conditions, so the user can make a different >> choice through customization. > > project-kill-buffer-conditions doesn't work, I've tried it, it has this > fundamental-mode thing there that makes it impossible. Supposedly it is > there to serve some purpose that no-one seems to be able to find a > argumentative basis for. What have you tried? This should take care of the specific complaint about unknown "invisible" buffers: diff --git a/lisp/progmodes/project.el b/lisp/progmodes/project.el index ac278edd40..1e7573c740 100644 --- a/lisp/progmodes/project.el +++ b/lisp/progmodes/project.el @@ -1223,7 +1223,9 @@ project-display-buffer-other-frame (defcustom project-kill-buffer-conditions '(buffer-file-name ; All file-visiting buffers are included. ;; Most of the temp buffers in the background: - (major-mode . fundamental-mode) + (and + (major-mode . fundamental-mode) + (not "\\` ")) ;; non-text buffer such as xref, occur, vc, log, ... (and (derived-mode . special-mode) (not (major-mode . help-mode))) > It's quite clear that _some_ non-file-visiting buffers can be considered > as belonging to a project's working set. But it's very very easy to > come up with many that cannot be considered so. > > Because "killing buffers" is a destructive operation, being greedy here > is a really bad design decision, as it catches an arbitrary number of > unsuspecting extensions off-guard, which have been using earmuffed > buffers for many years. > > All in all, it's like you're making a gun that only backfires 5% of the > time. Yours is the first instance so far. > In the little time I've used this feature since the start of this > discussion I have discovered it backfires no small number of occasions: > Eglot, CIDER, *scratch*, *ielm*, *sly-scratch*, *Completions*,... Heck > even *ibuffer* itself is targeted by this. Of course it is targeted: we want ibuffer buffers to be killed just as well when killing a project. And sly-scratch, and etc. > Project-kill-buffers is off. Its intention pretty useful, but its > implementation is a blunder. The root cause is this overgreedy > project-buffers. When "killing a project" the echo area asks me if I > want to kill a number of buffers that I didn't even know I had, because > of hidden buffers. This cannot be logical and the only way the > "argument can be made both ways" is out of stubborness. > > JSONRPC's buffers are hidden implementation details: the argument that > they are somehow under the responsibility of project.el just because it > can see them through (buffer-list) is blind tiranny. > > The mini-languages invented in project-kill-buffers-conditions and > project-ignore-buffer-conditions are abominations. This is the point where I'd normally blacklist you again. > diff --git a/lisp/vc/vc-dispatcher.el b/lisp/vc/vc-dispatcher.el > index dc3ed52650..718bebc7cd 100644 > --- a/lisp/vc/vc-dispatcher.el > +++ b/lisp/vc/vc-dispatcher.el > @@ -179,6 +179,7 @@ vc-setup-buffer > (let ((camefrom (current-buffer)) > (olddir default-directory)) > (set-buffer (get-buffer-create buf)) > + (setq-local project-owned t) > (let ((oldproc (get-buffer-process (current-buffer)))) > ;; If we wanted to wait for oldproc to finish before doing > ;; something, we'd have used vc-eval-after. > > To name one. The above is just the converse of the solution proposed by > Philip before. > > Anyway, I've now suggested and presented 2 actually tested, actually > working patches to project.el. I don't have anything more to add. They are not much better than the "patch" I showed for Eglot, correctness-wise. And mine would make it safe against any kill-buffer calls, including ones issued by the user.