From mboxrd@z Thu Jan 1 00:00:00 1970 Path: news.gmane.io!.POSTED.blaine.gmane.org!not-for-mail From: =?UTF-8?Q?Jo=C3=A3o_?= =?UTF-8?Q?T=C3=A1vora?= 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 02:39:34 +0100 Message-ID: <87v8o3wgq1.fsf@gmail.com> 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> Mime-Version: 1.0 Content-Type: text/plain Injection-Info: ciao.gmane.io; posting-host="blaine.gmane.org:116.202.254.214"; logging-data="18759"; mail-complaints-to="usenet@ciao.gmane.io" User-Agent: Gnus/5.13 (Gnus v5.13) Cc: Philip Kaludercic , Manuel Uberti , 58839@debbugs.gnu.org To: Dmitry Gutov Original-X-From: bug-gnu-emacs-bounces+geb-bug-gnu-emacs=m.gmane-mx.org@gnu.org Sat Oct 29 03:39:15 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 1ooaod-0004k3-MC for geb-bug-gnu-emacs@m.gmane-mx.org; Sat, 29 Oct 2022 03:39:15 +0200 Original-Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1ooaoR-0001E8-BK; Fri, 28 Oct 2022 21:39:03 -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 1ooaoP-00014f-Vp for bug-gnu-emacs@gnu.org; Fri, 28 Oct 2022 21:39:02 -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 1ooaoP-0007pK-Md for bug-gnu-emacs@gnu.org; Fri, 28 Oct 2022 21:39:01 -0400 Original-Received: from Debian-debbugs by debbugs.gnu.org with local (Exim 4.84_2) (envelope-from ) id 1ooaoP-0001Bs-Hy for bug-gnu-emacs@gnu.org; Fri, 28 Oct 2022 21:39:01 -0400 X-Loop: help-debbugs@gnu.org Resent-From: =?UTF-8?Q?Jo=C3=A3o_?= =?UTF-8?Q?T=C3=A1vora?= Original-Sender: "Debbugs-submit" Resent-CC: bug-gnu-emacs@gnu.org Resent-Date: Sat, 29 Oct 2022 01:39: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.16670075144541 (code B ref 58839); Sat, 29 Oct 2022 01:39:01 +0000 Original-Received: (at 58839) by debbugs.gnu.org; 29 Oct 2022 01:38:34 +0000 Original-Received: from localhost ([127.0.0.1]:34625 helo=debbugs.gnu.org) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1ooany-0001BA-4o for submit@debbugs.gnu.org; Fri, 28 Oct 2022 21:38:34 -0400 Original-Received: from mail-wm1-f45.google.com ([209.85.128.45]:44701) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1ooanv-0001Aw-3f for 58839@debbugs.gnu.org; Fri, 28 Oct 2022 21:38:33 -0400 Original-Received: by mail-wm1-f45.google.com with SMTP id bg9-20020a05600c3c8900b003bf249616b0so4881209wmb.3 for <58839@debbugs.gnu.org>; Fri, 28 Oct 2022 18:38:31 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20210112; h=mime-version:user-agent:message-id:date:references:in-reply-to :subject:cc:to:from:from:to:cc:subject:date:message-id:reply-to; bh=T1/g2QpkiYxmE9EqeXM0SBU9TGqsuE6ECzZds2++sfY=; b=b+QhHQOY/f48MKpm2ZiyPIQrCIxloMkfE6+CIuBxHcYC0Hv8jQGg8aYpgkHkLeuGU4 HfSWvYhV4LYejdWTb5/8G1QmAn34OKpA54mLHzdUqVCUAmx0FcymiEdnGRuzqURe2afo q4ZmQs14qr/e7rTN+9cmgM7GSEaPjski8BXvdwRscL9j4JbliLn7uWKp8rz6bFAYuyE8 lAdiURaHJgxBk4khUNcImnREbCEWa9FkUrKdQgPrRzxoW76lvGmBSrfKA8vvTma5xvUt fFpSVTkIMZ/n1JISbwWOoKBS/lMzmJZ1pv081FtRP+Fk6tgTfK0TuKWxtW/nQkeHv6Xg Aj0A== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=mime-version:user-agent:message-id:date:references:in-reply-to :subject:cc:to:from:x-gm-message-state:from:to:cc:subject:date :message-id:reply-to; bh=T1/g2QpkiYxmE9EqeXM0SBU9TGqsuE6ECzZds2++sfY=; b=3/+uWYUzDHrBcISAkM6rhdLlpvlbVFewsdZZ8dfrh1fjLapPehcG1e0MkoTRoz30mc Yhs5FNyrtooBIoqUMi9dQoFLMAaLmgWwQGQzu+FV35b5XQLjUuTWaZfiQ/WevrPfhDrt 5RC2DQeXbfERQ5MbBFzCCAG+88F6DirxmRF1ox54guvASxsej6slTwZjMI4yaFb1zJ13 Dhu+WVSp8wuW3Ob4pkrcX0mKdSRJmY1pQZ8xkpCtL21fTap+XZEq09EPch6mZ1vhKnep FaJLmd15RZDDCpBz81gO4+20Mjs2lzvqNofe8OR8LuPvB1CtifBCeWLCO6oSGQjjxZhL cWsg== X-Gm-Message-State: ACrzQf3ve6UoofZZeJmpuSji+MIqWjdb1OsGQDpc53uRxx6w7/WjbZ4c BtwKvq564NE0AiTTSzCKT2Q= X-Google-Smtp-Source: AMsMyM5kWPnEuBEAVYQn8DL1vDDAG2O2fsTgjBk+/jcAGa2YfJ1Hvk3DftFysnc6uk0nMuvEE9NNjw== X-Received: by 2002:a05:600c:314f:b0:3c6:f27d:fa52 with SMTP id h15-20020a05600c314f00b003c6f27dfa52mr11087713wmo.20.1667007504982; Fri, 28 Oct 2022 18:38:24 -0700 (PDT) Original-Received: from krug ([87.196.74.89]) by smtp.gmail.com with ESMTPSA id m13-20020adffe4d000000b0022afcc11f65sm172855wrs.47.2022.10.28.18.38.23 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 28 Oct 2022 18:38:24 -0700 (PDT) In-Reply-To: <8e31a89d-e35e-6dd0-a8e3-f0b9684c8bfa@yandex.ru> (Dmitry Gutov's message of "Sat, 29 Oct 2022 04:09:13 +0300") 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:246473 Archived-At: Dmitry Gutov writes: > Sorry, I don't have Eglot checked out, or the time to test out the > patch. If you missed it, Eglot has been merged in lisp/progmodes/eglot.el. There's not much point in testing that your patch: I can tell you right away it doesn't work. > I suppose. But the current criterion depends on the value of > default-directory, and that makes it a match. This criterion is wrong. It makes mistakes. But a criterion that is "default-directory and is not hidden", though probably still not ideal, but is definitely better. >> If you agree that >> there are such cases, then it should become clear that the buffer in >> question must be at the top of that list. > > I'm not sure. Intuitively, I'd say that this buffer belongs to the > project because it "services" the project. But if it were to work for > several projects at the same time, I suppose I could say it doesn't > belong to any particular one. It indeed indirectly services just that one project: but it's also just another object. Eglot has lots of objects, variables etc., that "service the project" and project.el fortunately isn't crazy to to touch them. The buffer in question is an implementation detail of jsonrpc.el. It's not a buffer of interest in any way for the user or project.el's manipulations. And it's only a buffer because buffer's are Emacs' common way of communicating with external entities, and jsonrpc.el uses that technique. But it could use some other way, say another process-filter or function calls into C code of a dynamic library. There would also be objects that indirectly "service" the project, but not buffers. >> There are more hints that the concept of "buffer belonging to a project" >> was not fully thought through, even in cases unrelated to this bug >> report. >> * Take the *scratch* buffer. It has a default-directory. Does this >> also make *scratch* belong to a project? It doesn't make any sense to >> me that it would. Yet it is caught by project-buffers. > > *scratch* is not that special - you can create similar buffers at > will. So there are two ways of looking at that question. One can > create a "scratch" for a project, and it will be part of that > project. > > If "~" (the usual value of default-directory in the original > *scratch*) belongs to a project, then *scratch* also does. I M-x cd in *scratch* all the time. It's a global scratch pad, now accessible via scratch-buffer everywhere. >> * project-buffers also catches the one-time *Completions* buffers, the >> kind produced by hitting TAB after C-x p b. If you type C-x p b >> again, it quite comically offers the stale *Completions* buffer as a >> candidate to switch to. > > We could make an exception for that too. > >> But back to *scratch*. Somehow *scratch* is not killed by M-x >> project-kill-buffers. I think it's because it doesn't have a >> buffer-file-name. But then neither does the Eglot/Jsonrpc's "background >> buffers"! It seems it is being targeted merely because it uses >> fundamental-mode, a most reasonable mode to use for exchanging messages >> via standard streams. >> I guess this means that the hack below is enough to fix the issue, >> but >> it is also decidedly silly. > > It's not much better than adding a function to > kill-buffer-query-functions that returns nil. And/or behaves > accordingly to eglot-autoshutdown. You should think your solution through before comparing with the ones provided so far, which have been tested. Where in the source code would you even set kill-buffer-query-functions? Eglot code in jsonrpc.el?? Not to mention duplicating the eglot-autoshutdown check in unrelated places is pretty ugly. >> So please consider fixing this in project.el. As Manuel pointed out, >> the venerable ibuffer.el's ibuffer-kill-filter-group also kills project >> 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-2053395