Subject: bug#77118: 31.0.50; help-key-binding face in help buffer

From: Arash Esbati <[email-masked]>
Date: Wed, 19 Mar 2025 14:05:21 +0100

Hi all,

when I eval the following code:

--8<---------------cut here---------------start------------->8---
(let ((help-form (substitute-command-keys "\
Select with a key:
\\`h'   do this,
\\`k'   do that,
\\`RET' do nothing.")))
  (read-char-choice (substitute-command-keys
                     (format "\
This (\\`h'), That (\\`k'), Nothing (\\`RET'), Help (\\`%s'): "
                             (key-description (vector help-char))))
                    '(?h ?k ?\r)))
--8<---------------cut here---------------end--------------->8---

and do 'C-h', h, k and RET don't receive the help-key-binding face in
the help buffer which pops up.  What I see with 'emacs -Q' is attached.
Note the difference in the minibuffer.

The reason seems to be in the implementation of `help-form-show' using
`princ' which strips properties.  If this is intentional, it doesn't
match definitions of `help-form' in Emacs tree.  Take for example
dired-aux.el which pushes the string for `help-form' also through
`substitute-command-keys'[1,2,3].

In case this report is confirmed, a possible solution is provided
here[4].

Best, Arash

Footnotes:
[1]  https://git.savannah.gnu.org/cgit/emacs.git/tree/lisp/dired-aux.el#n2489
[2]  https://git.savannah.gnu.org/cgit/emacs.git/tree/lisp/dired-aux.el#n3091
[3]  https://git.savannah.gnu.org/cgit/emacs.git/tree/lisp/dired-aux.el#n3227
[4]  https://lists.gnu.org/archive/html/help-gnu-emacs/2025-03/msg00192.html

In GNU Emacs 31.0.50 (build 1, aarch64-apple-darwin24.3.0, NS
 appkit-2575.40 Version 15.3.2 (Build 24D81)) of 2025-03-17 built on
 MacMutant.local
Repository revision: acb96a5ca8ac3bef80ca2ff1496cacb3ab57c87a
Repository branch: master
Windowing system distributor 'Apple', version 10.3.2575
System Description:  macOS 15.3.2

Configured using:
 'configure --with-ns --with-threads --with-modules
 --with-native-compilation --without-compress-install --without-harfbuzz
 --without-mailutils --without-pop 'CFLAGS=-O2 -g0 -pipe '
 'CPPFLAGS=-I/opt/homebrew/Cellar/gcc/14.2.0_1/include
 -I/opt/homebrew/Cellar/libgccjit/14.2.0_1/include
 -I/opt/homebrew/Cellar/gmp/6.3.0/include
 -I/opt/homebrew/Cellar/libxml2/2.13.6_1/include '
 'LDFLAGS=-L/opt/homebrew/Cellar/gcc/14.2.0_1/lib/gcc/current
 -L/opt/homebrew/Cellar/gmp/6.3.0/lib
 -L/opt/homebrew/Cellar/libxml2/2.13.6_1/lib ''