From debbugs-submit-bounces@debbugs.gnu.org Thu Nov 03 14:49:29 2022 Received: (at submit) by debbugs.gnu.org; 3 Nov 2022 18:49:29 +0000 Received: from localhost ([127.0.0.1]:50671 helo=debbugs.gnu.org) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1oqfHN-0003vL-Eg for submit@debbugs.gnu.org; Thu, 03 Nov 2022 14:49:29 -0400 Received: from lists.gnu.org ([209.51.188.17]:34004) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1oqfHJ-0003vA-Fe for submit@debbugs.gnu.org; Thu, 03 Nov 2022 14:49:27 -0400 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 1oqfGi-00087E-7e for bug-gnu-emacs@gnu.org; Thu, 03 Nov 2022 14:49:12 -0400 Received: from relay8-d.mail.gandi.net ([2001:4b98:dc4:8::228]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1oqfGd-0007vW-KU for bug-gnu-emacs@gnu.org; Thu, 03 Nov 2022 14:48:46 -0400 Received: (Authenticated sender: juri@linkov.net) by mail.gandi.net (Postfix) with ESMTPSA id EEA941BF205 for ; Thu, 3 Nov 2022 18:48:39 +0000 (UTC) From: Juri Linkov To: bug-gnu-emacs@gnu.org Subject: Eglot activated in xref internal buffers Organization: LINKOV.NET Date: Thu, 03 Nov 2022 20:43:31 +0200 Message-ID: <86y1srri98.fsf_-_@mail.linkov.net> User-Agent: Gnus/5.13 (Gnus v5.13) Emacs/29.0.50 (x86_64-pc-linux-gnu) MIME-Version: 1.0 Content-Type: text/plain; charset=iso-8859-1 Content-Transfer-Encoding: 8bit Received-SPF: pass client-ip=2001:4b98:dc4:8::228; envelope-from=juri@linkov.net; helo=relay8-d.mail.gandi.net X-Spam_score_int: -25 X-Spam_score: -2.6 X-Spam_bar: -- X-Spam_report: (-2.6 / 5.0 requ) BAYES_00=-1.9, RCVD_IN_DNSWL_LOW=-0.7, SPF_HELO_NONE=0.001, SPF_PASS=-0.001 autolearn=ham autolearn_force=no X-Spam_action: no action X-Spam-Score: -1.6 (-) X-Debbugs-Envelope-To: submit X-BeenThere: debbugs-submit@debbugs.gnu.org X-Mailman-Version: 2.1.18 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: debbugs-submit-bounces@debbugs.gnu.org Sender: "Debbugs-submit" X-Spam-Score: -2.6 (--) X-Debbugs-Cc: João Távora X-Debbugs-Cc: Dmitry Gutov [A new issue spun off from bug#58839] > Juri, this doesn't seem right. Eglot shouldn't be turning itself on in > hidden buffers to start with: It's totally useless there. > > So you have to explain an Emacs -Q recipe that demonstrates how Eglot > reached this nonsensical state. You haven't done that (or have you and i > have missed it?). > > I tried project-find-regexp with Eglot-managed files with no problems, but > I have no idea what you're doing. > > Also, this problem is totally off-topic here: this is about > project-kill-buffers. Please start as new issue of you haven't already. This issue is very hard to reproduce. It occurs only when *xref-temp* first sets one mode not eglot-managed, then afterwards enables another mode that is eglot-managed in the same internal buffer. Maybe Dmitry could explain what is going wrong. > On Thu, Nov 3, 2022, 17:39 Juri Linkov wrote: >> OTOH I completely support the request to make Eglot more resilient >> to unforeseeable situations. Currently it's so brittle, so I get a lot >> of such errors all the time: >> >> Debugger entered--Lisp error: (wrong-type-argument arrayp nil) >> file-truename(nil) >> eglot--path-to-uri(nil) >> eglot--TextDocumentIdentifier() >> eglot--signal-textDocument/didClose() >> kill-buffer(#) >> xref--convert-hits(...) >> xref-matches-in-files("word" ...) >> project--find-regexp-in-files("word" ...) >> apply(project--find-regexp-in-files ("word" ...)) >> xref--show-xref-buffer(...) >> xref--show-xrefs(...) >> xref-show-xrefs(...) >> project-find-regexp("word") >> funcall-interactively(project-find-regexp "word") >> command-execute(project-find-regexp) > > Here's a patch that fixes this: > > diff --git a/lisp/progmodes/eglot.el b/lisp/progmodes/eglot.el > index c5870618372..5b05f84c63c 100644 > --- a/lisp/progmodes/eglot.el > +++ b/lisp/progmodes/eglot.el > @@ -1792,7 +1792,9 @@ eglot--maybe-activate-editing-mode > (unless eglot--managed-mode > ;; Called when `revert-buffer-in-progress-p' is t but > ;; `revert-buffer-preserve-modes' is nil. > - (when (and buffer-file-name (eglot-current-server)) > + (when (and buffer-file-name > + (not (string-match-p "\\` " (buffer-name))) > + (eglot-current-server)) > (setq eglot--diagnostics nil) > (eglot--managed-mode) > (eglot--signal-textDocument/didOpen)))) From debbugs-submit-bounces@debbugs.gnu.org Thu Nov 03 20:50:32 2022 Received: (at 59001) by debbugs.gnu.org; 4 Nov 2022 00:50:32 +0000 Received: from localhost ([127.0.0.1]:51044 helo=debbugs.gnu.org) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1oqkul-0004t4-Vi for submit@debbugs.gnu.org; Thu, 03 Nov 2022 20:50:32 -0400 Received: from mail-wr1-f44.google.com ([209.85.221.44]:46969) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1oqkuh-0004so-CE for 59001@debbugs.gnu.org; Thu, 03 Nov 2022 20:50:30 -0400 Received: by mail-wr1-f44.google.com with SMTP id bk15so4995385wrb.13 for <59001@debbugs.gnu.org>; Thu, 03 Nov 2022 17:50:27 -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:to :content-language:subject:user-agent:mime-version:date:message-id :sender:from:to:cc:subject:date:message-id:reply-to; bh=AwdRpfXW6ejtofq1M9bmCOmWBa3pd3eP2AofcBdwmhQ=; b=grTdikpmLaAR9yQBBn1DhPuoYSaQvpPG7/N8IkxosYlxIYzw/06brIlGb8/zfNUNtS fOpM96eViPwB1AoL7z2D8SaIV+WVerMJsxE9AA3dh5JTut7MT+5Qf27nQe6mPc0WzK3L SWQIVJKYxqMmK8iavxP+xnZPFqacYL0DD4Va535Lm7cHA+4YPmNHUTiJOz0bSx0tzB4y sjkRLqQ4nYp8jCAsbqZPcy0qt8T4cbqzELwRe7rHEug5o3w+TPG0fa9QBlq1Q5HF7vtz 9V9o81gkg6YnK7guD518yJJ+ue1aHVQSiY7SBUX9gtDiB72jfIchIOuMjr3YB/cts27+ tl9g== 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: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=AwdRpfXW6ejtofq1M9bmCOmWBa3pd3eP2AofcBdwmhQ=; b=F4WvgRm1eLcDLBI6sF+Nbds5kPwq6QzvDJccV+blUKJinXwsEwiAa+qIAhXlVp4Jjo A8wYh6Fi0iPv+0EFNB28xj94BHTO864gjLTUsGSfXKckjswZZSZ2zvlm9KjVmBRReOSv MA27FgJVMeuscm3A3Kut3h4LIUJItJFvsY+UX9DF9GebdHla/OCkuGeUN9h4/2Y0CncS BMDo28m9mJL/wOmvRp6v4GdikAmbxW6kXDIRfCh+5Jk5unwmhSMGYbNW+5v6v97hUkV3 ReO2ZmPVwTMNpbsBlS3o42TmF8Dey3mj5foCfv6G7QPyTx7XnOUG+hrBBO5rMN5ifCzY NEVA== X-Gm-Message-State: ACrzQf0uADNBvHoqg3HPLn/2H6/urDOd8Jyggd9FaAFqp4BVLVaHwJ7x TCZK0KXQIPpZqkx/X6ovtAw= X-Google-Smtp-Source: AMsMyM4BFcnY8Oo7IHTG7UKjBN50T7IZo0vk5Y9ei+sTVUeFnuajnj/PKZAoTj0pkNKIjbuO8KgK5A== X-Received: by 2002:adf:f609:0:b0:236:680b:8c65 with SMTP id t9-20020adff609000000b00236680b8c65mr21560839wrp.615.1667523021178; Thu, 03 Nov 2022 17:50:21 -0700 (PDT) Received: from [192.168.0.6] ([46.251.119.176]) by smtp.googlemail.com with ESMTPSA id n18-20020a05600c465200b003b497138093sm1093077wmo.47.2022.11.03.17.50.20 (version=TLS1_3 cipher=TLS_AES_128_GCM_SHA256 bits=128/128); Thu, 03 Nov 2022 17:50:20 -0700 (PDT) Message-ID: <402a1c24-48c3-28ef-454e-afa93a89c47e@yandex.ru> Date: Fri, 4 Nov 2022 02:50:19 +0200 MIME-Version: 1.0 User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:102.0) Gecko/20100101 Thunderbird/102.2.2 Subject: Re: bug#59001: Eglot activated in xref internal buffers Content-Language: en-US To: Juri Linkov , 59001@debbugs.gnu.org References: <86y1srri98.fsf_-_@mail.linkov.net> From: Dmitry Gutov In-Reply-To: <86y1srri98.fsf_-_@mail.linkov.net> Content-Type: text/plain; charset=UTF-8; format=flowed Content-Transfer-Encoding: 8bit X-Spam-Score: -1.3 (-) X-Debbugs-Envelope-To: 59001 X-BeenThere: debbugs-submit@debbugs.gnu.org X-Mailman-Version: 2.1.18 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: debbugs-submit-bounces@debbugs.gnu.org Sender: "Debbugs-submit" X-Spam-Score: -2.3 (--) On 03.11.2022 20:43, Juri Linkov wrote: > X-Debbugs-Cc: João Távora > X-Debbugs-Cc: Dmitry Gutov > > [A new issue spun off from bug#58839] > >> Juri, this doesn't seem right. Eglot shouldn't be turning itself on in >> hidden buffers to start with: It's totally useless there. >> >> So you have to explain an Emacs -Q recipe that demonstrates how Eglot >> reached this nonsensical state. You haven't done that (or have you and i >> have missed it?). >> >> I tried project-find-regexp with Eglot-managed files with no problems, but >> I have no idea what you're doing. >> >> Also, this problem is totally off-topic here: this is about >> project-kill-buffers. Please start as new issue of you haven't already. > This issue is very hard to reproduce. It occurs only when > *xref-temp* first sets one mode not eglot-managed, then > afterwards enables another mode that is eglot-managed > in the same internal buffer. Maybe Dmitry could explain > what is going wrong. Sounds like Eglot, by means of some hooks, sets up some information about the buffer. And then it somehow doesn't get cleaned up when the major mode changes. Permanent locals? That's a question for Joao. It is a temporary buffer, and we enable different major modes in it (through set-auto-mode), to be able to regexp-search in the inserted contents using syntax-sensitive specials (most often - \_< and \_>). The reason we don't use delay-mode-hooks is in the linked bug report in the comments. Hopefully we will later, maybe after Emacs 29. From debbugs-submit-bounces@debbugs.gnu.org Fri Nov 04 03:31:51 2022 Received: (at 59001) by debbugs.gnu.org; 4 Nov 2022 07:31:51 +0000 Received: from localhost ([127.0.0.1]:51516 helo=debbugs.gnu.org) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1oqrB8-0000ck-Vb for submit@debbugs.gnu.org; Fri, 04 Nov 2022 03:31:51 -0400 Received: from relay2-d.mail.gandi.net ([217.70.183.194]:54381) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1oqrB4-0000cU-LQ for 59001@debbugs.gnu.org; Fri, 04 Nov 2022 03:31:50 -0400 Received: (Authenticated sender: juri@linkov.net) by mail.gandi.net (Postfix) with ESMTPSA id 261FF40002; Fri, 4 Nov 2022 07:31:38 +0000 (UTC) From: Juri Linkov To: Dmitry Gutov Subject: Re: bug#59001: Eglot activated in Xref internal buffers In-Reply-To: <402a1c24-48c3-28ef-454e-afa93a89c47e@yandex.ru> (Dmitry Gutov's message of "Fri, 4 Nov 2022 02:50:19 +0200") Organization: LINKOV.NET References: <86y1srri98.fsf_-_@mail.linkov.net> <402a1c24-48c3-28ef-454e-afa93a89c47e@yandex.ru> Date: Fri, 04 Nov 2022 09:29:49 +0200 Message-ID: <86cza3190q.fsf_-_@mail.linkov.net> User-Agent: Gnus/5.13 (Gnus v5.13) Emacs/29.0.50 (x86_64-pc-linux-gnu) MIME-Version: 1.0 Content-Type: text/plain X-Spam-Score: -0.7 (/) X-Debbugs-Envelope-To: 59001 Cc: 59001@debbugs.gnu.org X-BeenThere: debbugs-submit@debbugs.gnu.org X-Mailman-Version: 2.1.18 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: debbugs-submit-bounces@debbugs.gnu.org Sender: "Debbugs-submit" X-Spam-Score: -1.7 (-) >> This issue is very hard to reproduce. It occurs only when >> *xref-temp* first sets one mode not eglot-managed, then >> afterwards enables another mode that is eglot-managed >> in the same internal buffer. Maybe Dmitry could explain >> what is going wrong. > > Sounds like Eglot, by means of some hooks, sets up some information about > the buffer. And then it somehow doesn't get cleaned up when the major mode > changes. Permanent locals? That's a question for Joao. > > It is a temporary buffer, and we enable different major modes in it > (through set-auto-mode), to be able to regexp-search in the inserted > contents using syntax-sensitive specials (most often - \_< and \_>). > > The reason we don't use delay-mode-hooks is in the linked bug report in the > comments. Hopefully we will later, maybe after Emacs 29. Thanks for reminding that it's the same as bug#39190 and https://github.com/joaotavora/eglot/pull/233 Though I still don't completely understand full details of bug#23272 why xref--collect-matches couldn't use delay-mode-hooks. From debbugs-submit-bounces@debbugs.gnu.org Fri Nov 04 06:52:55 2022 Received: (at 59001) by debbugs.gnu.org; 4 Nov 2022 10:52:55 +0000 Received: from localhost ([127.0.0.1]:51893 helo=debbugs.gnu.org) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1oquJj-0006Kl-FY for submit@debbugs.gnu.org; Fri, 04 Nov 2022 06:52:55 -0400 Received: from mail-wr1-f47.google.com ([209.85.221.47]:41819) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1oquJg-0006KF-Nv for 59001@debbugs.gnu.org; Fri, 04 Nov 2022 06:52:53 -0400 Received: by mail-wr1-f47.google.com with SMTP id w14so6492865wru.8 for <59001@debbugs.gnu.org>; Fri, 04 Nov 2022 03:52:52 -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=sNy490pOLOPUXaxbsXWHQd4NGNQPfmPsCLPaqtZMsYg=; b=MdMXJyHfGN8qnly7wb9KoWdqFebyTdKPYHBF//64q8Ket1kix377+tM43vBTnLVHBJ m2dKg67vMwVyc8mnTvZz/ssoQj6nrPLbDXW5XuP+4+fTS/XYpkkPhiRQq7e6LTSyevoK oy1PJd+vbWwB+x0p1Kz/E6+lYzQG4C2u6gKaP37fubGhgGOnZYMLwZsl0wvBGjwuq4oh WFZtsr5bW3m4SjiGyBY6IVlGaah5W6OmczNgimQTMxV4S3Md/cICrPTU3KVyd+dWd2dW nJtpwTd1BysPyFOyXzEjnGIpNg1PpY6KEs1utjsv0bYz5u4jFM0dcr1seNr5lAE/SjkD dvAQ== 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=sNy490pOLOPUXaxbsXWHQd4NGNQPfmPsCLPaqtZMsYg=; b=TTtAlxNoW76VFFi1mdFr0xyWf/LhVSlf9H0E+4XlrG5W6Qlpm54xHAnFQrzQroXmoY vzhvVGpgf7bgnMmyf0ulahsUjAQHx/lWsnXHKVKaLVZyXONc/pbI+G0XcBv8uvnzpA/v JBbWAV5+gWPkGgP46RW8Rhu5HSHJ4a4xOWWYzpnNbgGs0nX+5c4GSgj2f2rXv7CtybO/ PEvRvlPM+1pf7E+SkevEzYKaWSRclZTfhLYVOBTKZeQ1DudqDpxt7mp90ikFJPh/ThfI mtmR1v5hO6Z9RWVAZ/W8GzvzNEB66oELMtmfhhMZ5VGHOEGkWUEUUney86+HRNEMX3Nl /5bw== X-Gm-Message-State: ACrzQf2DvmbKuFC5YR7Ln+bu43bZT1ighBOTlpcdV/Nh3otpgaoMCoWK 5qB5c9dJGiLUFVKiGR6RbiM= X-Google-Smtp-Source: AMsMyM7FXvHIkvd27mw+njzPxNadc8bbKP7o8bMPiLVunHiWY2lFGFS0tGaRSFEGmoXivcjcfEBcSA== X-Received: by 2002:adf:ba8f:0:b0:22c:def3:1179 with SMTP id p15-20020adfba8f000000b0022cdef31179mr22098515wrg.571.1667559166468; Fri, 04 Nov 2022 03:52:46 -0700 (PDT) Received: from [192.168.0.6] ([46.251.119.176]) by smtp.googlemail.com with ESMTPSA id k4-20020a05600c1c8400b003b4cba4ef71sm2575452wms.41.2022.11.04.03.52.45 (version=TLS1_3 cipher=TLS_AES_128_GCM_SHA256 bits=128/128); Fri, 04 Nov 2022 03:52:46 -0700 (PDT) Message-ID: <066aaa20-9f7b-8051-3a01-a4ab2e6ed88e@yandex.ru> Date: Fri, 4 Nov 2022 12:52:44 +0200 MIME-Version: 1.0 User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:102.0) Gecko/20100101 Thunderbird/102.2.2 Subject: Re: bug#59001: Eglot activated in Xref internal buffers Content-Language: en-US To: Juri Linkov References: <86y1srri98.fsf_-_@mail.linkov.net> <402a1c24-48c3-28ef-454e-afa93a89c47e@yandex.ru> <86cza3190q.fsf_-_@mail.linkov.net> From: Dmitry Gutov In-Reply-To: <86cza3190q.fsf_-_@mail.linkov.net> Content-Type: text/plain; charset=UTF-8; format=flowed Content-Transfer-Encoding: 7bit X-Spam-Score: -1.3 (-) X-Debbugs-Envelope-To: 59001 Cc: 59001@debbugs.gnu.org X-BeenThere: debbugs-submit@debbugs.gnu.org X-Mailman-Version: 2.1.18 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: debbugs-submit-bounces@debbugs.gnu.org Sender: "Debbugs-submit" X-Spam-Score: -2.3 (--) On 04.11.2022 09:29, Juri Linkov wrote: > Though I still don't completely understand full details of bug#23272 > why xref--collect-matches couldn't use delay-mode-hooks. That causes errors with major modes which use syntax-propertize-via-font-lock. Not sure how prevalent it is these days (hopefully not), but apparently it can still happen with Auctex: https://lists.gnu.org/archive/html/auctex-devel/2022-03/msg00027.html