summary refs log tree commit diff
diff options
context:
space:
mode:
authorPeter Stephenson <pws@users.sourceforge.net>2009-01-19 17:57:43 +0000
committerPeter Stephenson <pws@users.sourceforge.net>2009-01-19 17:57:43 +0000
commit46cdeb71b7c8dae7517ef832130049dc1e821cb6 (patch)
treec11b0fc3b9fef873d86fcfff1455d27b4dab295e
parent8541ccb842c27c8e8ff14e4e0718f7b14efee0b2 (diff)
downloadzsh-46cdeb71b7c8dae7517ef832130049dc1e821cb6.tar.gz
zsh-46cdeb71b7c8dae7517ef832130049dc1e821cb6.tar.xz
zsh-46cdeb71b7c8dae7517ef832130049dc1e821cb6.zip
26366: add "isearch" keymap and "accept-search" functino
-rw-r--r--ChangeLog6
-rw-r--r--Doc/Zsh/zle.yo19
-rw-r--r--Src/Zle/iwidgets.list1
-rw-r--r--Src/Zle/zle_hist.c10
-rw-r--r--Src/Zle/zle_keymap.c4
5 files changed, 35 insertions, 5 deletions
diff --git a/ChangeLog b/ChangeLog
index 2963acfdb..7105b2169 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -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 $                         
 *****************************************************
diff --git a/Doc/Zsh/zle.yo b/Doc/Zsh/zle.yo
index af339d37f..c17271778 100644
--- a/Doc/Zsh/zle.yo
+++ b/Doc/Zsh/zle.yo
@@ -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))(
diff --git a/Src/Zle/iwidgets.list b/Src/Zle/iwidgets.list
index 6c82f9b61..4372fe36e 100644
--- a/Src/Zle/iwidgets.list
+++ b/Src/Zle/iwidgets.list
@@ -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
diff --git a/Src/Zle/zle_hist.c b/Src/Zle/zle_hist.c
index c4dad7617..aec847ec6 100644
--- a/Src/Zle/zle_hist.c
+++ b/Src/Zle/zle_hist.c
@@ -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
diff --git a/Src/Zle/zle_keymap.c b/Src/Zle/zle_keymap.c
index 9dac62049..30c747900 100644
--- a/Src/Zle/zle_keymap.c
+++ b/Src/Zle/zle_keymap.c
@@ -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;
 }