Subject: bug#70163: 29.3; hexl-mode incorrect docstring

From: Stefan Monnier <[email-masked]>
Date: Sat, 06 Apr 2024 16:21:44 -0400

>> What is "the more appropriate place", and how will you find it, given
>> that some doc strings are auto-generated, either in part or in full?
> Right after the next \n ?

As in the patch below.

        Stefan

diff --git a/lisp/help.el b/lisp/help.el
index 1ef46e394f3..c2a278bc0a0 100644
--- a/lisp/help.el
+++ b/lisp/help.el
@@ -1380,6 +1380,7 @@ substitute-command-keys
     ;; itself.
     (let ((keymap overriding-local-map)
           (inhibit-modification-hooks t)
+          (delayed ())
           (orig-buf (current-buffer)))
       (with-temp-buffer
         (insert string)
@@ -1496,11 +1497,17 @@ substitute-command-keys
                                              (symbol-value name)))))
                   (cond
                    ((null this-keymap)
-                    (insert "\nUses keymap "
-                            (substitute-quotes "`")
-                            (symbol-name name)
-                            (substitute-quotes "'")
-                            ", which is not currently defined.\n")
+                    ;; Insert a warning on the next line (bug#70163).
+                    (let ((pos (copy-marker (line-beginning-position 2))))
+                      (push (lambda ()
+                              (goto-char pos)
+                              (unless (bolp) (insert "\n"))
+                              (insert "Uses keymap "
+                                      (substitute-quotes "`")
+                                      (symbol-name name)
+                                      (substitute-quotes "'")
+                                      ", which is not currently defined.\n"))
+                            delayed))
                     (unless generate-summary
                       (setq keymap nil)))
                    ((not generate-summary)
@@ -1527,6 +1534,7 @@ substitute-command-keys
               (delete-char 1))
              ;; 3. Nothing to do -- next character.
              (t (forward-char 1)))))
+        (mapc #'funcall delayed)
         (buffer-string)))))
 
 (defun substitute-quotes (string)