diff options
author | Peter Stephenson <pws@users.sourceforge.net> | 2009-01-28 09:31:53 +0000 |
---|---|---|
committer | Peter Stephenson <pws@users.sourceforge.net> | 2009-01-28 09:31:53 +0000 |
commit | af39a5ab1a4f0b154ac212fdeb86bad322b32056 (patch) | |
tree | 45a825b359c708c6acfec4f4c037a8beea2b6436 | |
parent | 7c43fb69bf81dd37c0743a761c6b43519ea9a0d0 (diff) | |
download | zsh-af39a5ab1a4f0b154ac212fdeb86bad322b32056.tar.gz zsh-af39a5ab1a4f0b154ac212fdeb86bad322b32056.tar.xz zsh-af39a5ab1a4f0b154ac212fdeb86bad322b32056.zip |
26463: Greg Klanderman: add zle-line-finish widget
26464: Greg Klanderman: fix insert-ids=single for menu completion 26465: Greg Klanderman: command keymap for execution
-rw-r--r-- | ChangeLog | 13 | ||||
-rw-r--r-- | Completion/Unix/Type/_pids | 3 | ||||
-rw-r--r-- | Doc/Zsh/zle.yo | 15 | ||||
-rw-r--r-- | Src/Zle/zle_keymap.c | 15 | ||||
-rw-r--r-- | Src/Zle/zle_main.c | 13 | ||||
-rw-r--r-- | Src/Zle/zle_misc.c | 22 |
6 files changed, 70 insertions, 11 deletions
diff --git a/ChangeLog b/ChangeLog index 9ddc81860..86cd7cb17 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,3 +1,14 @@ +2009-01-28 Peter Stephenson <pws@csr.com> + + * Greg Klanderman: 26465: Doc/Zsh/zle.yo, Src/Zle/zle_keymap.c: + add command keymap for command execution. + + * Greg Klanderman: 26464: Completion/Unix/Type/_pids: style + insert-ids=single was problematic with menu completion. + + * Greg Klanderman: 26463: Doc/Zsh/zle.yo, Src/Zle/zle_main.c: add + zle-line-finish widget. + 2009-01-27 Peter Stephenson <pws@csr.com> * 26448: Doc/Zsh/expn.yo, Src/glob.c: glob sort operators @@ -11012,5 +11023,5 @@ ***************************************************** * This is used by the shell to define $ZSH_PATCHLEVEL -* $Revision: 1.4528 $ +* $Revision: 1.4529 $ ***************************************************** diff --git a/Completion/Unix/Type/_pids b/Completion/Unix/Type/_pids index 18ed4616e..ea5ed79ee 100644 --- a/Completion/Unix/Type/_pids +++ b/Completion/Unix/Type/_pids @@ -45,7 +45,8 @@ if [[ -n "$all" ]]; then case "$out" in menu) compstate[insert]=menu ;; - single) [[ $compstate[nmatches] -ne nm+1 ]] && compstate[insert]= ;; + single) [[ $compstate[nmatches] -ne nm+1 && $compstate[insert] != menu ]] && + compstate[insert]= ;; *) [[ ${#:-$PREFIX$SUFFIX} -gt ${#compstate[unambiguous]} ]] && compstate[insert]=menu ;; esac diff --git a/Doc/Zsh/zle.yo b/Doc/Zsh/zle.yo index c17271778..5e375d7cc 100644 --- a/Doc/Zsh/zle.yo +++ b/Doc/Zsh/zle.yo @@ -60,13 +60,14 @@ 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 five keymaps: +Initially, there are six 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(command))(read a command name) sitem(tt(.safe))(fallback keymap) endsitem() @@ -871,6 +872,11 @@ zle -N zle-line-init) (The command inside the function sets the keymap directly; it is equivalent to tt(zle vi-cmd-mode).) ) +tindex(zle-line-finish) +item(tt(zle-line-finish))( +This is similar to tt(zle-line-init) but is executed every time the +line editor has finished reading a line of input. +) tindex(zle-keymap-select) item(tt(zle-keymap-select))( Executed every time the keymap changes, i.e. the special parameter @@ -1862,7 +1868,9 @@ tindex(execute-named-cmd) item(tt(execute-named-cmd) (ESC-x) (unbound) (unbound))( Read the name of an editor command and execute it. A restricted set of editing functions is available in the -mini-buffer. An interrupt signal, as defined by the stty setting, will +mini-buffer. Keys are looked up in the special +tt(command) keymap, and if not found there in the main keymap. +An interrupt signal, as defined by the stty setting, will abort the function. The allowed functions are: tt(backward-delete-char), tt(vi-backward-delete-char), @@ -2087,6 +2095,9 @@ tindex(where-is) item(tt(where-is))( Read the name of an editor command and and print the listing of key sequences that invoke the specified command. +A restricted set of editing functions is available in the +mini-buffer. Keys are looked up in the special +tt(command) keymap, and if not found there in the main keymap. ) tindex(which-command) item(tt(which-command) (ESC-?) (unbound) (unbound))( diff --git a/Src/Zle/zle_keymap.c b/Src/Zle/zle_keymap.c index 30c747900..7f59d9d9b 100644 --- a/Src/Zle/zle_keymap.c +++ b/Src/Zle/zle_keymap.c @@ -1176,8 +1176,6 @@ 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 * @@ -1276,10 +1274,19 @@ 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; + + /* isearch keymap: initially empty */ + isearch_keymap = newkeymap(NULL, "isearch"); + linkkeymap(isearch_keymap, "isearch", 0); + + /* command keymap: make sure accept-line and send-break are bound */ + command_keymap = newkeymap(NULL, "command"); + command_keymap->first['\n'] = refthingy(t_acceptline); + command_keymap->first['\r'] = refthingy(t_acceptline); + command_keymap->first['G'&0x1F] = refthingy(t_sendbreak); + linkkeymap(command_keymap, "command", 0); } /*************************/ diff --git a/Src/Zle/zle_main.c b/Src/Zle/zle_main.c index 9106083ed..ef14342bc 100644 --- a/Src/Zle/zle_main.c +++ b/Src/Zle/zle_main.c @@ -1212,6 +1212,19 @@ zleread(char **lp, char **rp, int flags, int context) zlecore(); + if (done && !exit_pending && !errflag && + (initthingy = rthingy_nocreate("zle-line-finish"))) { + int saverrflag = errflag; + int savretflag = retflag; + char *args[2]; + args[0] = initthingy->nam; + args[1] = NULL; + execzlefunc(initthingy, args, 1); + unrefthingy(initthingy); + errflag = saverrflag; + retflag = savretflag; + } + statusline = NULL; invalidatelist(); trashzle(); diff --git a/Src/Zle/zle_misc.c b/Src/Zle/zle_misc.c index 738e7b8c4..961776f43 100644 --- a/Src/Zle/zle_misc.c +++ b/Src/Zle/zle_misc.c @@ -966,11 +966,19 @@ scancompcmd(HashNode hn, UNUSED(int flags)) #define NAMLEN 60 +/* + * Local keymap used when reading a command name for the + * execute-named-command and where-is widgets. + */ + +/**/ +Keymap command_keymap; + /**/ Thingy executenamedcommand(char *prmt) { - Thingy cmd; + Thingy cmd, retval = NULL; int l, len, feep = 0, listed = 0, curlist = 0; int ols = (listshown && validlist), olll = lastlistlen; char *cmdbuf, *ptr; @@ -988,6 +996,7 @@ executenamedcommand(char *prmt) strcpy(cmdbuf, prmt); zsfree(prmt); statusline = cmdbuf; + selectlocalmap(command_keymap); selectkeymap("main", 1); ptr = cmdbuf += l; len = 0; @@ -1005,7 +1014,8 @@ executenamedcommand(char *prmt) } else if (listed) clearlist = listshown = 1; - return NULL; + retval = NULL; + goto done; } if(cmd == Th(z_clearscreen)) { clearscreen(zlenoargs); @@ -1090,7 +1100,9 @@ executenamedcommand(char *prmt) lastlistlen = olll; } else if (listed) clearlist = listshown = 1; - return r; + + retval = r; + goto done; } unrefthingy(r); } @@ -1180,6 +1192,10 @@ executenamedcommand(char *prmt) handlefeep(zlenoargs); feep = 0; } + + done: + selectlocalmap(NULL); + return retval; } /*****************/ |