mirror of
git://git.code.sf.net/p/zsh/code
synced 2025-09-02 22:11:54 +02:00
26366: add "isearch" keymap and "accept-search" functino
This commit is contained in:
parent
8541ccb842
commit
46cdeb71b7
5 changed files with 35 additions and 5 deletions
|
@ -1,5 +1,9 @@
|
||||||
2009-01-19 Peter Stephenson <pws@csr.com>
|
2009-01-19 Peter Stephenson <pws@csr.com>
|
||||||
|
|
||||||
|
* 26366: Doc/Zsh/zle.yo, Src/Zle/iwidgets.list,
|
||||||
|
Src/Zle/zle_hist.c, Src/Zle/zle_keymap.c: add "isearch"
|
||||||
|
keymap and "accept-search" function.
|
||||||
|
|
||||||
* Doug Kearns: 26365: Completion/Unix/Command/_python: new 3.0
|
* Doug Kearns: 26365: Completion/Unix/Command/_python: new 3.0
|
||||||
options.
|
options.
|
||||||
|
|
||||||
|
@ -10948,5 +10952,5 @@
|
||||||
|
|
||||||
*****************************************************
|
*****************************************************
|
||||||
* This is used by the shell to define $ZSH_PATCHLEVEL
|
* This is used by the shell to define $ZSH_PATCHLEVEL
|
||||||
* $Revision: 1.4517 $
|
* $Revision: 1.4518 $
|
||||||
*****************************************************
|
*****************************************************
|
||||||
|
|
|
@ -60,12 +60,13 @@ or more names. If all of a keymap's names are deleted, it disappears.
|
||||||
findex(bindkey, use of)
|
findex(bindkey, use of)
|
||||||
tt(bindkey) can be used to manipulate keymap names.
|
tt(bindkey) can be used to manipulate keymap names.
|
||||||
|
|
||||||
Initially, there are four keymaps:
|
Initially, there are five keymaps:
|
||||||
|
|
||||||
startsitem()
|
startsitem()
|
||||||
sitem(tt(emacs))(EMACS emulation)
|
sitem(tt(emacs))(EMACS emulation)
|
||||||
sitem(tt(viins))(vi emulation - insert mode)
|
sitem(tt(viins))(vi emulation - insert mode)
|
||||||
sitem(tt(vicmd))(vi emulation - command mode)
|
sitem(tt(vicmd))(vi emulation - command mode)
|
||||||
|
sitem(tt(isearch))(incremental search mode)
|
||||||
sitem(tt(.safe))(fallback keymap)
|
sitem(tt(.safe))(fallback keymap)
|
||||||
endsitem()
|
endsitem()
|
||||||
|
|
||||||
|
@ -76,7 +77,7 @@ avoid using names beginning with `tt(.)' for their own keymaps.
|
||||||
|
|
||||||
vindex(VISUAL)
|
vindex(VISUAL)
|
||||||
vindex(EDITOR)
|
vindex(EDITOR)
|
||||||
In addition to these four names, either `tt(emacs)' or `tt(viins)' is
|
In addition to these names, either `tt(emacs)' or `tt(viins)' is
|
||||||
also linked to the name `tt(main)'. If one of the tt(VISUAL) or
|
also linked to the name `tt(main)'. If one of the tt(VISUAL) or
|
||||||
tt(EDITOR) environment variables contain the string `tt(vi)' when the shell
|
tt(EDITOR) environment variables contain the string `tt(vi)' when the shell
|
||||||
starts up then it will be `tt(viins)', otherwise it will be `tt(emacs)'.
|
starts up then it will be `tt(viins)', otherwise it will be `tt(emacs)'.
|
||||||
|
@ -1115,9 +1116,14 @@ numeric argument was given. The string may begin with `tt(^)' to anchor the
|
||||||
search to the beginning of the line.
|
search to the beginning of the line.
|
||||||
|
|
||||||
A restricted set of editing functions
|
A restricted set of editing functions
|
||||||
is available in the mini-buffer. An interrupt signal, as defined by the stty
|
is available in the mini-buffer. Keys are looked up in the special
|
||||||
|
tt(isearch) keymap, and if not found there in the main keymap (note
|
||||||
|
that by default the tt(isearch) keymap is empty).
|
||||||
|
An interrupt signal, as defined by the stty
|
||||||
setting, will stop the search and go back to the original line. An undefined
|
setting, will stop the search and go back to the original line. An undefined
|
||||||
key will have the same effect. The supported functions are:
|
key will have the same effect. Note that the following always
|
||||||
|
perform the same task within incremental searches and cannot be
|
||||||
|
replaced by user defined widgets. The supported functions are:
|
||||||
|
|
||||||
startitem()
|
startitem()
|
||||||
xitem(tt(accept-and-hold))
|
xitem(tt(accept-and-hold))
|
||||||
|
@ -1133,6 +1139,11 @@ Back up one place in the search history. If the search has been
|
||||||
repeated this does not immediately erase a character in the
|
repeated this does not immediately erase a character in the
|
||||||
minibuffer.
|
minibuffer.
|
||||||
)
|
)
|
||||||
|
item(tt(accept-search))(
|
||||||
|
Exit incremental search, retaining the command line but performing no
|
||||||
|
further action. Note that this function is not bound by default
|
||||||
|
and has no effect outside incremental search.
|
||||||
|
)
|
||||||
xitem(tt(backward-delete-word))
|
xitem(tt(backward-delete-word))
|
||||||
xitem(tt(backward-kill-word))
|
xitem(tt(backward-kill-word))
|
||||||
item(tt(vi-backward-kill-word))(
|
item(tt(vi-backward-kill-word))(
|
||||||
|
|
|
@ -13,6 +13,7 @@
|
||||||
"accept-and-menu-complete", acceptandmenucomplete, ZLE_MENUCMP | ZLE_KEEPSUFFIX
|
"accept-and-menu-complete", acceptandmenucomplete, ZLE_MENUCMP | ZLE_KEEPSUFFIX
|
||||||
"accept-line", acceptline, 0
|
"accept-line", acceptline, 0
|
||||||
"accept-line-and-down-history", acceptlineanddownhistory, 0
|
"accept-line-and-down-history", acceptlineanddownhistory, 0
|
||||||
|
"accept-search", NULL, 0
|
||||||
"argument-base", argumentbase, ZLE_MENUCMP | ZLE_KEEPSUFFIX | ZLE_LASTCOL | ZLE_NOTCOMMAND
|
"argument-base", argumentbase, ZLE_MENUCMP | ZLE_KEEPSUFFIX | ZLE_LASTCOL | ZLE_NOTCOMMAND
|
||||||
"auto-suffix-remove", handlesuffix, ZLE_NOTCOMMAND
|
"auto-suffix-remove", handlesuffix, ZLE_NOTCOMMAND
|
||||||
"auto-suffix-retain", handlesuffix, ZLE_KEEPSUFFIX | ZLE_NOTCOMMAND
|
"auto-suffix-retain", handlesuffix, ZLE_KEEPSUFFIX | ZLE_NOTCOMMAND
|
||||||
|
|
|
@ -49,6 +49,10 @@ ZLE_STRING_T previous_search = NULL;
|
||||||
/**/
|
/**/
|
||||||
int previous_search_len = 0;
|
int previous_search_len = 0;
|
||||||
|
|
||||||
|
/* Local keymap in isearch mode */
|
||||||
|
|
||||||
|
/**/
|
||||||
|
Keymap isearch_keymap;
|
||||||
|
|
||||||
/*** History text manipulation utilities ***/
|
/*** History text manipulation utilities ***/
|
||||||
|
|
||||||
|
@ -1141,6 +1145,8 @@ doisearch(char **args, int dir, int pattern)
|
||||||
if (!(he = quietgethist(hl)))
|
if (!(he = quietgethist(hl)))
|
||||||
return;
|
return;
|
||||||
|
|
||||||
|
selectlocalmap(isearch_keymap);
|
||||||
|
|
||||||
clearlist = 1;
|
clearlist = 1;
|
||||||
|
|
||||||
if (*args) {
|
if (*args) {
|
||||||
|
@ -1572,6 +1578,8 @@ doisearch(char **args, int dir, int pattern)
|
||||||
feep = 1;
|
feep = 1;
|
||||||
else
|
else
|
||||||
goto ins;
|
goto ins;
|
||||||
|
} else if (cmd == Th(z_acceptsearch)) {
|
||||||
|
break;
|
||||||
} else {
|
} else {
|
||||||
if(cmd == Th(z_selfinsertunmeta)) {
|
if(cmd == Th(z_selfinsertunmeta)) {
|
||||||
fixunmeta();
|
fixunmeta();
|
||||||
|
@ -1640,6 +1648,8 @@ doisearch(char **args, int dir, int pattern)
|
||||||
*/
|
*/
|
||||||
if (savekeys >= 0 && kungetct > savekeys)
|
if (savekeys >= 0 && kungetct > savekeys)
|
||||||
kungetct = savekeys;
|
kungetct = savekeys;
|
||||||
|
|
||||||
|
selectlocalmap(NULL);
|
||||||
}
|
}
|
||||||
|
|
||||||
static Histent
|
static Histent
|
||||||
|
|
|
@ -1176,6 +1176,8 @@ default_bindings(void)
|
||||||
char buf[3], *ed;
|
char buf[3], *ed;
|
||||||
int i;
|
int i;
|
||||||
|
|
||||||
|
isearch_keymap = newkeymap(NULL, "isearch");
|
||||||
|
|
||||||
/* vi insert mode and emacs mode: *
|
/* vi insert mode and emacs mode: *
|
||||||
* 0-31 taken from the tables *
|
* 0-31 taken from the tables *
|
||||||
* 32-126 self-insert *
|
* 32-126 self-insert *
|
||||||
|
@ -1274,6 +1276,8 @@ default_bindings(void)
|
||||||
else
|
else
|
||||||
linkkeymap(emap, "main", 0);
|
linkkeymap(emap, "main", 0);
|
||||||
|
|
||||||
|
linkkeymap(isearch_keymap, "isearch", 0);
|
||||||
|
|
||||||
/* the .safe map cannot be modified or deleted */
|
/* the .safe map cannot be modified or deleted */
|
||||||
smap->flags |= KM_IMMUTABLE;
|
smap->flags |= KM_IMMUTABLE;
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in a new issue