From 556cb01b48e2db6baa6c8793c45358b578724bfe Mon Sep 17 00:00:00 2001
From: Matthew Tromp <matthewktromp@gmail.com>
Date: Thu, 10 Aug 2023 10:41:24 -0400
Subject: [PATCH] Substitute command keys in 'ielm-header' at use time

Before, command keys were substituted into the ielm-header when
ielm.el was loaded, which resulted in the substitutions depending on
the user's current buffer instead of the ielm buffer.
For example, if the user was in an info-mode buffer, the key would
appear as 'H' instead of 'C-h m'.
Now, the command key is substituted after the ielm buffer has been
created.
* lisp/ielm.el (ielm-header): Remove substitute-command-keys.
(inferior-emacs-lisp-mode): Add substitute-command-keys.  (Bug#65213)

Copyright-paperwork-exempt: yes
---
 lisp/ielm.el | 5 ++---
 1 file changed, 2 insertions(+), 3 deletions(-)

diff --git a/lisp/ielm.el b/lisp/ielm.el
index 5c370733c05..578422001a5 100644
--- a/lisp/ielm.el
+++ b/lisp/ielm.el
@@ -148,9 +148,8 @@ such as `edebug-defun' to work with such inputs."
 This variable is buffer-local.")
 
 (defvar ielm-header
-  (substitute-command-keys
    "*** Welcome to IELM ***  Type (describe-mode) or press \
-\\[describe-mode] for help.\n")
+\\[describe-mode] for help.\n"
   "Message to display when IELM is started.")
 
 (defvaralias 'inferior-emacs-lisp-mode-map 'ielm-map)
@@ -615,7 +614,7 @@ Customized bindings may be defined in `ielm-map', which currently contains:
     (setq-local comint-inhibit-carriage-motion t)
 
     ;; Add a silly header
-    (insert ielm-header)
+    (insert (substitute-command-keys ielm-header))
     (ielm-set-pm (point-max))
     (unless comint-use-prompt-regexp
       (let ((inhibit-read-only t))
-- 
2.39.5