Subject: bug#67609: 29.1; (eglot-inlay-hints-mode -1) behaves surprisingly, does not work in cc-mode hooks

From: Morgon Kanter <[email-masked]>
Date: Sun, 3 Dec 2023 13:28:36 -0500

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))