From: Spencer Baugh <sbaugh@janestreet.com>
To: 71823@debbugs.gnu.org
Subject: bug#71823: 31.0.50; project-mode-line and eglot duplicate project-name in mode-line
Date: Fri, 28 Jun 2024 10:15:45 -0400 [thread overview]
Message-ID: <ierjzi9qhke.fsf@janestreet.com> (raw)
In-Reply-To: <ierpls1nok0.fsf@igm-qws-u22796a.mail-host-address-is-not-set> (Spencer Baugh's message of "Fri, 28 Jun 2024 10:13:03 -0400")
[-- Attachment #1: Type: text/plain, Size: 21 bytes --]
Patch fixing this:
[-- Warning: decoded text below may be mangled, UTF-8 assumed --]
[-- Attachment #2: 0001-Skip-eglot-project-name-when-project-mode-line-t.patch --]
[-- Type: text/x-patch, Size: 2986 bytes --]
From 928101e122725866ee95172730ebff03f4d54d5a Mon Sep 17 00:00:00 2001
From: Spencer Baugh <sbaugh@janestreet.com>
Date: Fri, 28 Jun 2024 10:00:10 -0400
Subject: [PATCH] Skip eglot project-name when project-mode-line=t
Both the eglot mode line entry and project-mode-line add
project-name to the modeline. When both of them are enabled,
this is unnecessary duplication.
To fix, add the customization eglot-mode-line-project-name to
allow disabling the project-name in eglot's mode-line entry.
Furthermore, by default, set this customization so that eglot
will check project-mode-line and omit the project-name if
project-mode-line is non-nil. This allows a user to just set
project-mode-line without having to separately customize eglot.
* lisp/progmodes/eglot.el (eglot-mode-line-project-name): Add.
(eglot--mode-line-format): Check
eglot-mode-line-project-name. (bug#71823)
---
lisp/progmodes/eglot.el | 23 +++++++++++++++++++++--
1 file changed, 21 insertions(+), 2 deletions(-)
diff --git a/lisp/progmodes/eglot.el b/lisp/progmodes/eglot.el
index df4cbe50dc0..60e68b323f6 100644
--- a/lisp/progmodes/eglot.el
+++ b/lisp/progmodes/eglot.el
@@ -2237,10 +2237,29 @@ eglot--mode-line-props
keymap ,map help-echo ,(concat prepend blurb)
mouse-face mode-line-highlight))))
+(defcustom eglot-mode-line-project-name
+ (if (version< "30" emacs-version)
+ ;; The project mode-line entry was added to `mode-line-format' in
+ ;; Emacs 30; before that, `project-mode-line' has no effect.
+ 'unless-project-mode-line
+ nil)
+ "If non-nil, the eglot mode-line entry may contain `project-name'.
+
+If t, the eglot mode-line entry always contains `project-name'; if nil,
+it never contains `project-name'.
+
+If the symbol `unless-project-mode-line', the eglot mode-line entry only
+contains `project-name' if `project-mode-line' is nil. (This avoids
+showing `project-name' in the modeline twice.)")
+
(defun eglot--mode-line-format ()
"Compose Eglot's mode-line."
(let* ((server (eglot-current-server))
(nick (and server (eglot-project-nickname server)))
+ (use-nick (cl-case eglot-mode-line-project-name
+ (nil nil)
+ (unless-project-mode-line (not (bound-and-true-p project-mode-line)))
+ (t t)))
(pending (and server (jsonrpc-continuation-count server)))
(last-error (and server (jsonrpc-last-error server))))
(append
@@ -2253,9 +2272,9 @@ eglot--mode-line-format
(define-key map [mode-line down-mouse-1] eglot-menu)
map)))
(when nick
- `(":"
+ `(,(if use-nick ":" "")
,(propertize
- nick
+ (if use-nick nick ":")
'face 'eglot-mode-line
'mouse-face 'mode-line-highlight
'help-echo (format "Project '%s'\nmouse-1: LSP server control menu" nick)
--
2.39.3
next prev parent reply other threads:[~2024-06-28 14:15 UTC|newest]
Thread overview: 30+ messages / expand[flat|nested] mbox.gz Atom feed top
2024-06-28 14:13 bug#71823: 31.0.50; project-mode-line and eglot duplicate project-name in mode-line Spencer Baugh
2024-06-28 14:15 ` Spencer Baugh [this message]
2024-06-28 14:40 ` Eli Zaretskii
2024-06-28 17:49 ` João Távora
2024-06-28 22:08 ` Spencer Baugh
2024-06-29 7:12 ` Eli Zaretskii
2024-06-29 11:59 ` Dmitry Gutov
2024-06-29 12:43 ` Eli Zaretskii
2024-06-30 6:50 ` Juri Linkov
2024-06-30 10:25 ` João Távora
2024-06-29 12:05 ` João Távora
2024-06-29 12:17 ` Dmitry Gutov
2024-06-29 12:21 ` João Távora
2024-06-29 12:41 ` Spencer Baugh
2024-06-29 14:24 ` Spencer Baugh
2024-06-30 0:25 ` João Távora
2024-06-30 12:51 ` sbaugh
2024-06-30 14:53 ` João Távora
2024-06-30 15:05 ` João Távora
2024-07-03 13:17 ` Spencer Baugh
2024-07-03 13:59 ` João Távora
2024-07-03 14:47 ` Spencer Baugh
2024-07-03 14:57 ` João Távora
2024-07-03 15:12 ` Spencer Baugh
2024-07-03 16:03 ` João Távora
2024-07-03 17:10 ` sbaugh
2024-07-05 12:04 ` João Távora
2024-07-15 13:30 ` Spencer Baugh
2024-06-30 16:38 ` Juri Linkov
2024-07-03 13:00 ` Spencer Baugh
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
List information: https://www.gnu.org/software/emacs/
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=ierjzi9qhke.fsf@janestreet.com \
--to=sbaugh@janestreet.com \
--cc=71823@debbugs.gnu.org \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
Code repositories for project(s) associated with this public inbox
https://git.savannah.gnu.org/cgit/emacs.git
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).