Subject: Re: bug#62892: proposal to extend mark-sexp to go forward and backward on command

From: Zachary Kanfer <[email-masked]>
Date: Wed, 26 Apr 2023 00:41:45 -0400

The documentation for mark-sexp says:

> Set mark ARG sexps from point.
> The place mark goes is the same place C-M-<right> would
> move to with the same argument.

This is correct but misleading. Worse still is the next part:

> Interactively, if this command is repeated
> or (in Transient Mark mode) if the mark is active,
> it marks the next ARG sexps after the ones already marked.

This says it marks sexps *after* the ones already marked. This is
incorrect; if point is *after* mark, and mark is active, this function
marks sexps *before* the ones already marked.

> In my opinion, the description of that feature should not be part of the
> mark-sexp command documentation, because the feature is actually
> provided by C-x C-x (exchange-point-and-mark).

One way for this situation to occur is by using C-x C-x, yes, but it's not
the only way. You can set point, move forward sexps, and then calling
mark-sexp will mark sexps backwards.

There is specific code in mark-sexp to check which direction to move; it
should be documented as such.

On Tue, Apr 25, 2023 at 6:26 PM Daniel Martín <[email-masked]> wrote:

> Zachary Kanfer <[email-masked]> writes:
>
> >
> > Also, whatever the outcome of this patch, I think it would be advisable
> to
> > explain somewhere how mark-sexp extends region by the end of region
> > opposite point; this is not in the docstring or any other documentation
> > I've seen.
> >
>
> In my opinion, the description of that feature should not be part of the
> mark-sexp command documentation, because the feature is actually
> provided by C-x C-x (exchange-point-and-mark).  The Emacs manual in
> section 12.1 Setting the Mark describes this use case well, I think:
>
> ‘C-x C-x’ is useful when you are
> satisfied with the position of point but want to move the other end of
> the region (where the mark is).
>