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

From: Drew Adams <[email-masked]>
Date: Fri, 28 Apr 2023 19:28:43 +0000

> > +(defun mark--helper (move-fn number-of-things)
> 
> A nicer name would be 'mark-thing' as a reference to thingatpt.el.

FWIW, I have a different take on this.

Is it an "internal" function?  Then its name should
maybe use `--'.  (But why should it be internal?)

Is it a helper function?  Then its name should maybe
use a suffix that indicates that, such as `-helper'
or `-1' (old-school Lisp, I suppose).

`mark-thing' should be reserved for a function that
takes a THING name as arg: `sexp', `page', etc.,
instead of a movement function such as `forward-sexp'.
___

FWIW, I think MOVE-FN is a fine name for the argument.
My own preference, and what I use in my code, is the
name FORWARD-THING-FUNCTION.
___

FWIW, in my library isearch+.el), I use the arg name
THING for a thing name, not a movement or other
function.

E.g.: Function `isearchp-in-thing-p' is a helper
function for defining specific THING-type predicates,
such as `isearch(-not)-in-email-address-p'.
___

FWIW, my library `thing-cmds.el' has a command named
`mark-things', which prompts for a THING type as arg:

 mark-things is an alias for 'select-things' in 'thing-cmds.el'.

 (mark-things THING &optional ARG ALLOW-EXTEND)

 Set point at one end of THING and set mark ARG THINGs from point.
 THING is a symbol that names a type of thing.  Interactively, you are
 prompted for it.  Completion is available (lax).

 (If THING doesn't have an associated `forward-'THING operation then
 do nothing.)

 Put mark at the same place command `forward-'THING would move point
 with the same prefix argument.

 Put point at the beginning of THING, unless the prefix argument (ARG)
 is negative, in which case put it at the end of THING.

 If `select-things' is repeated or if the mark is active (in Transient
 Mark mode), then it marks the next ARG THINGs, after the ones already
 marked.  In this case the type of THING used is whatever was used the
 last time `select-things' was called - you are not prompted for it.

 This region extension reusing the last type of THING happens even if
 the active region is empty.  This means that you can, for instance,
 just use `C-SPC' to activate an empty region and then use
 `select-things' to select more THINGS of the last kind selected.

 If there is no THING at point, and `thgcmd-use-nearest-thing-flag' is
 non-nil, then select a THING near point.