Subject: bug#62453: 30.0.50; Semicolon in view-lossage yields wrong alignment

From: Eli Zaretskii <[email-masked]>
Date: Sun, 26 Mar 2023 12:23:56 +0300

> Date: Sun, 26 Mar 2023 08:33:18 +0300
> From:  Eshel Yaron via "Bug reports for GNU Emacs,
>  the Swiss army knife of text editors" <[email-masked]>
> 
> 
> It seems like key sequences that end with a semicolon hinder the
> alignment in the `view-lossage` output buffer.  This is a regression
> with respect to the (IMO correct) behavior in Emacs 27.
> 
> With Emacs from master:
> 1. emacs -Q
> 2. type C-;
> 3. type ;
> 4. type C-h l
> 5. The *Help* buffer now shows:
> 
>  C-			; ;; nil
>  ; ;; self-insert-command
>  C-h l ;; view-lossage
> 
> Note that all three lines are formatted incorrectly compared to what we
> get with Emacs 27:
> 
>  C-;			;; nil
>  ;			;; self-insert-command
>  C-h l			;; view-lossage

Does the patch below give good results?

Stefan, any better ideas?  It looks like relying on comment-indent is
quite fragile here, as keys can include a semi-colon, which will be
interpreted as beginning a comment in too many places.  I wonder
whether the two extra bindings I add below really plug all the holes.

diff --git a/lisp/help.el b/lisp/help.el
index 3e94b50..13e61c0 100644
--- a/lisp/help.el
+++ b/lisp/help.el
@@ -689,6 +689,10 @@ view-lossage
       (with-current-buffer standard-output
 	(goto-char (point-min))
 	(let ((comment-start ";; ")
+              ;; Prevent 'comment-indent' from handling a single
+              ;; semicolon as the beginning of a comment.
+              (comment-start-skip ";; ")
+              (comment-use-syntax nil)
               (comment-column 24))
           (while (not (eobp))
             (comment-indent)