[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
bug#71823: 31.0.50; project-mode-line and eglot duplicate project-name i
From: |
Spencer Baugh |
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 |
User-agent: |
Gnus/5.13 (Gnus v5.13) |
Patch fixing this:
>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
- bug#71823: 31.0.50; project-mode-line and eglot duplicate project-name in mode-line, Spencer Baugh, 2024/06/28
- bug#71823: 31.0.50; project-mode-line and eglot duplicate project-name in mode-line,
Spencer Baugh <=
- bug#71823: 31.0.50; project-mode-line and eglot duplicate project-name in mode-line, Eli Zaretskii, 2024/06/28
- bug#71823: 31.0.50; project-mode-line and eglot duplicate project-name in mode-line, João Távora, 2024/06/28
- bug#71823: 31.0.50; project-mode-line and eglot duplicate project-name in mode-line, Spencer Baugh, 2024/06/28
- bug#71823: 31.0.50; project-mode-line and eglot duplicate project-name in mode-line, Eli Zaretskii, 2024/06/29
- bug#71823: 31.0.50; project-mode-line and eglot duplicate project-name in mode-line, Dmitry Gutov, 2024/06/29
- bug#71823: 31.0.50; project-mode-line and eglot duplicate project-name in mode-line, Eli Zaretskii, 2024/06/29
- bug#71823: 31.0.50; project-mode-line and eglot duplicate project-name in mode-line, Juri Linkov, 2024/06/30
- bug#71823: 31.0.50; project-mode-line and eglot duplicate project-name in mode-line, João Távora, 2024/06/30
- bug#71823: 31.0.50; project-mode-line and eglot duplicate project-name in mode-line, João Távora, 2024/06/29
- bug#71823: 31.0.50; project-mode-line and eglot duplicate project-name in mode-line, Dmitry Gutov, 2024/06/29