Subject: bug#31204: 25.3; Make word motion more customizable

From: Lars Ingebrigtsen <[email-masked]>
Date: Wed, 18 May 2022 14:03:42 +0200

Yuri Khan <[email-masked]> writes:

> While trying to make word motion commands (Ctrl+left/right, M-f/b) more
> similar to that implemented in other editors:
>
> http://lists.gnu.org/archive/html/help-gnu-emacs/2018-04/msg00230.html
>
> I encountered a difficulty.

[...]

> Step 1, on the other hand, is not customizable at all.
>
> The specific behavior that I was trying to implement was to find the
> nearest transition:
>
> * from a word character to a non-word character, OR
> * from a non-word non-whitespace character to a word character, OR
> * from a non-word non-whitespace character to a whitespace character.
>
> As an illustration (where ‘|’ specifies word motion stops when going
> left to right):
>
>     foo| ***| +++| (|bar|)|
>        ^

[...]

> Perhaps it would be nice to have an optional hook for step 1 of
> ‘forward-word’, a function that would take two arguments POS and LIMIT,
> and returning the starting word boundary position from which step 2 would
> then work.

(I'm going through old bug reports that unfortunately weren't resolved
at the time.)

I think this sounds like it could be useful.  If we added such a hook to
`forward-word', what would the rest of the code look like to make
`C-<right>' work this way?

-- 
(domestic pets only, the antidote for overdose, milk.)
   bloggy blog: http://lars.ingebrigtsen.no