GNU bug report logs -
#71823
31.0.50; project-mode-line and eglot duplicate project-name in mode-line
Previous Next
Reported by: Spencer Baugh <sbaugh <at> janestreet.com>
Date: Fri, 28 Jun 2024 14:14:02 UTC
Severity: normal
Found in version 31.0.50
Done: João Távora <joaotavora <at> gmail.com>
Bug is archived. No further changes may be made.
Full log
Message #11 received at 71823 <at> debbugs.gnu.org (full text, mbox):
> From: Spencer Baugh <sbaugh <at> janestreet.com>
> Date: Fri, 28 Jun 2024 10:15:45 -0400
>
> >From 928101e122725866ee95172730ebff03f4d54d5a Mon Sep 17 00:00:00 2001
> From: Spencer Baugh <sbaugh <at> 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
João, any comments?
This bug report was last modified 117 days ago.
Previous Next
GNU bug tracking system
Copyright (C) 1999 Darren O. Benham,
1997,2003 nCipher Corporation Ltd,
1994-97 Ian Jackson.