mirror of
git://git.code.sf.net/p/zsh/code
synced 2025-10-27 04:40:59 +01:00
17983: Added zle LASTSEARCJ parameter
This commit is contained in:
parent
a02a308839
commit
e91067d966
4 changed files with 31 additions and 2 deletions
|
|
@ -1,3 +1,9 @@
|
||||||
|
2002-12-06 Felix Rosencrantz <f_rosencrantz@yahoo.com>
|
||||||
|
|
||||||
|
* 17983: Src/Zle/zle_hist.c, Src/Zle/zle_params.c, Doc/Zsh/zle.yo:
|
||||||
|
Added zle LASTSEARCH parameter, giving read access to last incremental
|
||||||
|
search.
|
||||||
|
|
||||||
2002-12-06 Bart Schaefer <schaefer@zsh.org>
|
2002-12-06 Bart Schaefer <schaefer@zsh.org>
|
||||||
|
|
||||||
* 17985: Test/B02typeset.ztst: adjust hiding/tagging test so it no
|
* 17985: Test/B02typeset.ztst: adjust hiding/tagging test so it no
|
||||||
|
|
|
||||||
|
|
@ -627,6 +627,11 @@ Unlike a normal array, only a maximum of eight elements may be written;
|
||||||
any extra are ignored. If fewer than eight elements are given, the
|
any extra are ignored. If fewer than eight elements are given, the
|
||||||
remaining elements of the kill ring will be treated as undefined.
|
remaining elements of the kill ring will be treated as undefined.
|
||||||
)
|
)
|
||||||
|
|
||||||
|
vindex(LASTSEARCH)
|
||||||
|
item(tt(LASTSEARCH) (scalar))(
|
||||||
|
The last search string used by an interactive search ; read-only.
|
||||||
|
)
|
||||||
vindex(LASTWIDGET)
|
vindex(LASTWIDGET)
|
||||||
item(tt(LASTWIDGET) (scalar))(
|
item(tt(LASTWIDGET) (scalar))(
|
||||||
The name of the last widget that was executed; read-only.
|
The name of the last widget that was executed; read-only.
|
||||||
|
|
|
||||||
|
|
@ -41,6 +41,14 @@ int lastcol;
|
||||||
/**/
|
/**/
|
||||||
int histline;
|
int histline;
|
||||||
|
|
||||||
|
/* Previous search string use in an incremental search */
|
||||||
|
|
||||||
|
/**/
|
||||||
|
char *previous_search = NULL;
|
||||||
|
|
||||||
|
/**/
|
||||||
|
int previous_search_len = 0;
|
||||||
|
|
||||||
#define ZLETEXT(X) ((X)->zle_text ? (X)->zle_text : (X)->text)
|
#define ZLETEXT(X) ((X)->zle_text ? (X)->zle_text : (X)->text)
|
||||||
|
|
||||||
/**/
|
/**/
|
||||||
|
|
@ -757,8 +765,6 @@ doisearch(char **args, int dir)
|
||||||
int hl = histline, savekeys = -1, feep = 0;
|
int hl = histline, savekeys = -1, feep = 0;
|
||||||
Thingy cmd;
|
Thingy cmd;
|
||||||
char *okeymap;
|
char *okeymap;
|
||||||
static char *previous_search = NULL;
|
|
||||||
static int previous_search_len = 0;
|
|
||||||
Histent he;
|
Histent he;
|
||||||
|
|
||||||
if (!(he = quietgethist(hl)))
|
if (!(he = quietgethist(hl)))
|
||||||
|
|
|
||||||
|
|
@ -89,6 +89,8 @@ static struct zleparam {
|
||||||
zleunsetfn, NULL },
|
zleunsetfn, NULL },
|
||||||
{ "POSTDISPLAY", PM_SCALAR, FN(set_postdisplay), FN(get_postdisplay),
|
{ "POSTDISPLAY", PM_SCALAR, FN(set_postdisplay), FN(get_postdisplay),
|
||||||
zleunsetfn, NULL },
|
zleunsetfn, NULL },
|
||||||
|
{ "LASTSEARCH", PM_SCALAR | PM_READONLY, NULL, FN(get_lsearch),
|
||||||
|
zleunsetfn, NULL },
|
||||||
{ NULL, 0, NULL, NULL, NULL, NULL }
|
{ NULL, 0, NULL, NULL, NULL, NULL }
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
@ -526,3 +528,13 @@ free_prepostdisplay(void)
|
||||||
if (postdisplaylen)
|
if (postdisplaylen)
|
||||||
set_prepost(&postdisplay, &postdisplaylen, NULL);
|
set_prepost(&postdisplay, &postdisplaylen, NULL);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**/
|
||||||
|
static char *
|
||||||
|
get_lsearch(Param pm)
|
||||||
|
{
|
||||||
|
if (previous_search_len)
|
||||||
|
return metafy(previous_search, previous_search_len, META_HEAPDUP);
|
||||||
|
else
|
||||||
|
return "";
|
||||||
|
}
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue