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

From: Ruijie Yu <[email-masked]>
Date: Mon, 17 Apr 2023 11:06:03 +0800

Zachary Kanfer <[email-masked]> writes:

> Attached is a patch to add #'mark-sexp-forwards and #'mark-sexp-backwards. These functions extend the region by sexps forward and
> backward. They are mutually incremental: you can call mark-sexp-fowards, then mark-sexp-backwards twice, then mark-sexp-forwards. After
> this, the region will consist of the two sexps before point and the two sexps after point.

If this is to be accepted, why not extend it to all like mark functions,
listed below?  Implementing them should be pretty similar, and you might
even be able to reuse the same helper for all these variants.  Also, the
helper function might need to contain a double-dash in its name because
this is inherently a private function.

- `mark-defun'
- `mark-page'
- `mark-paragraph'
- `mark-word'

> +(defun mark-sexp-helper (number-of-expressions)
> +  "A helper function for 'mark-sexp-[forward, backward]'.
> +
> +If NUMBER-OF-EXPRESSIONS is positive, mark that many sexps forward;
> +otherwise, amrk backward."

Please use `quote' to quote things in Emacs docstrings.  Also, both here
and in other docstrings, the newline immediately after the first line,
while seems necessary, is usually redundant in Emacs docstrings.  And
there is a typo: "amrk" -> "mark".

I also think you shouldn't use wildcard-like elements in quotes (in your
case, you reuse part of the name in the quote), but I'm not sure.

-- 
Best,

RY