Subject: [PATCH] Substitute command keys in ielm-header at use time

From: [email-masked]
Date: Thu, 10 Aug 2023 11:21:22 -0400

Tags: patch

Tags: patch

Fixes an ielm bug

In GNU Emacs 29.1 (build 1, x86_64-pc-linux-gnu, X toolkit, cairo
version 1.16.0, Xaw3d scroll bars)
Repository revision: b28d44d4226497c4b2582bc15a59fc817eb3ce0a
Repository branch: master
Windowing system distributor 'The X.Org Foundation', version 11.0.12101008
System Description: NixOS 23.05 (Stoat)

Configured using:
 'configure
 --prefix=/nix/store/ri7x0w6iqs38vr7vgwc76i9dwy5ikd8i-emacs-git-20230503.0
 --disable-build-details --with-modules --with-x-toolkit=lucid
 --with-xft --with-cairo'

>From 4a09a067bd09987291081b5b42a3ba0125765f60 Mon Sep 17 00:00:00 2001
From: Matthew Tromp <[email-masked]>
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.
---
 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.31.1