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

From: Juri Linkov <[email-masked]>
Date: Thu, 27 Apr 2023 21:12:55 +0300

> I tried to describe the behavior in the doc string as follows:
>
>   (defun mark-sexp (&optional arg allow-extend)
>     "Set mark ARG sexps from point or move mark one sexp.
>   When called from Lisp with ALLOW-EXTEND ommitted or nil, mark is
>   set ARG sexps from point; ARG defaults to 1.
>   With ALLOW-EXTEND non-nil (interactively, with prefix argument),
>   the place mark goes is the same place \\[forward-sexp] would move
>   with the same value of ARG; if the mark is active, it moves ARG
>   sexps from its current position, otherwise it is set ARG sexps
>   from point; ARG defaults to 1.
>   When invoked interactively without a prefix argument and no active
>   region, mark moves one sexp forward.
>   When invoked interactively without a prefix argument, and region
>   is active, mark moves one sexp away of point (i.e., forward
>   if mark is at or after point, back if mark is before point), thus
>   extending the region by one sexp.  Since the direction of region
>   extension depends on the relative position of mark and point, you
>   can change the direction by \\[exchange-point-and-mark].
>   This command assumes point is not in a string or comment."
>
> It is still somewhat complicated and confusing, but at least it's
> accurate, I think.

mark-sexp has a counterpart mark-word that has almost the same
implementation and docstring.  So this could be fixed in both places.