From mboxrd@z Thu Jan 1 00:00:00 1970 Path: news.gmane.io!.POSTED.blaine.gmane.org!not-for-mail From: Philip Kaludercic Newsgroups: gmane.emacs.bugs Subject: bug#58839: [Patch] Re: bug#58839: 29.0.50; project-kill-buffer fails when Eglot is running Date: Sat, 29 Oct 2022 14:32:50 +0000 Message-ID: <871qqq7l9p.fsf@posteo.net> 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> Mime-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: quoted-printable Injection-Info: ciao.gmane.io; posting-host="blaine.gmane.org:116.202.254.214"; logging-data="11522"; mail-complaints-to="usenet@ciao.gmane.io" Cc: Manuel Uberti , 58839@debbugs.gnu.org, Dmitry Gutov 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@gnu.org Sat Oct 29 16:34:19 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 1oomug-0002mo-Gi for geb-bug-gnu-emacs@m.gmane-mx.org; Sat, 29 Oct 2022 16:34:18 +0200 Original-Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1oomuS-0007Vb-NN; Sat, 29 Oct 2022 10:34:04 -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 1oomuR-0007VN-05 for bug-gnu-emacs@gnu.org; Sat, 29 Oct 2022 10:34:03 -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 1oomuQ-00076K-Ph for bug-gnu-emacs@gnu.org; Sat, 29 Oct 2022 10:34:02 -0400 Original-Received: from Debian-debbugs by debbugs.gnu.org with local (Exim 4.84_2) (envelope-from ) id 1oomuQ-0002j2-BP for bug-gnu-emacs@gnu.org; Sat, 29 Oct 2022 10:34:02 -0400 X-Loop: help-debbugs@gnu.org Resent-From: Philip Kaludercic Original-Sender: "Debbugs-submit" Resent-CC: bug-gnu-emacs@gnu.org Resent-Date: Sat, 29 Oct 2022 14:34:02 +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.166705399110408 (code B ref 58839); Sat, 29 Oct 2022 14:34:02 +0000 Original-Received: (at 58839) by debbugs.gnu.org; 29 Oct 2022 14:33:11 +0000 Original-Received: from localhost ([127.0.0.1]:36304 helo=debbugs.gnu.org) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1oomta-0002hn-HG for submit@debbugs.gnu.org; Sat, 29 Oct 2022 10:33:10 -0400 Original-Received: from mout01.posteo.de ([185.67.36.65]:41713) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1oomtV-0002hG-VZ for 58839@debbugs.gnu.org; Sat, 29 Oct 2022 10:33:08 -0400 Original-Received: from submission (posteo.de [185.67.36.169]) by mout01.posteo.de (Postfix) with ESMTPS id EE0C1240026 for <58839@debbugs.gnu.org>; Sat, 29 Oct 2022 16:32:59 +0200 (CEST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=posteo.net; s=2017; t=1667053980; bh=S2Rv0NtXlcFjdeTC3LBawUbreaRVfgYv67zAmJ0gFoY=; h=From:To:Cc:Subject:Autocrypt:Date:From; b=gxElmpWRHJYBTzM2HV0/m755sROgtM/TgV68QtGLFYd8bu35+FXLu7EWuXZR6q4yt gGY4J9EIfUnX4F7RZMVQ8fiuHrtTmQJEh/27vpanCDqSPidmcNA66Z1mDT8I8/rRwL Zv6zG2ZbhHG3a7kN/jyPEe6Ti/LY6AmA7G7vt4SNUae5Of1mAtySoxam5uZgMqQ9xS 69UoAMqDwrsufaL0lv7Rjb47TW2jBAuhfZUOaw669k1Bf6GAv8nl+KZqEtdlwwH9tY y+Kdu29WftQxEs8u5UezLHF8283ze0qEAGKGwmfrXtrr/DKwb3wy10cJuM5/M/I9RV c6RQawfsyqDbA== Original-Received: from customer (localhost [127.0.0.1]) by submission (posteo.de) with ESMTPSA id 4N022L4jLxz9rxF; Sat, 29 Oct 2022 16:32:56 +0200 (CEST) In-Reply-To: <87ilk2x1si.fsf@gmail.com> ("=?UTF-8?Q?Jo=C3=A3o_?= =?UTF-8?Q?T=C3=A1vora?="'s message of "Sat, 29 Oct 2022 13:16:45 +0100") Autocrypt: addr=philipk@posteo.net; prefer-encrypt=nopreference; keydata= mDMEYHHqUhYJKwYBBAHaRw8BAQdAp3GdmYJ6tm5McweY6dEvIYIiry+Oz9rU4MH6NHWK0Ee0QlBo aWxpcCBLYWx1ZGVyY2ljIChnZW5lcmF0ZWQgYnkgYXV0b2NyeXB0LmVsKSA8cGhpbGlwa0Bwb3N0 ZW8ubmV0PoiQBBMWCAA4FiEEDM2H44ZoPt9Ms0eHtVrAHPRh1FwFAmBx6lICGwMFCwkIBwIGFQoJ CAsCBBYCAwECHgECF4AACgkQtVrAHPRh1FyTkgEAjlbGPxFchvMbxzAES3r8QLuZgCxeAXunM9gh io0ePtUBALVhh9G6wIoZhl0gUCbQpoN/UJHI08Gm1qDob5zDxnIHuDgEYHHqUhIKKwYBBAGXVQEF AQEHQNcRB+MUimTMqoxxMMUERpOR+Q4b1KgncDZkhrO2ql1tAwEIB4h4BBgWCAAgFiEEDM2H44Zo Pt9Ms0eHtVrAHPRh1FwFAmBx6lICGwwACgkQtVrAHPRh1Fw1JwD/Qo7kvtib8jy7puyWrSv0MeTS g8qIxgoRWJE/KKdkCLEA/jb9b9/g8nnX+UcwHf/4VfKsjExlnND3FrBviXUW6NcB 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@gnu.org Xref: news.gmane.io gmane.emacs.bugs:246533 Archived-At: Jo=C3=A3o T=C3=A1vora writes: > Dmitry Gutov writes: > >> This whole discussion is about different shades of OCD. One party >> wants to clean up as much as possible, another says don't touch my >> things. > > I think this discussion is about mistaking resource access for resource > ownership. Just because project.el or any Lisp package can access the > full list of buffers, doesn't mean it can do whatever it wants with > them. Just like a routine in a C program can see the full memory > address space of the process, and possibly even form pointers to these > bytes, but it shouldn't rely on their values and certainly can't free() > what it didn't malloc(). But to extend this metaphor, if I kill a programm that allocated malloc, I would expect that memory to be cleaned up. >> I don't think there is an objective "right" way to do things, only >> something we're able to agree on in the end. I don't really use this >> feature much myself: if you're able to come to an agreement with >> Philip (who took the initiative on adding that command), I'll be >> happy. > > I think the command is pretty useful. But perhaps, I'm just guessing > here, Philip is focusing too much it as if it were the only sanctioned > way for Emacs users to stop working on a given set of files in a > programming project and clean up. Of course it isn't, it is just my prefered way and Eglot breaks it. > So project-k-buffers is useful but it doesn't have that exclusive. If it > did (but I don't think it will ever have) then Eglot could indeed attach > connection management to it. > >> Most object types are garbage-collected when no live reference to them >> remains. That's not the case for buffers. > > Because there is always at least one live reference to them, obviously. > But why does this matter? In this buffer's case there are probably even > more. One of these references is the one that Eglot and Jsonrpc control > the program or network process. This is held in global variable. There > are no resource leaks, as far as I know. > >> Is the buffer in question killed when the user calls 'M-x >> eglot-shutdown'? If so, consider that, after the user calls >> project-kill-buffers, there won't be any buffers remaining that belong >> to that project, that the user would be able to call 'M-x >> eglot-shutdown' from. > > Are you sure? Well you should actually try M-x eglot-shutdown and see > what happens then :-) > >>> I M-x cd in *scratch* all the time. It's a global scratch pad, >>> now accessible via scratch-buffer everywhere. >> And I don't have any projects that "~" belongs to. > > Neither do I. But when I M-x cd to other places, project.el thinks that > scratch belongs to that project. It doesn't, I keep stuff of various > projects in it. I agree, this is bad, but that can easily be solved by adding `lisp-interaction-mode' to the list of major modes that are not killed. >> Same place you changed the major mode in the last patch: >> jsonrpc.el. If jsonrpc.el doesn't want its buffers to be killed, it >> could set that up as described above, through >> kill-buffer-query-functions. > > Why should resource owners go to the hassle of whitelisting themselves > from other packages' newfound disregard for private property? Not to > mention jsonrpc.el wants its buffers to be killed in controlled > circunstances. So now it would have to "unprotect itself" in those > places. I can't even think of adjectifying this design, let alone deal > with the corner cases. > >>>>> So please consider fixing this in project.el. As Manuel pointed out, >>>>> the venerable ibuffer.el's ibuffer-kill-filter-group also kills proje= ct >>>>> buffers and handles this whole thing very well. We should just take a >>>>> hint from it. >>>> I'm unable to find that message. >>> In the original conversation: >>> https://github.com/joaotavora/eglot/discussions/822#discussioncomment-2= 053395 >> >> It's a reasonable approach too. Just not the one we took here. It >> would make sense to try to make it work first. > > Ibuffer understands ownership, so it comes with bug-free and > hassle-free. Sounds more than "reasonable" to me. > > Just commit the original tested patch I gave you that exempts hidden > buffers without buffer-file-name from project-buffers. Philip's command > will keep working perfectly and we can close this bug. So if I understand correctly, with `eglot-autoshutdown' enabled as soon as all the buffers have been killed, the server will also shut down, right? Regarding the patch itself, I think it would be better to use `project-kill-buffer-conditions', so that if a project.el backend defines a new implementation for `project-buffers', the issue doesn't pop up again. > Jo=C3=A3o