On 4/9/26 7:21 AM, k4lizen wrote:
Hello again!Oftentimes I start searching some command with Ctrl-R, realize that I don't have it in history, but I will nonetheless want to execute the command.
You mean you want to execute the contents of the search string, whether it's found in the history or not?
Currently if I Ctrl-C while searching, the command buffer will become empty, but I want to retain whatever was my search query in order to potentially edit the arguments a bit and submit it.
C-c aborts everything you're doing with the current readline command, including clearing the search string. If you want to save the search string after a C-c, you have to do it yourself.
Similarly, if my search query has 0 matches, and I press Enter/Return/C-M, I would like my search query to remain in the command buffer.
So you want an unsuccessful search string to be copied from the search string buffer to the line buffer. This is not currently available with incremental search, but see below for how to do it.
Is this currently possible? If not, could you implement the option to enable it?
The whole idea behind incremental search is that it only acts on successful
searches, and the last successful match is what `sticks'.
It sounds like you want the functionality provided by non-incremental
searching. If you want to type the search string after invoking the
search command, use
non-incremental-reverse-search-history
non-incremental-forward-search-history
but these wil not preserve the contents of the search string if the search
fails. You can use
history-substring-search-backward
history-substring-search-forward
(which are unbound by default) to search the history for the string that is
the contents of the readline line buffer between the start of the line and
point.
If you use the latter two functions, you can type a string into the line
buffer, hit whatever key sequence you bind to that function, and have
readline perform the search. If it's successful, the matching history line
is copied into the line buffer as normal. If it's unsuccessful, the search
string remains unchanged in the line buffer. You can continue to edit it
from there.
Chet
--
``The lyf so short, the craft so long to lerne.'' - Chaucer
``Ars longa, vita brevis'' - Hippocrates
Chet Ramey, UTech, CWRU [email protected] http://tiswww.cwru.edu/~chet/
OpenPGP_signature.asc
Description: OpenPGP digital signature
