all messages for Emacs-related lists mirrored at yhetil.org
 help / color / mirror / code / Atom feed
* bug#67609: 29.1; (eglot-inlay-hints-mode -1) behaves surprisingly, does not work in cc-mode hooks
@ 2023-12-03 18:28 Morgon Kanter
  2023-12-03 18:52 ` João Távora
  0 siblings, 1 reply; 8+ messages in thread
From: Morgon Kanter @ 2023-12-03 18:28 UTC (permalink / raw)
  To: 67609

eglot-inlay-hints-mode seems to always turn on, at least in cc-mode, even
when explicitly disabled by a hook, leaving me to disable it once the
buffer is loaded. For example, this is my config:

(defun config:cc-defaults ()
  (c-toggle-comment-style 1)
  (subword-mode 1)
  (diminish 'subword-mode)
  (local-set-key (kbd "C-M-S-<backspace>") #'kill-outer-sexp-and-parens)
  ;; Run eglot if we're under a project.
  (when (project-current)
    (eglot-ensure)
    (eglot-inlay-hints-mode -1)))
(add-hook 'c-mode-common-hook #'config:cc-defaults)

This will, when visiting a C++ file for the first time, turn on eglot.
Then it should also turn *off* the inlay-hints mode, but it does not.
The inlay hints appear until I manually run eglot-inlay-hints-mode.

This behavior appears even if I change the above configuration to remove
the eglot-ensure portion, and simply run (eglot-inlay-hints-mode -1)
unconditionally in the hook. They will still appear, and I still have to
run it manually to turn it off.

This behavior is, I think, different from most other mode configurations
throughout Emacs which can be set up and torn down in hooks.


In GNU Emacs 29.1 (build 1, x86_64-pc-linux-gnu, GTK+ Version 3.24.38,
cairo version 1.17.8)
Windowing system distributor 'Microsoft Corporation', version 11.0.12010000
System Description: Arch Linux

Configured using:
 'configure --with-x-toolkit=gtk3 --with-native-compilation=aot
 --sysconfdir=/etc --prefix=/usr --libexecdir=/usr/lib
 --with-tree-sitter --localstatedir=/var --with-cairo
 --disable-build-details --with-harfbuzz --with-libsystemd
 --with-modules 'CFLAGS=-march=x86-64 -mtune=generic -O2 -pipe -fno-plt
 -fexceptions -Wp,-D_FORTIFY_SOURCE=2 -Wformat -Werror=format-security
 -fstack-clash-protection -fcf-protection -g
 -ffile-prefix-map=/build/emacs/src=/usr/src/debug/emacs -flto=auto'
 'LDFLAGS=-Wl,-O1,--sort-common,--as-needed,-z,relro,-z,now -flto=auto'
 'CXXFLAGS=-march=x86-64 -mtune=generic -O2 -pipe -fno-plt -fexceptions
 -Wp,-D_FORTIFY_SOURCE=2 -Wformat -Werror=format-security
 -fstack-clash-protection -fcf-protection -Wp,-D_GLIBCXX_ASSERTIONS -g
 -ffile-prefix-map=/build/emacs/src=/usr/src/debug/emacs -flto=auto''

Configured features:
ACL CAIRO DBUS FREETYPE GIF GLIB GMP GNUTLS GPM GSETTINGS HARFBUZZ JPEG
JSON LCMS2 LIBOTF LIBSYSTEMD LIBXML2 M17N_FLT MODULES NATIVE_COMP NOTIFY
INOTIFY PDUMPER PNG RSVG SECCOMP SOUND SQLITE3 THREADS TIFF
TOOLKIT_SCROLL_BARS TREE_SITTER WEBP X11 XDBE XIM XINPUT2 XPM GTK3 ZLIB

Important settings:
  value of $LANG: en_US.UTF-8
  locale-coding-system: utf-8-unix

Major mode: ELisp/d

Minor modes in effect:
  global-git-commit-mode: t
  magit-auto-revert-mode: t
  shell-dirtrack-mode: t
  marginalia-mode: t
  override-global-mode: t
  vertico-mode: t
  which-key-mode: t
  server-mode: t
  global-eldoc-mode: t
  eldoc-mode: t
  show-paren-mode: t
  electric-indent-mode: t
  mouse-wheel-mode: t
  menu-bar-mode: t
  file-name-shadow-mode: t
  global-font-lock-mode: t
  font-lock-mode: t
  blink-cursor-mode: t
  column-number-mode: t
  line-number-mode: t
  transient-mark-mode: t
  auto-composition-mode: t
  auto-encryption-mode: t
  auto-compression-mode: t

Load-path shadows:
/home/surgo/.emacs.d/elpa/transient-20231103.2312/transient hides
/usr/share/emacs/29.1/lisp/transient
/home/surgo/.emacs.d/elpa/seq-2.24/seq hides
/usr/share/emacs/29.1/lisp/emacs-lisp/seq

Features:
(shadow sort mail-extr emacsbug misearch multi-isearch eglot
external-completion array jsonrpc ert pp ewoc debug backtrace find-func
xref flymake-proc flymake thingatpt compile project mule-util vc-git
vc-dispatcher cap-words superword subword cc-mode cc-fonts cc-guess
cc-menus cc-cmds cc-styles cc-align cc-engine cc-vars cc-defs
magit-submodule magit-blame magit-stash magit-reflog magit-bisect
magit-push magit-pull magit-fetch magit-clone magit-remote magit-commit
magit-sequence magit-notes magit-worktree magit-tag magit-merge
magit-branch magit-reset magit-files magit-refs magit-status magit
magit-repos magit-apply magit-wip magit-log which-func imenu magit-diff
smerge-mode diff diff-mode git-commit log-edit message sendmail
yank-media puny dired dired-loaddefs rfc822 mml mml-sec epa derived epg
rfc6068 epg-config gnus-util text-property-search time-date mm-decode
mm-bodies mm-encode mail-parse rfc2231 rfc2047 rfc2045 mm-util
ietf-drums mail-prsvr mailabbrev mail-utils gmm-utils mailheader
pcvs-util add-log magit-core magit-autorevert autorevert filenotify
magit-margin magit-transient magit-process with-editor comp comp-cstr
warnings icons rx shell pcomplete comint ansi-osc ring ansi-color
magit-mode transient magit-git magit-base magit-section format-spec
cursor-sensor crm dash marginalia edmacro kmacro use-package-bind-key
bind-key easy-mmode vertico compat diminish which-key cl-extra help-mode
use-package-diminish use-package-core tango-dark-theme server
magit-autoloads pcase git-commit-autoloads magit-section-autoloads
dash-autoloads marginalia-autoloads projectile-autoloads
transient-autoloads vertico-autoloads with-editor-autoloads info
compat-autoloads seq-autoloads package browse-url url url-proxy
url-privacy url-expand url-methods url-history url-cookie
generate-lisp-file url-domsuf url-util mailcap url-handlers url-parse
auth-source cl-seq eieio eieio-core cl-macs password-cache json subr-x
map byte-opt gv bytecomp byte-compile url-vars cl-loaddefs cl-lib rmc
iso-transl tooltip cconv eldoc paren electric uniquify ediff-hook
vc-hooks lisp-float-type elisp-mode mwheel term/x-win x-win
term/common-win x-dnd tool-bar dnd fontset image regexp-opt fringe
tabulated-list replace newcomment text-mode lisp-mode prog-mode register
page tab-bar menu-bar rfn-eshadow isearch easymenu timer select
scroll-bar mouse jit-lock font-lock syntax font-core term/tty-colors
frame minibuffer nadvice seq simple cl-generic indonesian philippine
cham georgian utf-8-lang misc-lang vietnamese tibetan thai tai-viet lao
korean japanese eucjp-ms cp51932 hebrew greek romanian slovak czech
european ethiopic indian cyrillic chinese composite emoji-zwj charscript
charprop case-table epa-hook jka-cmpr-hook help abbrev obarray oclosure
cl-preloaded button loaddefs theme-loaddefs faces cus-face macroexp
files window text-properties overlay sha1 md5 base64 format env
code-pages mule custom widget keymap hashtable-print-readable backquote
threads dbusbind inotify lcms2 dynamic-setting system-font-setting
font-render-setting cairo move-toolbar gtk x-toolkit xinput2 x multi-tty
make-network-process native-compile emacs)

Memory information:
((conses 16 262393 20795)
 (symbols 48 19979 3)
 (strings 32 68186 1843)
 (string-bytes 1 2926233)
 (vectors 16 46984)
 (vector-slots 8 840297 27324)
 (floats 8 117 317)
 (intervals 56 941 111)
 (buffers 984 17))





^ permalink raw reply	[flat|nested] 8+ messages in thread

* bug#67609: 29.1; (eglot-inlay-hints-mode -1) behaves surprisingly, does not work in cc-mode hooks
  2023-12-03 18:28 bug#67609: 29.1; (eglot-inlay-hints-mode -1) behaves surprisingly, does not work in cc-mode hooks Morgon Kanter
@ 2023-12-03 18:52 ` João Távora
  2023-12-03 19:02   ` Morgon Kanter
  0 siblings, 1 reply; 8+ messages in thread
From: João Távora @ 2023-12-03 18:52 UTC (permalink / raw)
  To: Morgon Kanter; +Cc: 67609

On Sun, Dec 3, 2023 at 6:35 PM Morgon Kanter <morgon.kanter@gmail.com> wrote:
>
> eglot-inlay-hints-mode seems to always turn on, at least in cc-mode, even
> when explicitly disabled by a hook, leaving me to disable it once the
> buffer is loaded. For example, this is my config:
>
> (defun config:cc-defaults ()
>   (c-toggle-comment-style 1)
>   (subword-mode 1)
>   (diminish 'subword-mode)
>   (local-set-key (kbd "C-M-S-<backspace>") #'kill-outer-sexp-and-parens)
>   ;; Run eglot if we're under a project.
>   (when (project-current)
>     (eglot-ensure)
>     (eglot-inlay-hints-mode -1)))
> (add-hook 'c-mode-common-hook #'config:cc-defaults)

Hi.  Because you're using 'eglot-ensure' (hint, maybe you
shoudn't, read the manual in the latest master for why)
it means that after the eglot-ensure form executes,
Eglot will not be setup yet, so the following form
has no effect.  You need to replace it with

  (add-hook 'eglot-managed-mode-hook (lambda ()
(eglot-inlay-hints-mode -1)) nil t)

So that when Eglot does start up, it knows to disable
inlay hints.

You may add the above line globally (with the trailing 'nil t') if
you never want inlay hints to be enabled automatically in any
mode or language server.

And see also eglot-ignored-server-capabilities and add consider
:inlayHintProvider to it if you don't even ever want to enable
it manually.

João





^ permalink raw reply	[flat|nested] 8+ messages in thread

* bug#67609: 29.1; (eglot-inlay-hints-mode -1) behaves surprisingly, does not work in cc-mode hooks
  2023-12-03 18:52 ` João Távora
@ 2023-12-03 19:02   ` Morgon Kanter
  2023-12-03 19:23     ` João Távora
  0 siblings, 1 reply; 8+ messages in thread
From: Morgon Kanter @ 2023-12-03 19:02 UTC (permalink / raw)
  To: João Távora; +Cc: 67609

Hi João,

> Hi.  Because you're using 'eglot-ensure' (hint, maybe you
> shoudn't, read the manual in the latest master for why)
> it means that after the eglot-ensure form executes,
> Eglot will not be setup yet, so the following form
> has no effect.  You need to replace it with [snip]

I believe there is more to the story than this. I can remove the
eglot-ensure, load eglot so eglot-inlay-hints-mode is a valid symbol,
and replace my config with this:

(defun config:cc-defaults ()
  ;(setq c-require-final-newline t)  ;; lol causes errors in cc-mode
  (c-toggle-comment-style 1)
  (subword-mode 1)
  (diminish 'subword-mode)
  (local-set-key (kbd "C-M-S-<backspace>") #'kill-outer-sexp-and-parens)
  (eglot-inlay-hints-mode -1))

...and I will receive the same behavior. The eglot-ensure here is a red herring.

To reproduce, visit a C++ buffer in a project, run M-x eglot. Inlay
hints will appear. Kill and reopen the buffer. Inlay hints will
appear.

-- Morgon





^ permalink raw reply	[flat|nested] 8+ messages in thread

* bug#67609: 29.1; (eglot-inlay-hints-mode -1) behaves surprisingly, does not work in cc-mode hooks
  2023-12-03 19:02   ` Morgon Kanter
@ 2023-12-03 19:23     ` João Távora
  2023-12-03 19:37       ` Morgon Kanter
  0 siblings, 1 reply; 8+ messages in thread
From: João Távora @ 2023-12-03 19:23 UTC (permalink / raw)
  To: Morgon Kanter; +Cc: 67609

On Sun, Dec 3, 2023 at 7:02 PM Morgon Kanter <morgon.kanter@gmail.com> wrote:

> (defun config:cc-defaults ()
>   ;(setq c-require-final-newline t)  ;; lol causes errors in cc-mode
>   (c-toggle-comment-style 1)
>   (subword-mode 1)
>   (diminish 'subword-mode)
>   (local-set-key (kbd "C-M-S-<backspace>") #'kill-outer-sexp-and-parens)
>   (eglot-inlay-hints-mode -1))
>
> ...and I will receive the same behavior. The eglot-ensure here is a red herring.

I never said this would work either.  It's not a red herring
in the sense that you shouldn't expect eglot-ensure to have
loaded eglot in the buffer after the form has finished.

And you shouldn't expect (eglot-inlay-hints-mode -1) to have
any effect before Eglot is loaded, which obviously does not
happen in the absence of any Eglot-related command as you show here.

So, this doesn't add anything to the story.

> To reproduce, visit a C++ buffer in a project, run M-x eglot. Inlay
> hints will appear. Kill and reopen the buffer. Inlay hints will
> appear.

To achieve your desired behaviour, read my advice in the last email,
thanks.

João





^ permalink raw reply	[flat|nested] 8+ messages in thread

* bug#67609: 29.1; (eglot-inlay-hints-mode -1) behaves surprisingly, does not work in cc-mode hooks
  2023-12-03 19:23     ` João Távora
@ 2023-12-03 19:37       ` Morgon Kanter
  2023-12-03 20:38         ` João Távora
  2023-12-16  9:31         ` Eli Zaretskii
  0 siblings, 2 replies; 8+ messages in thread
From: Morgon Kanter @ 2023-12-03 19:37 UTC (permalink / raw)
  To: João Távora; +Cc: 67609

> > To reproduce, visit a C++ buffer in a project, run M-x eglot. Inlay
> > hints will appear. Kill and reopen the buffer. Inlay hints will
> > appear.
>
> To achieve your desired behaviour, read my advice in the last email,
> thanks.

Fair enough. I understand now that the correct and expected way to
disable this is the way you have described. Since the behavior appears
surprising though, and it looks like the only such eglot-related mode
command is eglot-inlay-hints-mode, could something like this quote be
added to the manual for eglot-inlay-hints-mode?

"Eglot will turn on eglot-inlay-hints-mode after setting up, which
happens after most mode hooks are run. To disable it, you should run
(eglot-inlay-hints-mode -1) in eglot-managed-mode-hook, rather than
your buffer's major mode hooks."

This should hopefully stop bug reports like mine in the future.

Thanks,
-- Morgon





^ permalink raw reply	[flat|nested] 8+ messages in thread

* bug#67609: 29.1; (eglot-inlay-hints-mode -1) behaves surprisingly, does not work in cc-mode hooks
  2023-12-03 19:37       ` Morgon Kanter
@ 2023-12-03 20:38         ` João Távora
  2023-12-16  9:31         ` Eli Zaretskii
  1 sibling, 0 replies; 8+ messages in thread
From: João Távora @ 2023-12-03 20:38 UTC (permalink / raw)
  To: Morgon Kanter; +Cc: 67609

On Sun, Dec 3, 2023 at 7:37 PM Morgon Kanter <morgon.kanter@gmail.com> wrote:

> This should hopefully stop bug reports like mine in the future.

Yours is the first such bug here I can remember, maybe because
googling for "turn off eglot-inlay-hints-mode" lands you on a
Reddit page with the eglot-managed-mode-hook information.

Maybe I can update the manual, but it already says Eglot turns all
supported LSP features by default .  And it should come at no suprise
that eglot-inlay-hints-mode, listed under "Eglot commands", only works
if Eglot is active.  Eglot is presented as minor mode and
eglot-managed-mode-hook is described in sufficient detail.





^ permalink raw reply	[flat|nested] 8+ messages in thread

* bug#67609: 29.1; (eglot-inlay-hints-mode -1) behaves surprisingly, does not work in cc-mode hooks
  2023-12-03 19:37       ` Morgon Kanter
  2023-12-03 20:38         ` João Távora
@ 2023-12-16  9:31         ` Eli Zaretskii
  2023-12-16 11:55           ` João Távora
  1 sibling, 1 reply; 8+ messages in thread
From: Eli Zaretskii @ 2023-12-16  9:31 UTC (permalink / raw)
  To: Morgon Kanter; +Cc: joaotavora, 67609

> Cc: 67609@debbugs.gnu.org
> From: Morgon Kanter <morgon.kanter@gmail.com>
> Date: Sun, 3 Dec 2023 14:37:42 -0500
> 
> > > To reproduce, visit a C++ buffer in a project, run M-x eglot. Inlay
> > > hints will appear. Kill and reopen the buffer. Inlay hints will
> > > appear.
> >
> > To achieve your desired behaviour, read my advice in the last email,
> > thanks.
> 
> Fair enough. I understand now that the correct and expected way to
> disable this is the way you have described. Since the behavior appears
> surprising though, and it looks like the only such eglot-related mode
> command is eglot-inlay-hints-mode, could something like this quote be
> added to the manual for eglot-inlay-hints-mode?
> 
> "Eglot will turn on eglot-inlay-hints-mode after setting up, which
> happens after most mode hooks are run. To disable it, you should run
> (eglot-inlay-hints-mode -1) in eglot-managed-mode-hook, rather than
> your buffer's major mode hooks."
> 
> This should hopefully stop bug reports like mine in the future.

João, do we need to do anything here, or can this be closed now?





^ permalink raw reply	[flat|nested] 8+ messages in thread

* bug#67609: 29.1; (eglot-inlay-hints-mode -1) behaves surprisingly, does not work in cc-mode hooks
  2023-12-16  9:31         ` Eli Zaretskii
@ 2023-12-16 11:55           ` João Távora
  0 siblings, 0 replies; 8+ messages in thread
From: João Távora @ 2023-12-16 11:55 UTC (permalink / raw)
  To: Eli Zaretskii; +Cc: 67609, Morgon Kanter

[-- Attachment #1: Type: text/plain, Size: 1589 bytes --]

On Sat, Dec 16, 2023, 09:32 Eli Zaretskii <eliz@gnu.org> wrote:

> > Cc: 67609@debbugs.gnu.org
> > From: Morgon Kanter <morgon.kanter@gmail.com>
> > Date: Sun, 3 Dec 2023 14:37:42 -0500
> >
> > > > To reproduce, visit a C++ buffer in a project, run M-x eglot. Inlay
> > > > hints will appear. Kill and reopen the buffer. Inlay hints will
> > > > appear.
> > >
> > > To achieve your desired behaviour, read my advice in the last email,
> > > thanks.
> >
> > Fair enough. I understand now that the correct and expected way to
> > disable this is the way you have described. Since the behavior appears
> > surprising though, and it looks like the only such eglot-related mode
> > command is eglot-inlay-hints-mode, could something like this quote be
> > added to the manual for eglot-inlay-hints-mode?
> >
> > "Eglot will turn on eglot-inlay-hints-mode after setting up, which
> > happens after most mode hooks are run. To disable it, you should run
> > (eglot-inlay-hints-mode -1) in eglot-managed-mode-hook, rather than
> > your buffer's major mode hooks."
> >
> > This should hopefully stop bug reports like mine in the future.
>
> João, do we need to do anything here, or can this be closed now?
>

I mean to add something to the manual  (though not specifically for inlay
hints) that will help users connect the pieces of this puzzle more easily,
the there pieces being.

Eglot generally turns all supported things on by default
Eglot has a minor mode with a hook
Eglot functions called from lisp have no effect outside the minor mode.

João

>

[-- Attachment #2: Type: text/html, Size: 2561 bytes --]

^ permalink raw reply	[flat|nested] 8+ messages in thread

end of thread, other threads:[~2023-12-16 11:55 UTC | newest]

Thread overview: 8+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2023-12-03 18:28 bug#67609: 29.1; (eglot-inlay-hints-mode -1) behaves surprisingly, does not work in cc-mode hooks Morgon Kanter
2023-12-03 18:52 ` João Távora
2023-12-03 19:02   ` Morgon Kanter
2023-12-03 19:23     ` João Távora
2023-12-03 19:37       ` Morgon Kanter
2023-12-03 20:38         ` João Távora
2023-12-16  9:31         ` Eli Zaretskii
2023-12-16 11:55           ` João Távora

Code repositories for project(s) associated with this external index

	https://git.savannah.gnu.org/cgit/emacs.git
	https://git.savannah.gnu.org/cgit/emacs/org-mode.git

This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.