Subject: bug#43489: [PATCH] Don't signal scan-error when moving by sexp interactively

From: João Távora <[email-masked]>
Date: Mon, 21 Sep 2020 09:49:25 +0100

On Fri, Sep 18, 2020 at 2:14 PM Lars Ingebrigtsen <[email-masked]> wrote:

> Mattias Engdegård <[email-masked]> writes:
>
> > When moving by sexp (C-M-f, C-M-u and so on) and point is already at a
> > boundary preventing further movement, Emacs currently signals an
> > internal error such as
> >
> >  Scan error: "Containing expression ends prematurely", 5010, 5010
> >
> > or
> >
> >  Scan error: "Unbalanced parentheses", 5010, 1
> >
> > which is unhelpful and rather looks as if something went wrong in the
> > internal machinery.
>
> Yes, those error messages are confusing in interactive usage.
>

I disagree strongly.  Maybe the integers following them and
containing character positions are confusing, but the messages
themselves are fine.

Here's my use case.  When selecting a certain amount of forms
inside another one, but not an outermost one, I type a lot of M-PC
until I see the "Containing expression..." message.  I actively look
out for it.  When it pops up, the region persists. I can then C-w
or do whatever, keeping that part of the code balanced. If, however,
the message is "Unbalanced parenthesis", I know something's up
and have to fix it.

Please don't remove the message and/or conflate the two cases.

João