new readline "fetch-history" bindable command; declare -p output change

This commit is contained in:
Chet Ramey
2021-04-01 17:25:48 -04:00
parent 65822e5011
commit 8f485ff84c
17 changed files with 3065 additions and 2786 deletions
+15 -9
View File
@@ -853,6 +853,21 @@ Move to the first line in the history.
Move to the end of the input history, i.e., the line currently being
entered.
.TP
.B
operate\-and\-get\-next (C\-o)
Accept the current line for return to the calling application as if a
newline had been entered,
and fetch the next line relative to the current line from the history
for editing.
A numeric argument, if supplied, specifies the history entry to use instead
of the current line.
.TP
.B
fetch\-history
With a numeric argument, fetch that entry from the history list
and make it the current line.
Without an argument, move back to the first entry in the history list.
.TP
.B reverse\-search\-history (C\-r)
Search backward starting at the current line and moving `up' through
the history as necessary. This is an incremental search.
@@ -919,15 +934,6 @@ the direction to move through the history. A negative argument switches
the direction through the history (back or forward).
The history expansion facilities are used to extract the last argument,
as if the "!$" history expansion had been specified.
.TP
.B
operate\-and\-get\-next (C\-o)
Accept the current line for return to the calling application as if a
newline had been entered,
and fetch the next line relative to the current line from the history
for editing.
A numeric argument, if supplied, specifies the history entry to use instead
of the current line.
.PD
.SS Commands for Changing Text
.PD 0
+5
View File
@@ -1332,6 +1332,11 @@ for editing.
A numeric argument, if supplied, specifies the history entry to use instead
of the current line.
@item fetch-history ()
With a numeric argument, fetch that entry from the history list
and make it the current line.
Without an argument, move back to the first entry in the history list.
@end ftable
@node Commands For Text
+2 -2
View File
@@ -4,7 +4,7 @@ Copyright (C) 1988-2021 Free Software Foundation, Inc.
@set EDITION 8.1
@set VERSION 8.1
@set UPDATED 16 March 2021
@set UPDATED 31 March 2021
@set UPDATED-MONTH March 2021
@set LASTCHANGE Tue Mar 16 14:41:07 EDT 2021
@set LASTCHANGE Wed Mar 31 11:45:32 EDT 2021
+1
View File
@@ -93,6 +93,7 @@ static const FUNMAP default_funmap[] = {
{ "end-of-history", rl_end_of_history },
{ "end-of-line", rl_end_of_line },
{ "exchange-point-and-mark", rl_exchange_point_and_mark },
{ "fetch-history", rl_fetch_history },
{ "forward-backward-delete-char", rl_rubout_or_delete },
{ "forward-byte", rl_forward_byte },
{ "forward-char", rl_forward_char },
+36
View File
@@ -634,6 +634,42 @@ rl_get_previous_history (int count, int key)
return 0;
}
/* With an argument, move back that many history lines, else move to the
beginning of history. */
int
rl_fetch_history (int count, int c)
{
int wanted, nhist;
/* Giving an argument of n means we want the nth command in the history
file. The command number is interpreted the same way that the bash
`history' command does it -- that is, giving an argument count of 450
to this command would get the command listed as number 450 in the
output of `history'. */
if (rl_explicit_arg)
{
nhist = history_base + where_history ();
/* Negative arguments count back from the end of the history list. */
wanted = (count >= 0) ? nhist - count : -count;
if (wanted <= 0 || wanted >= nhist)
{
/* In vi mode, we don't change the line with an out-of-range
argument, as for the `G' command. */
if (rl_editing_mode == vi_mode)
rl_ding ();
else
rl_beginning_of_history (0, 0);
}
else
rl_get_previous_history (wanted, c);
}
else
rl_beginning_of_history (count, 0);
return (0);
}
/* The equivalent of the Korn shell C-o operate-and-get-next-history-line
editing command. */
+1
View File
@@ -134,6 +134,7 @@ extern int rl_end_of_history (int, int);
extern int rl_get_next_history (int, int);
extern int rl_get_previous_history (int, int);
extern int rl_operate_and_get_next (int, int);
extern int rl_fetch_history (int, int);
/* Bindable commands for managing the mark and region. */
extern int rl_set_mark (int, int);
+1 -18
View File
@@ -337,24 +337,7 @@ rl_vi_yank_arg (int count, int key)
int
rl_vi_fetch_history (int count, int c)
{
int wanted;
/* Giving an argument of n means we want the nth command in the history
file. The command number is interpreted the same way that the bash
`history' command does it -- that is, giving an argument count of 450
to this command would get the command listed as number 450 in the
output of `history'. */
if (rl_explicit_arg)
{
wanted = history_base + where_history () - count;
if (wanted <= 0)
rl_beginning_of_history (0, 0);
else
rl_get_previous_history (wanted, c);
}
else
rl_beginning_of_history (count, 0);
return (0);
return (rl_fetch_history (count, c));
}
/* Search again for the last thing searched for. */