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#59149: [SPAM UNSURE] Re: bug#59149: Feature Request: Report progress of long requests in Eglot Date: Sat, 26 Nov 2022 01:03:41 +0000 Message-ID: <87r0xqsf0y.fsf@gmail.com> References: <87educqkar.fsf@dfreeman.email> <86cz9jmg9r.fsf@stephe-leake.org> <87k03qvmla.fsf@dfreeman.email> <86fseckwvb.fsf@stephe-leake.org> <87tu2pohub.fsf@dfreeman.email> <86ilj5k0sn.fsf@stephe-leake.org> <87wn7l316m.fsf@dfreeman.email> <86edtsk3xi.fsf@stephe-leake.org> <87o7swv3nx.fsf@gmail.com> <8635a8jb8e.fsf@stephe-leake.org> <87r0xrxb0i.fsf@dfreeman.email> <834junuhae.fsf@gnu.org> <87ilj3x9we.fsf@dfreeman.email> 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="8864"; mail-complaints-to="usenet@ciao.gmane.io" User-Agent: Gnus/5.13 (Gnus v5.13) Cc: 59149@debbugs.gnu.org, Eli Zaretskii , stephen_leake@stephe-leake.org, stefankangas@gmail.com To: Danny Freeman Original-X-From: bug-gnu-emacs-bounces+geb-bug-gnu-emacs=m.gmane-mx.org@gnu.org Sat Nov 26 02:03:18 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 1oyjbA-00027A-In for geb-bug-gnu-emacs@m.gmane-mx.org; Sat, 26 Nov 2022 02:03:16 +0100 Original-Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1oyjay-0008Lw-QN; Fri, 25 Nov 2022 20:03:04 -0500 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 1oyjaw-0008LW-Kd for bug-gnu-emacs@gnu.org; Fri, 25 Nov 2022 20:03:02 -0500 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 1oyjaw-00009D-CD for bug-gnu-emacs@gnu.org; Fri, 25 Nov 2022 20:03:02 -0500 Original-Received: from Debian-debbugs by debbugs.gnu.org with local (Exim 4.84_2) (envelope-from ) id 1oyjav-0000eZ-Rk for bug-gnu-emacs@gnu.org; Fri, 25 Nov 2022 20:03:01 -0500 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, 26 Nov 2022 01:03:01 +0000 Resent-Message-ID: Resent-Sender: help-debbugs@gnu.org X-GNU-PR-Message: followup 59149 X-GNU-PR-Package: emacs Original-Received: via spool by 59149-submit@debbugs.gnu.org id=B59149.16694245562479 (code B ref 59149); Sat, 26 Nov 2022 01:03:01 +0000 Original-Received: (at 59149) by debbugs.gnu.org; 26 Nov 2022 01:02:36 +0000 Original-Received: from localhost ([127.0.0.1]:37461 helo=debbugs.gnu.org) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1oyjaW-0000dv-Cw for submit@debbugs.gnu.org; Fri, 25 Nov 2022 20:02:36 -0500 Original-Received: from mail-wr1-f42.google.com ([209.85.221.42]:46933) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1oyjaT-0000dg-47 for 59149@debbugs.gnu.org; Fri, 25 Nov 2022 20:02:34 -0500 Original-Received: by mail-wr1-f42.google.com with SMTP id h11so1637821wrw.13 for <59149@debbugs.gnu.org>; Fri, 25 Nov 2022 17:02:33 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20210112; h=content-transfer-encoding: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=BfssvVdkbmuS80eI3QvwwXhQA69ESmKPMuoHzKm+oZg=; b=DGAVngcq0NEKXWSwcpOVsG4FTUrzCbktaPEFLPtTgG9NZrEjmdLRDVVgta88k8oce4 ozvHrG8zrBu8A5Vi+C4M/mhzmakHKOb0dttN4gRW0ebGMBjVyPWKP0Lun5A6t5TgLkwi S5t4ozhkfuXeMQN8PsPCCNHEWEI4r0DVP9/fuLdLz9q7oDLZQOTcxwl/TkU8aqfWqIu2 u4H2W6d1ATKbylN58ekW7iUbcH63udTYMv9A/bftQCaF5lHrGbAXjn2I05JtSC6R9S5/ yBjNKrX/xrgqNfeCETf2Xdc1a56GUSeHIw4IOVxar73Ddgc13FrKTa3dQ5xoOeJnXiQS XtEg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=content-transfer-encoding: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=BfssvVdkbmuS80eI3QvwwXhQA69ESmKPMuoHzKm+oZg=; b=vm2979WAN5n8c9NY6rwq7DNTkKRaY83w1/2zPgSZumJuwG35fmWYOWuJ9mt0YJ89/E dLzbtKYOTfzbiFy2ZQyiga6e59PI6Fuyvbs7Ywbim+f8QjFJBLrar+vW8KAIgYDxhWSR HuRVYr+KrlAZVwDRYbvFgVoVodO3VK3FVggoLV75BtY5fLjtslZKR9AyCql2xgU1xxey YjoKFThhKSk+0Eg9z2iFtLN94ao/bRhjTCPy23GtewPDZaLuwJL6MuoXAyjNSh7V540w OkPsJ+r0sVhBtkOeghOzfHgdtR5h5vpJ/PWpCvCB/Jf0JGOQdmdfHDBxg3q3v1Fkk7dv FpbA== X-Gm-Message-State: ANoB5pnp/XYI8QSIOwMl9GYD+YGkAOikRTG+CgV7xXtUoIUMB5Piu0Kx WRGb7U/7HGVildY/4yjw+/M= X-Google-Smtp-Source: AA0mqf7QsABi5wRgliiJOAA/gIJnPS1duzNiDjDxGf7cqGkqqzatmP75nIo2AAgBRdfSg19XHcDdeg== X-Received: by 2002:a5d:50d0:0:b0:241:753d:6018 with SMTP id f16-20020a5d50d0000000b00241753d6018mr19096037wrt.67.1669424545709; Fri, 25 Nov 2022 17:02:25 -0800 (PST) Original-Received: from krug (87-196-72-177.net.novis.pt. [87.196.72.177]) by smtp.gmail.com with ESMTPSA id n14-20020a5d660e000000b00241bee11825sm4717931wru.103.2022.11.25.17.02.24 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 25 Nov 2022 17:02:25 -0800 (PST) In-Reply-To: <87ilj3x9we.fsf@dfreeman.email> (Danny Freeman's message of "Fri, 25 Nov 2022 11:41:46 -0500") 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:249030 Archived-At: Danny Freeman writes: > +(defcustom eglot-report-progress t > + "If non-nil, show progress of long running server work in the minibuff= er." > + :type 'boolean > + :version "29.1") The usual question: is the version number here Eglot, the ELPA package's upcoming version number, or is it Emacs's upcoming version number. I think Stefan Kangas had something to say about that. > + > + (message-log-max nil)) I know that indentation was off here, and you fixed it. But please revert this, and feel free to offer a separate cosmetic patch fixing this and other violations. > (ignore-errors (delay-mode-hooks (funcall mode)))) > (font-lock-ensure) > (string-trim (buffer-string))))) > @@ -2049,6 +2057,43 @@ eglot-handle-notification > (_server (_method (eql telemetry/event)) &rest _any) > "Handle notification telemetry/event.") ;; noop, use events buffer >=20=20 > +(defun eglot--progress-report-message (title message) > + "Format a $/progress report message, given a TITLE and/or MESSAGE stri= ng." > + (cond > + ((and title message) (format "%s %s" title message)) > + (title title) > + (message message))) > + > +(defun eglot--progress-reporter (server token) > + "Get a prgress-reporter identified by the progress TOKEN from the SERV= ER ." > + (cdr (assoc token (eglot--progress-reporter-alist server)))) > + > +(defun eglot--progress-reporter-delete (server token) > + "Delete progress-reporters identified by the progress TOKEN from the S= ERVER." > + (setf (eglot--progress-reporter-alist server) > + (assoc-delete-all token (eglot--progress-reporter-alist > server= )))) This is just a stylistic suggestion, but these functions could all be local inside the following eglot-handle-notification. Then you could give them less mouthfully names. The whole progress stuff could be examined by looking only at one function. > + > +(cl-defmethod eglot-handle-notification > + (server (_method (eql $/progress)) &key token value) > + "Handle a $/progress notification identified by TOKEN from the SERVER." > + (when eglot-report-progress > + (cl-destructuring-bind (&key kind title percentage message) value I think eglot-dbind is more appropriate here. See the file for how it's used. > + (pcase kind > + ("begin" (let* ((prefix (format (concat "[eglot] %s %s:" (when p= ercentage " ")) > + (eglot-project-nickname server) = token)) > + (pr (if percentage > + (make-progress-reporter prefix 0 100 per= centage 1 0) > + (make-progress-reporter prefix nil nil nil= 1 0)))) > + (eglot--progress-reporter-delete server token) > + (setf (eglot--progress-reporter-alist server) > + (cons (cons token pr) (eglot--progress-reporter= -alist server))) > + (progress-reporter-update pr percentage (eglot--progr= ess-report-message title message)))) > + ("report" (when-let ((pr (eglot--progress-reporter server token)= )) > + (progress-reporter-update pr percentage (eglot--prog= ress-report-message title message)))) > + ("end" (when-let ((pr (eglot--progress-reporter server token))) > + (progress-reporter-done pr) > + (eglot--progress-reporter-delete server token))))))) This lines are a bit too long, I think. Try to stick to 80 columns. M-x whitespace-mode helps in seeing that. I also think this could probably be simplified a bit or jumbled around to feel less repetitive. But it's not really bad as it stands, so feel free to disregard. > + > (cl-defmethod eglot-handle-notification > (_server (_method (eql textDocument/publishDiagnostics)) &key uri diag= nostics > &allow-other-keys) ; FIXME: doesn't respect `eglot-strict-mod= e' > @@ -2172,7 +2217,7 @@ eglot--TextDocumentItem > (append > (eglot--VersionedTextDocumentIdentifier) > (list :languageId > - (eglot--language-id (eglot--current-server-or-lose)) > + (eglot--language-id (eglot--current-server-or-lose)) Same here re: indentation. > :text > (eglot--widening > (buffer-substring-no-properties (point-min) (point-max)))))) The patch looks generally good: thanks! If you want to do the fixes I suggested, go ahead. Else give me some days to test it and I will push it. Jo=C3=A3o