all messages for Emacs-related lists mirrored at yhetil.org
 help / color / mirror / code / Atom feed
From: Michael Heerdegen via "Bug reports for GNU Emacs, the Swiss army knife of text editors" <bug-gnu-emacs@gnu.org>
To: Eli Zaretskii <eliz@gnu.org>
Cc: iarchivedmywholelife@gmail.com, 70868@debbugs.gnu.org
Subject: bug#70868: 30.0.50;
Date: Sun, 12 May 2024 16:50:40 +0200	[thread overview]
Message-ID: <87v83jozi7.fsf@web.de> (raw)
In-Reply-To: <86h6f419mi.fsf@gnu.org> (Eli Zaretskii's message of "Sat, 11 May 2024 21:33:41 +0300")

Eli Zaretskii <eliz@gnu.org> writes:

>   M-: (pp-emacs-lisp-code '((quote a))) RET
>     => ('a)

Another one is nil vs. () or '() vs. 'nil, like in

  (defun f () ...)  vs.  (defun f nil ...)

or

  (delq nil my-list) vs. (delq () my-list)

etc, then - when to use dot syntax? - there is
`(foo . (,b)) vs. `(foo ,b) or

(let ((my-alist '((a . (1 2)) (b . (3 4))))) ...) vs.
(let ((my-alist '((a 1 2))    (b 3 4))) ...)

then (list +1 -1) vs. (list 1 -1), ?c vs. n vs ?\x... vs. ?\N...,
then there is "\n" vs "
" (docstrings!!!) - there is a ton of such ambiguities!

And note that we have only brought up silly one-line code examples so
far.  In real code, what the user expects will be _different_ for
different places in one and the same larger expression.

I totally agree that this problem is surprising and APITA, but please
don't expect that `pp-emacs-lisp-code' will ever produce satisfying
results when fed with existing code written by humans (i.e., when we
`read' and reprint it).  This will mess up as much as it prettifies, and
more.

And note there are even more problems of other kinds.  Another one is
that we don't discriminate context dependent semantics.  Is (let ...) a
`let' expression?  Or a `let' `pcase' form?  Or a list of names of
special forms?  Or maybe something which is meant to be macroexpanded to
a `let' expression, and the second element of the list is not a binding
list but something like ,(compute-let-bindings)?


I know these kinds of problems well and for years from my experience
with my "el-search" package - when I first tried an automatic rewriting
rule like

   `(if ,cond ,form) --> `(when ,cond ,form)

I was very disappointed about how ugly everything got when all in FORM
got folded to syntactical defaults.

[ For completion, if anyone wonders: in "el-search" I try to identify
the code parts that get part of the replacement expression - COND and
FORM in the above example - in the original code in the buffer operated
on and reuse the print syntax from there. ]


In sum I'm quite sure that

  M-: (pp--insert-lisp 'my-large-thunk-of-real-life-code)

is something that will never produce really good looking code whatever
guessing and heuristical cleverness we might be able to invent.  It will
always produce a result that a human will have to tune and correct
manually line by line.  Which is actually exactly the work we wanted to
delegate to this function!


So, my opinion is that Elisp pretty printing with input expressions, in
contrast to text, is, if at all, only useful for automatically generated
expressions (like macro expansions).  It's trivial that this will come
with the same problems (though in this case they are a bit less
surprising and annoying at least).  We should still fix this bug,
obviously.


Michael.






  reply	other threads:[~2024-05-12 14:50 UTC|newest]

Thread overview: 26+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2024-05-10 23:56 bug#70868: 30.0.50; pp--insert-lisp prints small integers as characters No Wayman
2024-05-11  0:10 ` No Wayman
2024-05-11  6:47   ` Eli Zaretskii
2024-05-11 10:58   ` Michael Heerdegen via Bug reports for GNU Emacs, the Swiss army knife of text editors
2024-05-11 11:09     ` Michael Heerdegen via Bug reports for GNU Emacs, the Swiss army knife of text editors
2024-05-11 12:08       ` Mattias Engdegård
2024-05-11 14:48         ` Michael Heerdegen via Bug reports for GNU Emacs, the Swiss army knife of text editors
2024-05-11 15:10           ` Mattias Engdegård
2024-05-11 11:32     ` Andreas Schwab
2024-05-11 10:54 ` Michael Heerdegen via Bug reports for GNU Emacs, the Swiss army knife of text editors
2024-05-11 16:38   ` Michael Heerdegen via Bug reports for GNU Emacs, the Swiss army knife of text editors
2024-05-11 16:47     ` Eli Zaretskii
2024-05-11 18:26       ` bug#70868: 30.0.50; iarchivedmywholelife
2024-05-11 18:29         ` Eli Zaretskii
2024-05-11 18:33           ` Eli Zaretskii
2024-05-12 14:50             ` Michael Heerdegen via Bug reports for GNU Emacs, the Swiss army knife of text editors [this message]
2024-05-12 15:06               ` Eli Zaretskii
2024-05-12 15:15                 ` Michael Heerdegen via Bug reports for GNU Emacs, the Swiss army knife of text editors
2024-05-12 15:42                   ` Eli Zaretskii
2024-05-12 18:11                     ` Michael Heerdegen via Bug reports for GNU Emacs, the Swiss army knife of text editors
2024-05-28 10:51                       ` bug#70868: 30.0.50; pp--insert-lisp prints small integers as characters Michael Heerdegen via Bug reports for GNU Emacs, the Swiss army knife of text editors
2024-05-12 21:39                     ` bug#70868: 30.0.50; Stefan Monnier via Bug reports for GNU Emacs, the Swiss army knife of text editors
2024-05-14 18:25                       ` Michael Heerdegen via Bug reports for GNU Emacs, the Swiss army knife of text editors
2024-05-14 22:30                         ` Stefan Monnier via Bug reports for GNU Emacs, the Swiss army knife of text editors
2024-05-14 18:28                       ` Michael Heerdegen via Bug reports for GNU Emacs, the Swiss army knife of text editors
2024-05-14 20:16                         ` Michael Heerdegen via Bug reports for GNU Emacs, the Swiss army knife of text editors

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=87v83jozi7.fsf@web.de \
    --to=bug-gnu-emacs@gnu.org \
    --cc=70868@debbugs.gnu.org \
    --cc=eliz@gnu.org \
    --cc=iarchivedmywholelife@gmail.com \
    --cc=michael_heerdegen@web.de \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
Code repositories for project(s) associated with this external index

	https://git.savannah.gnu.org/cgit/emacs.git
	https://git.savannah.gnu.org/cgit/emacs/org-mode.git

This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.