[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
Re: word selection in history expansion - !?word?%
From: |
Chet Ramey |
Subject: |
Re: word selection in history expansion - !?word?% |
Date: |
Tue, 13 Aug 2024 16:00:13 -0400 |
User-agent: |
Mozilla Thunderbird |
On 8/12/24 5:15 PM, Jess M wrote:
Given the age of the behaviour, I would agree on not making it the default
behaviour.
To update the documentation to reflect that, how about something like this:
--- current --- lib/readline/doc/hsuser.texi
@item %
The first word matched by the most recent @samp{?@var{string}?} search,
if the search string begins with a character that is part of a word.
--- proposed ---
@item %
The first word matched by the most recent @samp{?@var{string}?} search,
if the search string begins with a character that is part of a word. The
search happens in reverse, so if multiple words on a line match, the word
nearer the end of the line is returned.
Thanks. I will add something similar.
Consider updating the word designator to accept a count. In this mode, `!?
word?:%3` would provide the third found item found in a reverse search.
I'd be wary of extending the history expansion syntax, even to the extent
of adding a new modifier. It's been basically identical for what, 46 years?
It's an interesting idea, though.
Implementing the search across lines might prove tricky. The current code
splits line match and word match; we don't even count words until after
we've identified the matched line.
History expansion is aggressively line-oriented.
--
``The lyf so short, the craft so long to lerne.'' - Chaucer
``Ars longa, vita brevis'' - Hippocrates
Chet Ramey, UTech, CWRU chet@case.edu http://tiswww.cwru.edu/~chet/