From mboxrd@z Thu Jan 1 00:00:00 1970 Path: news.gmane.io!.POSTED.blaine.gmane.org!not-for-mail From: Theodor Thornhill via "Bug reports for GNU Emacs, the Swiss army knife of text editors" Newsgroups: gmane.emacs.bugs Subject: bug#70036: a fix that Date: Fri, 19 Apr 2024 08:26:53 +0200 Message-ID: <87sezh27gy.fsf@thornhill.no> References: <4e670617-6483-4159-a5cf-27a921764c38@email.android.com> <87wmot289d.fsf@thornhill.no> Reply-To: Theodor Thornhill Mime-Version: 1.0 Content-Type: text/plain Injection-Info: ciao.gmane.io; posting-host="blaine.gmane.org:116.202.254.214"; logging-data="17980"; mail-complaints-to="usenet@ciao.gmane.io" Cc: Eli Zaretskii , 70036@debbugs.gnu.org, felician.nemeth@gmail.com 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 Fri Apr 19 08:28:01 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 1rxhj6-0004TQ-LW for geb-bug-gnu-emacs@m.gmane-mx.org; Fri, 19 Apr 2024 08:28:01 +0200 Original-Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1rxhiw-00058f-LP; Fri, 19 Apr 2024 02:27:50 -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 1rxhiu-00058M-DF for bug-gnu-emacs@gnu.org; Fri, 19 Apr 2024 02:27:48 -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 1rxhiu-0006wf-4g for bug-gnu-emacs@gnu.org; Fri, 19 Apr 2024 02:27:48 -0400 Original-Received: from Debian-debbugs by debbugs.gnu.org with local (Exim 4.84_2) (envelope-from ) id 1rxhj7-0005mi-Q2 for bug-gnu-emacs@gnu.org; Fri, 19 Apr 2024 02:28:01 -0400 X-Loop: help-debbugs@gnu.org Resent-From: Theodor Thornhill Original-Sender: "Debbugs-submit" Resent-CC: bug-gnu-emacs@gnu.org Resent-Date: Fri, 19 Apr 2024 06:28:01 +0000 Resent-Message-ID: Resent-Sender: help-debbugs@gnu.org X-GNU-PR-Message: followup 70036 X-GNU-PR-Package: emacs Original-Received: via spool by 70036-submit@debbugs.gnu.org id=B70036.171350804122095 (code B ref 70036); Fri, 19 Apr 2024 06:28:01 +0000 Original-Received: (at 70036) by debbugs.gnu.org; 19 Apr 2024 06:27:21 +0000 Original-Received: from localhost ([127.0.0.1]:57029 helo=debbugs.gnu.org) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1rxhiR-0005jv-1i for submit@debbugs.gnu.org; Fri, 19 Apr 2024 02:27:20 -0400 Original-Received: from out-171.mta0.migadu.com ([2001:41d0:1004:224b::ab]:50979) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1rxhiP-0005io-A2 for 70036@debbugs.gnu.org; Fri, 19 Apr 2024 02:27:17 -0400 X-Report-Abuse: Please report any abuse attempt to abuse@migadu.com and include these headers. DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=thornhill.no; s=key1; t=1713508016; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:cc:mime-version:mime-version:content-type:content-type: in-reply-to:in-reply-to:references:references; bh=RfrdPUU9wCJah/nAyBplofOasC4TkvR7WOMtu3yPsAs=; b=TFXARErT8ufWejwWYXK9VuGZpcgZ5Z+XrwH4ut1TJ/WGYds4butVxbQDHgBeoe3PnCyRGp tU1S7+i1cWAy2HzUHpfRpBP9UokBwzt8b9S2jeUxGlMDriVg9cIEFGNxnBvvYSPNAR7o8Y bZ6OfDfRpkABp7rKgAm2aqCJGgIxDYvIfhcYCWDmtj4Zsgq+EVadoBUp44LgmOYLU7jMLf VE7Oesx2zNNgbXQaqFrPndR1l30D652xaYwHi26cAl/OT5x/BnmkGarWf+rrw/SP779yOj m9vApCdQ8mNQ96ydAH/n10o01jbfmnGfW+REXUHNIYw0CC74r4rELvzlPsL9TA== In-Reply-To: <87wmot289d.fsf@thornhill.no> X-Migadu-Flow: FLOW_OUT 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:283634 Archived-At: > > Could we rather use eglot--managed-buffers, like in my patch? there > shouldn't be a need to loop through say 200 buffers that are unrelated > to the project in question, right? Apart from this I agree, and will try > it. Like this? I can confirm with yours and this patch the latency is down again, so thanks. I'll test a little the difference with/without eglot--managed-buffers. Theo diff --git a/lisp/progmodes/eglot.el b/lisp/progmodes/eglot.el index 90a607075d3..3578aed92b4 100644 --- a/lisp/progmodes/eglot.el +++ b/lisp/progmodes/eglot.el @@ -2381,8 +2381,11 @@ eglot-handle-notification (lambda () (remhash token (eglot--progress-reporters server)))))))))) +(defvar-local eglot--cached-tdi nil + "A cached LSP TextDocumentIdentifier URI string.") + (cl-defmethod eglot-handle-notification - (_server (_method (eql textDocument/publishDiagnostics)) &key uri diagnostics + (server (_method (eql textDocument/publishDiagnostics)) &key uri diagnostics &allow-other-keys) ; FIXME: doesn't respect `eglot-strict-mode' "Handle notification publishDiagnostics." (cl-flet ((eglot--diag-type (sev) @@ -2391,9 +2394,14 @@ eglot-handle-notification ((= sev 2) 'eglot-warning) (t 'eglot-note))) (mess (source code message) - (concat source (and code (format " [%s]" code)) ": " message))) + (concat source (and code (format " [%s]" code)) ": " message)) + (find-it (uri) + (cl-loop for b in (eglot--managed-buffers server) + when (with-current-buffer b + (equal eglot--cached-tdi uri)) + return b))) (if-let* ((path (expand-file-name (eglot-uri-to-path uri))) - (buffer (find-buffer-visiting path))) + (buffer (find-it uri))) (with-current-buffer buffer (cl-loop initially @@ -2518,9 +2526,6 @@ eglot-handle-request (t (setq success :json-false))) `(:success ,success))) -(defvar-local eglot--cached-tdi nil - "A cached LSP TextDocumentIdentifier URI string.") - (defun eglot--TextDocumentIdentifier () "Compute TextDocumentIdentifier object for current buffer." `(:uri ,(or eglot--cached-tdi Thanks, Theo