From mboxrd@z Thu Jan 1 00:00:00 1970 Path: news.gmane.io!.POSTED.blaine.gmane.org!not-for-mail From: sbaugh@catern.com Newsgroups: gmane.emacs.bugs Subject: bug#71823: 31.0.50; project-mode-line and eglot duplicate project-name in mode-line Date: Sun, 30 Jun 2024 12:51:25 +0000 (UTC) Message-ID: <87jzi6fvar.fsf@catern.com> References: <86wmm9jfk7.fsf@gnu.org> <86o77kjk87.fsf@gnu.org> <17183c60-1733-4938-9a85-f3351c87bcb9@gutov.dev> Mime-Version: 1.0 Content-Type: multipart/mixed; boundary="=-=-=" Injection-Info: ciao.gmane.io; posting-host="blaine.gmane.org:116.202.254.214"; logging-data="40923"; mail-complaints-to="usenet@ciao.gmane.io" User-Agent: Gnus/5.13 (Gnus v5.13) Cc: Spencer Baugh , Eli Zaretskii , Juri Linkov , 71823@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 Sun Jun 30 14:52:13 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 1sNu2O-000APv-LB for geb-bug-gnu-emacs@m.gmane-mx.org; Sun, 30 Jun 2024 14:52:13 +0200 Original-Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1sNu2H-0008A0-Cb; Sun, 30 Jun 2024 08:52:05 -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 1sNu2E-00089g-DM for bug-gnu-emacs@gnu.org; Sun, 30 Jun 2024 08:52:02 -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 1sNu2E-0001BQ-4z for bug-gnu-emacs@gnu.org; Sun, 30 Jun 2024 08:52:02 -0400 Original-Received: from Debian-debbugs by debbugs.gnu.org with local (Exim 4.84_2) (envelope-from ) id 1sNu2D-0002Kh-Rd for bug-gnu-emacs@gnu.org; Sun, 30 Jun 2024 08:52:01 -0400 X-Loop: help-debbugs@gnu.org Resent-From: sbaugh@catern.com Original-Sender: "Debbugs-submit" Resent-CC: bug-gnu-emacs@gnu.org Resent-Date: Sun, 30 Jun 2024 12:52:01 +0000 Resent-Message-ID: Resent-Sender: help-debbugs@gnu.org X-GNU-PR-Message: followup 71823 X-GNU-PR-Package: emacs Original-Received: via spool by 71823-submit@debbugs.gnu.org id=B71823.17197518948927 (code B ref 71823); Sun, 30 Jun 2024 12:52:01 +0000 Original-Received: (at 71823) by debbugs.gnu.org; 30 Jun 2024 12:51:34 +0000 Original-Received: from localhost ([127.0.0.1]:55865 helo=debbugs.gnu.org) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1sNu1l-0002Jv-OO for submit@debbugs.gnu.org; Sun, 30 Jun 2024 08:51:34 -0400 Original-Received: from s.wrqvtzvf.outbound-mail.sendgrid.net ([149.72.126.143]:57566) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1sNu1j-0002Jg-FG for 71823@debbugs.gnu.org; Sun, 30 Jun 2024 08:51:32 -0400 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=catern.com; h=from:subject:in-reply-to:references:mime-version:to:cc:content-type: cc:content-type:from:subject:to; s=s1; bh=VGx8NawPRCJepuLxL7n+AcmDO1f1/jRNJ3VaijX4tVs=; b=JG17Z+nmvFPX8VEDSH/rOxAnBtoLCpm1z8YtY3jkMc6lorc5HxuoMQjtS4YlOrEzmWL0 fk2t7+nlGAaIauQUjlmuex/dZ3Ik8LH/0KPZi4H1HvaWDLj4LRWVrSUmRb3R2EyWLw5MF+ RkOdxRJUAfGLPsVcCW3LTsWLLeyAUYvOSiydc2y5bsNDFeDnaICEaz2VDtPBxfHO+OiSgl TQkWlyrmidqGErW3ksDNFac+qNnaqFzF8gbBMnroZq6pOqtHznPW8+P+IwYxrqBO5KaXYw l3IussQIz6h8ZAW34JBj3NfDUw/fOPyjVgalWkWUU+s9gfGRlDUOAwFvauTgLydQ== Original-Received: by recvd-65946f9675-tqqhf with SMTP id recvd-65946f9675-tqqhf-1-668154CD-8 2024-06-30 12:51:25.756906222 +0000 UTC m=+243851.569972294 Original-Received: from earth.catern.com (unknown) by geopod-ismtpd-18 (SG) with ESMTP id e9RDq-tbRp-oBdWLro9dBA Sun, 30 Jun 2024 12:51:25.652 +0000 (UTC) X-Comment: SPF check N/A for local connections - client-ip=127.0.0.1; helo=localhost; envelope-from=sbaugh@catern.com; receiver=gmail.com Original-Received: from localhost (localhost [127.0.0.1]) by earth.catern.com (Postfix) with ESMTPSA id 2050162505; Sun, 30 Jun 2024 08:51:25 -0400 (EDT) In-Reply-To: ("=?UTF-8?Q?Jo=C3=A3o_?= =?UTF-8?Q?T=C3=A1vora?="'s message of "Sun, 30 Jun 2024 01:25:32 +0100") X-SG-EID: u001.v6RTqHFpv1T6krEot6UFAVAJmQ+4h1t8/TfqqE2B07PW6Nx04XuXMBWO3BsENpYtxy+vwKol+P1x86hHTzt7kESju5apyxR6klwmovNP0Zh1tS6XYT00LREuywHha2zhm51UPsie8RiVEcaVdezNRIeh+bCDAgYNaP7RQztOW/GVSBp0VZXazjugZ4rRWWXfbFxSEnavyUrcnGbCAITNhg== X-Entity-ID: u001.oW4JupFKOzCccZAQN2OOFQ== 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:288190 Archived-At: --=-=-= Content-Type: text/plain; charset=iso-8859-1 Content-Transfer-Encoding: quoted-printable Jo=E3o T=E1vora writes: > On Sat, Jun 29, 2024, 15:24 Spencer Baugh wrote: > > Or, here's an alternative idea, more aggressive: > > What if Eglot just sets project-mode-line=3Dt in eglot-managed buffers, = and removes the project-name from the Eglot entry > entirely? > > Then the language identifier would be the major mode, the project identi= fier would be project-mode-line, and the eglot status > indicator would just be for the status of the server. > > Works for me, it's in line with Eglot's policy of setting other modes whe= n managing buffers. Show a patch.=20 Attached. I do think this is a great way to resolve this - now that project-mode-line exists, using it deletes one small bit of eglot-specific functionality, which is in line with the Eglot design philosophy. The only issue is that this was only added to mode-line-format in Emacs 30, so we can only use it in Emacs 30 or later. The attached patch detects that with: + (when (member '(project-mode-line project-mode-line-format) mode-line-= format) but I'm also totally fine with: + (when (version<=3D "30" emacs-version) Or I guess we could sidestep the issue if project.el itself ensured, when loaded, that mode-line-format contains project-mode-line. eglot itself does this with eglot--mode-line-format, running the following at load time: (add-to-list 'mode-line-misc-info `(eglot--managed-mode (" [" eglot--mode-line-format "] "))) Juri, any opinion? > But also, my idea of eglot-mode-line-format should be alsoh considered. A= FAICT there no big technical hurdle, it's just relatively > boring work and some naming decisions to make. And as I mentioned, it wou= ld fix more issues than just the one at hand. Yes, I think that would also be useful as a separate patch. --=-=-= Content-Type: text/x-diff; charset=utf-8 Content-Disposition: inline; filename=0001-Use-project-mode-line-for-the-project-nick-in-Eglot.patch Content-Transfer-Encoding: quoted-printable >From 5b53ecc3db2356bcab3fd8b9d8583de6a6adcef2 Mon Sep 17 00:00:00 2001 From: Spencer Baugh Date: Sun, 30 Jun 2024 08:27:43 -0400 Subject: [PATCH] Use project-mode-line for the project nick in Eglot The existence of project-mode-line now means that eglot can have an indicator for the current project of the current buffer, without using the eglot mode-line entry to do it. This commit teaches eglot to (when possible) set project-mode-line true in eglot-managed buffers and remove project-name from the eglot mode line entry. * lisp/progmodes/eglot.el (eglot--managed-mode): Set project-mode-line if the project-mode-line entry is in mode-line-format. (eglot-menu): Always include eglot-server-menu as a submenu. (eglot--mode-line-format): Don't include project-name when project-mode-line is set. (bug#71823) --- lisp/progmodes/eglot.el | 74 ++++++++++++++++++++++------------------- 1 file changed, 39 insertions(+), 35 deletions(-) diff --git a/lisp/progmodes/eglot.el b/lisp/progmodes/eglot.el index bb6b0281d9f..249dda7f3d8 100644 --- a/lisp/progmodes/eglot.el +++ b/lisp/progmodes/eglot.el @@ -7,7 +7,7 @@ ;; Maintainer: Jo=C3=A3o T=C3=A1vora ;; URL: https://github.com/joaotavora/eglot ;; Keywords: convenience, languages -;; Package-Requires: ((emacs "26.3") (compat "27.1") (eldoc "1.14.0") (ext= ernal-completion "0.1") (flymake "1.2.1") (jsonrpc "1.0.24") (project "0.9.= 8") (seq "2.23") (track-changes "1.2") (xref "1.6.2")) +;; Package-Requires: ((emacs "26.3") (compat "27.1") (eldoc "1.14.0") (ext= ernal-completion "0.1") (flymake "1.2.1") (jsonrpc "1.0.24") (project "0.11= .0") (seq "2.23") (track-changes "1.2") (xref "1.6.2")) =20 ;; This is a GNU ELPA :core package. Avoid adding functionality ;; that is not available in the version of Emacs recorded above or any @@ -2026,6 +2026,8 @@ eglot--managed-mode (eglot--setq-saving company-tooltip-align-annotations t) (eglot--setq-saving eldoc-documentation-strategy #'eldoc-documentation-compose) + (when (member '(project-mode-line project-mode-line-format) mode-line-= format) + (setq-local project-mode-line t)) (unless (eglot--stay-out-of-p 'imenu) (add-function :before-until (local 'imenu-create-index-function) #'eglot-imenu)) @@ -2161,10 +2163,24 @@ eglot-upgrade-eglot (package-delete existing t)) (package-install (cadr (assoc 'eglot package-archive-contents))))) =20 +(easy-menu-define eglot-server-menu nil "Monitor server communication" + '("Debugging the server communication" + ["Reconnect to server" eglot-reconnect] + ["Quit server" eglot-shutdown] + "--" + ["LSP events buffer" eglot-events-buffer] + ["Server stderr buffer" eglot-stderr-buffer] + ["Customize event buffer size" + (lambda () + (interactive) + (customize-variable 'eglot-events-buffer-size))])) + (easy-menu-define eglot-menu nil "Eglot" `("Eglot" ;; Commands for getting information and customization. ["Customize Eglot" (lambda () (interactive) (customize-group "eglot"))] + ["Server" eglot-server-menu + :active (eglot-current-server)] "--" ;; xref like commands. ["Find definitions" xref-find-definitions @@ -2211,18 +2227,6 @@ eglot-menu ["Quickfix" eglot-code-action-quickfix :visible (eglot-server-capable :codeActionProvider)])) =20 -(easy-menu-define eglot-server-menu nil "Monitor server communication" - '("Debugging the server communication" - ["Reconnect to server" eglot-reconnect] - ["Quit server" eglot-shutdown] - "--" - ["LSP events buffer" eglot-events-buffer] - ["Server stderr buffer" eglot-stderr-buffer] - ["Customize event buffer size" - (lambda () - (interactive) - (customize-variable 'eglot-events-buffer-size))])) - (defun eglot--mode-line-props (thing face defs &optional prepend) "Helper for function `eglot--mode-line-format'. Uses THING, FACE, DEFS and PREPEND." @@ -2252,7 +2256,7 @@ eglot--mode-line-format 'keymap (let ((map (make-sparse-keymap))) (define-key map [mode-line down-mouse-1] eglot-menu) map))) - (when nick + (when (and nick (not project-mode-line)) `(":" ,(propertize nick @@ -2261,28 +2265,28 @@ eglot--mode-line-format 'help-echo (format "Project '%s'\nmouse-1: LSP server control m= enu" nick) 'keymap (let ((map (make-sparse-keymap))) (define-key map [mode-line down-mouse-1] eglot-server= -menu) - map)) - ,@(when last-error - `("/" ,(eglot--mode-line-props - "error" 'compilation-mode-line-fail - '((mouse-3 eglot-clear-status "Clear this status")) - (format "An error occurred: %s\n" (plist-get last-err= or - :message= ))))) - ,@(when (cl-plusp pending) - `("/" ,(eglot--mode-line-props - (format "%d" pending) 'warning - '((mouse-3 eglot-forget-pending-continuations - "Forget pending continuations")) - "Number of outgoing, \ + map)))) + (when last-error + `("/" ,(eglot--mode-line-props + "error" 'compilation-mode-line-fail + '((mouse-3 eglot-clear-status "Clear this status")) + (format "An error occurred: %s\n" (plist-get last-error + :message))))) + (when (cl-plusp pending) + `("/" ,(eglot--mode-line-props + (format "%d" pending) 'warning + '((mouse-3 eglot-forget-pending-continuations + "Forget pending continuations")) + "Number of outgoing, \ still unanswered LSP requests to the server\n"))) - ,@(cl-loop for pr hash-values of (eglot--progress-reporters serve= r) - when (eq (car pr) 'eglot--mode-line-reporter) - append `("/" ,(eglot--mode-line-props - (format "%s%%%%" (or (nth 4 pr) "?")) - 'eglot-mode-line - nil - (format "(%s) %s %s" (nth 1 pr) - (nth 2 pr) (nth 3 pr)))))))))) + (cl-loop for pr hash-values of (eglot--progress-reporters server) + when (eq (car pr) 'eglot--mode-line-reporter) + append `("/" ,(eglot--mode-line-props + (format "%s%%%%" (or (nth 4 pr) "?")) + 'eglot-mode-line + nil + (format "(%s) %s %s" (nth 1 pr) + (nth 2 pr) (nth 3 pr)))))))) =20 (add-to-list 'mode-line-misc-info `(eglot--managed-mode (" [" eglot--mode-line-format "] "))) --=20 2.44.0 --=-=-=--