1
0
Fork 0
mirror of git://git.code.sf.net/p/zsh/code synced 2025-09-02 10:01:11 +02:00

26366: add "isearch" keymap and "accept-search" functino

This commit is contained in:
Peter Stephenson 2009-01-19 17:57:43 +00:00
parent 8541ccb842
commit 46cdeb71b7
5 changed files with 35 additions and 5 deletions

View file

@ -1,5 +1,9 @@
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
options.
@ -10948,5 +10952,5 @@
*****************************************************
* This is used by the shell to define $ZSH_PATCHLEVEL
* $Revision: 1.4517 $
* $Revision: 1.4518 $
*****************************************************

View file

@ -60,12 +60,13 @@ or more names. If all of a keymap's names are deleted, it disappears.
findex(bindkey, use of)
tt(bindkey) can be used to manipulate keymap names.
Initially, there are four keymaps:
Initially, there are five keymaps:
startsitem()
sitem(tt(emacs))(EMACS emulation)
sitem(tt(viins))(vi emulation - insert mode)
sitem(tt(vicmd))(vi emulation - command mode)
sitem(tt(isearch))(incremental search mode)
sitem(tt(.safe))(fallback keymap)
endsitem()
@ -76,7 +77,7 @@ avoid using names beginning with `tt(.)' for their own keymaps.
vindex(VISUAL)
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
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)'.
@ -1115,9 +1116,14 @@ numeric argument was given. The string may begin with `tt(^)' to anchor the
search to the beginning of the line.
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
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()
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
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-kill-word))
item(tt(vi-backward-kill-word))(

View file

@ -13,6 +13,7 @@
"accept-and-menu-complete", acceptandmenucomplete, ZLE_MENUCMP | ZLE_KEEPSUFFIX
"accept-line", acceptline, 0
"accept-line-and-down-history", acceptlineanddownhistory, 0
"accept-search", NULL, 0
"argument-base", argumentbase, ZLE_MENUCMP | ZLE_KEEPSUFFIX | ZLE_LASTCOL | ZLE_NOTCOMMAND
"auto-suffix-remove", handlesuffix, ZLE_NOTCOMMAND
"auto-suffix-retain", handlesuffix, ZLE_KEEPSUFFIX | ZLE_NOTCOMMAND

View file

@ -49,6 +49,10 @@ ZLE_STRING_T previous_search = NULL;
/**/
int previous_search_len = 0;
/* Local keymap in isearch mode */
/**/
Keymap isearch_keymap;
/*** History text manipulation utilities ***/
@ -1141,6 +1145,8 @@ doisearch(char **args, int dir, int pattern)
if (!(he = quietgethist(hl)))
return;
selectlocalmap(isearch_keymap);
clearlist = 1;
if (*args) {
@ -1572,6 +1578,8 @@ doisearch(char **args, int dir, int pattern)
feep = 1;
else
goto ins;
} else if (cmd == Th(z_acceptsearch)) {
break;
} else {
if(cmd == Th(z_selfinsertunmeta)) {
fixunmeta();
@ -1640,6 +1648,8 @@ doisearch(char **args, int dir, int pattern)
*/
if (savekeys >= 0 && kungetct > savekeys)
kungetct = savekeys;
selectlocalmap(NULL);
}
static Histent

View file

@ -1176,6 +1176,8 @@ default_bindings(void)
char buf[3], *ed;
int i;
isearch_keymap = newkeymap(NULL, "isearch");
/* vi insert mode and emacs mode: *
* 0-31 taken from the tables *
* 32-126 self-insert *
@ -1274,6 +1276,8 @@ default_bindings(void)
else
linkkeymap(emap, "main", 0);
linkkeymap(isearch_keymap, "isearch", 0);
/* the .safe map cannot be modified or deleted */
smap->flags |= KM_IMMUTABLE;
}