Subject: Re: bug#78582: 30.1; which-key-mode overwrites custom key bindings

From: Eli Zaretskii <[email-masked]>
Date: Mon, 02 Jun 2025 10:26:12 +0300

> From: Gerd Möllmann <[email-masked]>
> Cc: Alex Murray <[email-masked]>,  Po Lu <[email-masked]>,
>   [email-masked]
> Date: Mon, 02 Jun 2025 05:49:14 +0200
> 
> Eli Zaretskii <[email-masked]> writes:
> 
> > Po Lu, any ideas why the PGTK build could show this strange behavior?
> 
> I encountered this on macOS today. Reproducer with an installed Emacs 
> (which is the Emacs.app on macOS):
> 
>   ~/Desktop/Emacs.app/Contents/MacOS/Emacs -q
> 
> In *scratch*, eval
> 
>  (global-set-key [f4] #'kill-current-buffer)
>  (documentation 'rectangle-mark-mode)
> 
> Then C-h k <f4> and observe that it has been redefined.

Not reproducible on my system with today's master branch.  When I
press "C-h k <f4>" after evaluating the above line by line, I get the
expected documentation of kill-current-buffer.

> A backtrace how this happens with which-key is at then end. In short,
> which-key calls 'documentation' which loads lisp/loaddefs which
> evaluates the global-set-keys loaddefs.el contains.

"M-x debug-on-entry RET global-set-key RET" doesn't pop up the
debugger when I evaluate "(documentation 'rectangle-mark-mode)".

Anyway, why would Emacs want to load loaddefs, when loaddefs is
preloaded?

> I have no idea how to fix this.

And I have no idea why this happens on some systems, but not on
others.