Subject: Re: bug#55478: 29.0.50; pp-emacs-lisp-code prints '("a") as (a)

From: Visuwesh <[email-masked]>
Date: Tue, 17 May 2022 15:48:31 +0530

[செவ்வாய் மே 17, 2022] Visuwesh wrote:

I hit send too early.  

> Sorry for the awful subject line.  To reproduce,
>
>         1. emacs -Q
>         2. (pp-emacs-lisp-code '("a"))
>         3. C-x C-e
>
> instead of (pp-emacs-lisp-code '("a")) you can also try
> (pp-emacs-lisp-code '("a" . "b")).  However, if the argument is '("a"
> "b"), then there are no such problems.
>
> A quick through edebug shows that this is due to the usage of `princ'.
    ^^^^^^^^^^^^^^^^^^^^^^

A quick edebug through pp--insert-lisp shows that it is due to use of
`princ' in this condition,

      (cons (cond
               ((consp (cdr sexp))
                (if (and (length= sexp 2)
                         (memq (car sexp) '(quote function)))
                    (cond
                     ((symbolp (cadr sexp))
                      (let ((print-quoted t))
                        (prin1 sexp (current-buffer))))
                     ((consp (cadr sexp))
                      (insert (if (eq (car sexp) 'quote)
                                  "'" "#'"))
                      (pp--format-list (cadr sexp)
                                       (set-marker (make-marker) (1- (point))))))
                  (pp--format-list sexp)))
               (t
                (princ sexp (current-buffer)))))
                    ^^^^^^^^^^^^^^^^^^^^^^^^^