Subject: bug#54932: 28.1; electric-help doesn't work when `help-char' has meta-prefix

From: Nobuyoshi Nakada <[email-masked]>
Date: Thu, 14 Apr 2022 18:04:18 +0900

Hello,

As I set `help-char' to `\M-H' to use the default `\C-h' as
`delete-backward-cahr', `(char-to-string help-char)' in the definition
of `electric-help-map' fails by `(wrong-type-argument characterp
134217800)'.

A proposal patch is attached.

Regards.

In GNU Emacs 28.1 (build 1, x86_64-apple-darwin21.4.0, Carbon Version 
165 AppKit 2113.4)
of 2022-04-12 built on ruby3.local
Windowing system distributor 'Apple Inc.', version 12.3.1
System Description: macOS 12.3.1

Configured using:
'configure --prefix=/opt/local --disable-silent-rules --with-mac
--enable-mac-app=/opt/local/var/macports/build/_opt_local_var_macports_sources_rsync.macports.org_macports_release_tarballs_ports_aqua_emacs-mac-app/emacs-mac-app/work/emacs-28.1-mac-9.0 

--enable-mac-self-contained --without-dbus --without-gconf
--without-libotf --without-m17n-flt --without-harfbuzz --without-xaw3d
--with-libgmp --with-gnutls --with-xml2 --with-json --with-lcms2
--with-modules --with-rsvg --with-imagemagick --with-native-compilation
'CFLAGS=-pipe -Os -fobjc-arc
-isysroot/Library/Developer/CommandLineTools/SDKs/MacOSX12.sdk -arch
x86_64' 'CPPFLAGS=-I/opt/local/include
-isysroot/Library/Developer/CommandLineTools/SDKs/MacOSX12.sdk'
'LDFLAGS=-L/opt/local/lib -Wl,-headerpad_max_install_names
-Wl,-syslibroot,/Library/Developer/CommandLineTools/SDKs/MacOSX12.sdk
-arch x86_64''

Configured features:
ACL GLIB GMP GNUTLS IMAGEMAGICK JSON LCMS2 LIBXML2 MODULES NATIVE_COMP
NOTIFY KQUEUE PDUMPER RSVG THREADS TOOLKIT_SCROLL_BARS XIM ZLIB

Important settings:
value of $LANG: ja_JP.UTF-8
locale-coding-system: utf-8-hfs

Major mode: ELisp/l

Minor modes in effect:
shell-dirtrack-mode: t
global-hl-line-mode: t
global-auto-revert-mode: t
display-time-mode: t
linum-mode: t
tooltip-mode: t
global-eldoc-mode: t
eldoc-mode: t
show-paren-mode: t
electric-indent-mode: t
mac-mouse-wheel-mode: t
mac-auto-ascii-mode: t
tool-bar-mode: t
menu-bar-mode: t
file-name-shadow-mode: t
global-font-lock-mode: t
font-lock-mode: t
blink-cursor-mode: t
auto-composition-mode: t
auto-encryption-mode: t
auto-compression-mode: t
size-indication-mode: t
column-number-mode: t
line-number-mode: t
indent-tabs-mode: t
transient-mark-mode: t

Load-path shadows:
/Users/nobu/.elisp/markdown-mode hides 
/Users/nobu/.emacs.d/elpa/markdown-mode-20210616.122/markdown-mode
/Users/nobu/.elisp/custom hides 
/Applications/MacPorts/EmacsMac.app/Contents/Resources/lisp/custom
/Users/nobu/.elisp/linum hides 
/Applications/MacPorts/EmacsMac.app/Contents/Resources/lisp/linum
/Users/nobu/.emacs.d/elpa/transient-20220412.1523/transient hides 
/Applications/MacPorts/EmacsMac.app/Contents/Resources/lisp/transient
/Users/nobu/.elisp/tempo hides 
/Applications/MacPorts/EmacsMac.app/Contents/Resources/lisp/tempo
/Users/nobu/.elisp/fill hides 
/Applications/MacPorts/EmacsMac.app/Contents/Resources/lisp/textmodes/fill
/Users/nobu/.elisp/cperl-mode hides 
/Applications/MacPorts/EmacsMac.app/Contents/Resources/lisp/progmodes/cperl-mode
/Users/nobu/.elisp/browse-url hides 
/Applications/MacPorts/EmacsMac.app/Contents/Resources/lisp/net/browse-url
/Users/nobu/.elisp/japanese hides 
/Applications/MacPorts/EmacsMac.app/Contents/Resources/lisp/language/japanese

Features:
(shadow sort mail-extr emacsbug message rmc puny rfc822 mml mml-sec epa
derived epg rfc6068 epg-config gnus-util rmail rmail-loaddefs mm-decode
mm-bodies mm-encode mail-parse rfc2231 mailabbrev gmm-utils mailheader
sendmail rfc2047 rfc2045 ietf-drums mm-util mail-prsvr mail-utils view
ehelp dabbrev pp edebug eieio-opt speedbar ezimage dframe shortdoc
text-property-search time-date misearch multi-isearch vc-filewise vc-rcs
help-fns radix-tree cl-print debug backtrace find-func cus-start eshell
esh-cmd esh-ext esh-opt esh-proc esh-io esh-arg esh-module esh-groups
esh-util dired dired-loaddefs shell pcomplete comint ring pcase
ansi-color magit-mode transient magit-git magit-base magit-section
format-spec crm dash jka-compr whitespace hl-line autorevert filenotify
time cus-load edmacro kmacro multiple-cursors mc-separate-operations
rectangular-region-mode mc-mark-pop mc-edit-lines
mc-hide-unmatched-lines-mode mc-mark-more thingatpt mc-cycle-cursors
multiple-cursors-core comp comp-cstr warnings rx cl-extra help-mode
advice rect ucs-normalize server mmm-erb mmm-region mmm-auto mmm-vars
mmm-utils mmm-compat sgml-mode facemenu dom region-command
ruby-additional ruby-mode smie linum easy-mmode ruby-style cc-styles
cc-align cc-engine cc-vars cc-defs executable finder-inf info package
browse-url url url-proxy url-privacy url-expand url-methods url-history
url-cookie url-domsuf url-util mailcap url-handlers url-parse
auth-source cl-seq eieio eieio-core cl-macs eieio-loaddefs
password-cache json subr-x map url-vars seq byte-opt gv bytecomp
byte-compile cconv cl-loaddefs cl-lib japan-util iso-transl tooltip
eldoc paren electric uniquify ediff-hook vc-hooks lisp-float-type
elisp-mode mwheel term/mac-win mac-win term/common-win 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 cl-generic 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 simple abbrev obarray
cl-preloaded nadvice button loaddefs faces cus-face macroexp files
window text-properties overlay sha1 md5 base64 format env code-pages
mule custom widget hashtable-print-readable backquote threads kqueue mac
lcms2 multi-tty make-network-process native-compile emacs)

Memory information:
((conses 16 376927 18101)
(symbols 48 18578 1)
(strings 32 73446 5356)
(string-bytes 1 3084140)
(vectors 16 56748)
(vector-slots 8 1009214 32281)
(floats 8 157 116)
(intervals 56 1385 214)
(buffers 992 20))

--- 28.1/lisp/ehelp.el.gz
+++ site-lisp/ehelp.el.gz
@@ -76,7 +76,9 @@
     (define-key map [?\C-7] 'electric-help-undefined)
     (define-key map [?\C-8] 'electric-help-undefined)
     (define-key map [?\C-9] 'electric-help-undefined)
-    (define-key map (char-to-string help-char) 'electric-help-help)
+    (define-key map
+      (if (characterp help-char) (char-to-string help-char) (vector help-char))
+      'electric-help-help)
     (define-key map "?" 'electric-help-help)
     (define-key map " " 'scroll-up)
     (define-key map [?\S-\ ] 'scroll-down)