about summary refs log tree commit diff
path: root/Src
diff options
context:
space:
mode:
authorTanaka Akira <akr@users.sourceforge.net>1999-06-27 06:54:32 +0000
committerTanaka Akira <akr@users.sourceforge.net>1999-06-27 06:54:32 +0000
commitb09922bb063ddf44c7850b182fec4795fbe1ae90 (patch)
tree8a6dfa5ef6c6012753c0dc5a6e93e6f820b51a58 /Src
parent346825df86466cf151be61b9429ef2c1734e66ea (diff)
downloadzsh-b09922bb063ddf44c7850b182fec4795fbe1ae90.tar.gz
zsh-b09922bb063ddf44c7850b182fec4795fbe1ae90.tar.xz
zsh-b09922bb063ddf44c7850b182fec4795fbe1ae90.zip
zsh-3.1.5-pws-23 zsh-3.1.5-pws-23
Diffstat (limited to 'Src')
-rw-r--r--Src/Zle/.distfiles1
-rw-r--r--Src/Zle/comp.h24
-rw-r--r--Src/Zle/compctl.c6
-rw-r--r--Src/Zle/deltochar.c2
-rw-r--r--Src/Zle/iwidgets.list1
-rw-r--r--Src/Zle/zle.export34
-rw-r--r--Src/Zle/zle.h6
-rw-r--r--Src/Zle/zle_hist.c78
-rw-r--r--Src/Zle/zle_keymap.c65
-rw-r--r--Src/Zle/zle_main.c31
-rw-r--r--Src/Zle/zle_misc.c48
-rw-r--r--Src/Zle/zle_move.c35
-rw-r--r--Src/Zle/zle_params.c2
-rw-r--r--Src/Zle/zle_thingy.c41
-rw-r--r--Src/Zle/zle_tricky.c344
-rw-r--r--Src/Zle/zle_utils.c24
-rw-r--r--Src/Zle/zle_vi.c126
-rw-r--r--Src/Zle/zle_word.c16
-rw-r--r--Src/builtin.c38
-rw-r--r--Src/exec.c43
-rw-r--r--Src/glob.c2
-rw-r--r--Src/hashtable.c1
-rw-r--r--Src/init.c11
-rw-r--r--Src/jobs.c9
-rw-r--r--Src/loop.c2
-rw-r--r--Src/module.c254
-rw-r--r--Src/params.c9
-rw-r--r--Src/subst.c11
-rw-r--r--Src/utils.c16
-rw-r--r--Src/xmods.conf1
-rw-r--r--Src/zsh.export5
-rw-r--r--Src/zsh.h32
32 files changed, 488 insertions, 830 deletions
diff --git a/Src/Zle/.distfiles b/Src/Zle/.distfiles
index add8f8466..9dbf27758 100644
--- a/Src/Zle/.distfiles
+++ b/Src/Zle/.distfiles
@@ -2,7 +2,6 @@ DISTFILES_SRC='
     .cvsignore .distfiles .exrc
     comp1.mdd comp.h comp1.c comp1.export
     compctl.mdd compctl.c
-    complist.mdd complist.c
     deltochar.mdd deltochar.c
     zle.mdd iwidgets.list zle.h zle_bindings.c zle_hist.c
     zle_keymap.c zle_main.c zle_misc.c zle_move.c zle_params.c
diff --git a/Src/Zle/comp.h b/Src/Zle/comp.h
index 8264890df..78c65ffeb 100644
--- a/Src/Zle/comp.h
+++ b/Src/Zle/comp.h
@@ -36,7 +36,6 @@ typedef struct patcomp   *Patcomp;
 typedef struct cmatcher  *Cmatcher;
 typedef struct cmlist    *Cmlist;
 typedef struct cpattern  *Cpattern;
-typedef struct menuinfo  *Menuinfo;
 
 /* node for compctl hash table (compctltab) */
 
@@ -267,19 +266,6 @@ struct cpattern {
 #define CFN_FIRST   1
 #define CFN_DEFAULT 2
 
-/* Information about menucompletion stuff. */
-
-struct menuinfo {
-    Cmgroup group;		/* position in the group list */
-    Cmatch *cur;		/* match currently inserted */
-    int pos;			/* begin on line */
-    int len;			/* length of inserted string */
-    int end;			/* end on the line */
-    int we;			/* non-zero if the cursor was at the end */
-    int insc;			/* length of suffix inserted */
-    int asked;			/* we asked if the list should be shown */
-};
-
 /* Flags for compadd and addmatches(). */
 
 #define CAF_QUOTE    1
@@ -313,16 +299,6 @@ struct cadata {
     char *dpar;			/* array to delete non-matches in (-D) */
 };
 
-/* Data given to hooks. */
-
-typedef struct chdata *Chdata;
-
-struct chdata {
-    Cmgroup matches;		/* the matches generated */
-    int num;			/* the number of matches */
-    Cmatch cur;			/* current match or NULL */
-};
-
 /* Flags for special parameters. */
 
 #define CPN_WORDS      0
diff --git a/Src/Zle/compctl.c b/Src/Zle/compctl.c
index 2b426492e..e0f9a9089 100644
--- a/Src/Zle/compctl.c
+++ b/Src/Zle/compctl.c
@@ -2221,8 +2221,7 @@ static void
 addcompparams(struct compparam *cp, Param *pp)
 {
     for (; cp->name; cp++, pp++) {
-	Param pm = createparam(cp->name,
-			       cp->type |PM_SPECIAL|PM_REMOVABLE|PM_LOCAL);
+	Param pm = createparam(cp->name, cp->type | PM_SPECIAL | PM_REMOVABLE);
 	if (!pm)
 	    pm = (Param) paramtab->getnode(paramtab, cp->name);
 	DPUTS(!pm, "param not set in addcompparams");
@@ -2262,8 +2261,7 @@ makecompparams(void)
 
     addcompparams(comprparams, comprpms);
 
-    if (!(cpm = createparam(COMPSTATENAME,
-			    PM_SPECIAL|PM_REMOVABLE|PM_LOCAL|PM_HASHED)))
+    if (!(cpm = createparam(COMPSTATENAME, PM_SPECIAL|PM_REMOVABLE|PM_HASHED)))
 	cpm = (Param) paramtab->getnode(paramtab, COMPSTATENAME);
     DPUTS(!cpm, "param not set in makecompparams");
 
diff --git a/Src/Zle/deltochar.c b/Src/Zle/deltochar.c
index f0df33f95..b9fb34f10 100644
--- a/Src/Zle/deltochar.c
+++ b/Src/Zle/deltochar.c
@@ -67,6 +67,8 @@ deltochar(char **args)
 	    }
 	}
     }
+    if (!ok)
+	feep();
     return !ok;
 }
 
diff --git a/Src/Zle/iwidgets.list b/Src/Zle/iwidgets.list
index c28acb438..e0c93bd03 100644
--- a/Src/Zle/iwidgets.list
+++ b/Src/Zle/iwidgets.list
@@ -19,7 +19,6 @@
 "backward-kill-line", backwardkillline, ZLE_KILL | ZLE_KEEPSUFFIX
 "backward-kill-word", backwardkillword, ZLE_KILL | ZLE_KEEPSUFFIX
 "backward-word", backwardword, 0
-"beep", handlefeep, 0
 "beginning-of-buffer-or-history", beginningofbufferorhistory, 0
 "beginning-of-history", beginningofhistory, 0
 "beginning-of-line", beginningofline, 0
diff --git a/Src/Zle/zle.export b/Src/Zle/zle.export
index e0b88cd5c..ccd5df98a 100644
--- a/Src/Zle/zle.export
+++ b/Src/Zle/zle.export
@@ -1,44 +1,10 @@
 #!
-acceptlast
 addzlefunction
 backdel
 backkill
-bindkey
-clearflag
-clearscreen
 deletezlefunction
-do_menucmp
-do_single
 feep
 foredel
 forekill
 getkey
-getkeycmd
-getzlequery
-linkkeymap
-listshown
-menucomplete
-menucur
-menugrp
-minfo
-newkeymap
-nlnct
-printfmt
-redisplay
-refthingy
-reversemenucomplete
-selectlocalmap
-showinglist
-skipnolist
-spaceinline
-tcmultout
-tcout
-thingies
-trashzle
-ungetkeycmd
-unlinkkeymap
-zlenoargs
 zmod
-zrefresh
-zsetterm
-ztat
diff --git a/Src/Zle/zle.h b/Src/Zle/zle.h
index ff515e7c4..8ab86f042 100644
--- a/Src/Zle/zle.h
+++ b/Src/Zle/zle.h
@@ -143,9 +143,3 @@ typedef struct cutbuffer *Cutbuffer;
 #define CUTBUFFER_LINE 1   /* for vi: buffer contains whole lines of data */
 
 #define KRINGCT 8   /* number of buffers in the kill ring */
-
-/* Convenience macros for the hooks */
-
-#define LISTMATCHESHOOK (zlehooks + 0)
-#define INSERTMATCHHOOK (zlehooks + 1)
-#define MENUSTARTHOOK   (zlehooks + 2)
diff --git a/Src/Zle/zle_hist.c b/Src/Zle/zle_hist.c
index f85fa00a6..66abbe438 100644
--- a/Src/Zle/zle_hist.c
+++ b/Src/Zle/zle_hist.c
@@ -77,8 +77,10 @@ int
 uphistory(char **args)
 {
     int nodups = isset(HISTIGNOREDUPS);
-    if (!zle_goto_hist(histline, -zmult, nodups) && isset(HISTBEEP))
+    if (!zle_goto_hist(histline, -zmult, nodups) && isset(HISTBEEP)) {
+	feep();
 	return 1;
+    }
     return 0;
 }
 
@@ -126,8 +128,10 @@ uplineorhistory(char **args)
 	int m = zmult, ret;
 
 	cs = ocs;
-	if (virangeflag || !histallowed)
+	if (virangeflag || !histallowed) {
+	    feep();
 	    return 1;
+	}
 	zmult = n;
 	ret = uphistory(args);
 	zmult = m;
@@ -156,8 +160,10 @@ uplineorsearch(char **args)
 	int m = zmult, ret;
 
 	cs = ocs;
-	if (virangeflag || !histallowed)
+	if (virangeflag || !histallowed) {
+	    feep();
 	    return 1;
+	}
 	zmult = n;
 	ret = historysearchbackward(args);
 	zmult = m;
@@ -210,8 +216,10 @@ downlineorhistory(char **args)
 	int m = zmult, ret;
 
 	cs = ocs;
-	if (virangeflag || !histallowed)
+	if (virangeflag || !histallowed) {
+	    feep();
 	    return 1;
+	}
 	zmult = n;
 	ret = downhistory(args);
 	zmult = m;
@@ -240,8 +248,10 @@ downlineorsearch(char **args)
 	int m = zmult, ret;
 
 	cs = ocs;
-	if (virangeflag || !histallowed)
+	if (virangeflag || !histallowed) {
+	    feep();
 	    return 1;
+	}
 	zmult = n;
 	ret = historysearchforward(args);
 	zmult = m;
@@ -256,8 +266,10 @@ acceptlineanddownhistory(char **args)
 {
     Histent he;
 
-    if (!(he = movehistent(quietgethist(histline), 1, HIST_FOREIGN)))
+    if (!(he = movehistent(quietgethist(histline), 1, HIST_FOREIGN))) {
+	feep();
 	return 1;
+    }
     pushnode(bufstack, ztrdup(ZLETEXT(he)));
     done = 1;
     stackhist = he->histnum;
@@ -269,8 +281,10 @@ int
 downhistory(char **args)
 {
     int nodups = isset(HISTIGNOREDUPS);
-    if (!zle_goto_hist(histline, zmult, nodups) && isset(HISTBEEP))
+    if (!zle_goto_hist(histline, zmult, nodups) && isset(HISTBEEP)) {
+	feep();
 	return 1;
+    }
     return 0;
 }
 
@@ -322,6 +336,7 @@ historysearchbackward(char **args)
 	    }
 	}
     }
+    feep();
     return 1;
 }
 
@@ -370,6 +385,7 @@ historysearchforward(char **args)
 	    }
 	}
     }
+    feep();
     return 1;
 }
 
@@ -388,8 +404,10 @@ beginningofbufferorhistory(char **args)
 int
 beginningofhistory(char **args)
 {
-    if (!zle_goto_hist(firsthist(), 0, 0) && isset(HISTBEEP))
+    if (!zle_goto_hist(firsthist(), 0, 0) && isset(HISTBEEP)) {
+	feep();
 	return 1;
+    }
     return 0;
 }
 
@@ -439,15 +457,19 @@ insertlastword(char **args)
 	zsfree(lastinsert);
 	lastinsert = NULL;
     }
-    if (!(he = quietgethist(evhist)) || !he->nwords)
+    if (!(he = quietgethist(evhist)) || !he->nwords) {
+	feep();
 	return 1;
+    }
     if (zmult > 0) {
 	n = he->nwords - (zmult - 1);
     } else {
 	n = 1 - zmult;
     }
-    if (n < 1 || n > he->nwords)
+    if (n < 1 || n > he->nwords) {
+	feep();
 	return 1;
+    }
     s = he->text + he->words[2*n-2];
     t = he->text + he->words[2*n-1];
     save = *t;
@@ -569,6 +591,7 @@ getline(char **args)
     char *s = (char *)getlinknode(bufstack);
 
     if (!s) {
+	feep();
 	return 1;
     } else {
 	int cc;
@@ -670,7 +693,7 @@ doisearch(char **args, int dir)
     int sbptr = 0, top_spot = 0, pos, sibuf = 80;
     int nomatch = 0, skip_line = 0, skip_pos = 0;
     int odir = dir, sens = zmult == 1 ? 3 : 1;
-    int hl = histline, savekeys = -1, feep = 0;
+    int hl = histline, savekeys = -1;
     Thingy cmd;
     char *okeymap = curkeymapname;
     static char *previous_search = NULL;
@@ -739,7 +762,7 @@ doisearch(char **args, int dir)
 		    get_isrch_spot(top_spot, &hl, &pos, &cs, &sbptr,
 				   &dir, &nomatch);
 		    if (!nomatch) {
-			feep = 1;
+			feep();
 			nomatch = 1;
 		    }
 		    he = quietgethist(hl);
@@ -780,7 +803,7 @@ doisearch(char **args, int dir)
 	    goto ref;
 	} else if(cmd == Th(z_vicmdmode)) {
 	    if(selectkeymap(invicmdmode() ? "main" : "vicmd", 0))
-		feep = 1;
+		feep();
 	    goto ref;
 	} else if(cmd == Th(z_vibackwarddeletechar) ||
 	    	cmd == Th(z_backwarddeletechar)) {
@@ -788,7 +811,7 @@ doisearch(char **args, int dir)
 		get_isrch_spot(--top_spot, &hl, &pos, &cs, &sbptr,
 			       &dir, &nomatch);
 	    else
-		feep = 1;
+		feep();
 	    if (nomatch) {
 		statusline = ibuf;
 		skip_pos = 1;
@@ -855,7 +878,7 @@ doisearch(char **args, int dir)
 		zrefresh();
 	    }
 	    if ((c = getkey(0)) == EOF)
-		feep = 1;
+		feep();
 	    else
 		goto ins;
 	} else {
@@ -873,7 +896,7 @@ doisearch(char **args, int dir)
 	    }
 	ins:
 	    if (sbptr == PATH_MAX) {
-		feep = 1;
+		feep();
 		continue;
 	    }
 	    set_isrch_spot(top_spot++, hl, pos, cs, sbptr, dir, nomatch);
@@ -884,9 +907,7 @@ doisearch(char **args, int dir)
 	    }
 	    sbuf[sbptr++] = c;
 	}
-	if (feep)
-	    handlefeep(zlenoargs);
-	feep = 0;
+	handlefeep();
     }
     if (sbptr) {
 	zfree(previous_search, previous_search_len);
@@ -936,6 +957,7 @@ infernexthistory(char **args)
 	    return 0;
 	}
     }
+    feep();
     return 1;
 }
 
@@ -954,6 +976,7 @@ vifetchhistory(char **args)
     }
     if (!zle_goto_hist((zmod.flags & MOD_MULT) ? zmult : curhist, 0, 0) &&
 	isset(HISTBEEP)) {
+	feep();
 	return 1;
     }
     return 0;
@@ -969,7 +992,7 @@ static int
 getvisrchstr(void)
 {
     char *sbuf = zhalloc(80);
-    int sptr = 1, ret = 0, ssbuf = 80, feep = 0;
+    int sptr = 1, ret = 0, ssbuf = 80;
     Thingy cmd;
     char *okeymap = curkeymapname;
 
@@ -1022,7 +1045,7 @@ getvisrchstr(void)
 		zrefresh();
 	    }
 	    if ((c = getkey(0)) == EOF)
-		feep = 1;
+		feep();
 	    else
 		goto ins;
 	} else if(cmd == Th(z_selfinsertunmeta) || cmd == Th(z_selfinsert)) {
@@ -1039,11 +1062,9 @@ getvisrchstr(void)
 	    }
 	    sbuf[sptr++] = c;
 	} else {
-	    feep = 1;
+	    feep();
 	}
-	if (feep)
-	    handlefeep(zlenoargs);
-	feep = 0;
+	handlefeep();
     }
     statusline = NULL;
     selectkeymap(okeymap, 1);
@@ -1101,8 +1122,10 @@ virepeatsearch(char **args)
     int n = zmult;
     char *s;
 
-    if (!visrchstr)
+    if (!visrchstr) {
+	feep();
 	return 1;
+    }
     if (zmult < 0) {
 	n = -n;
 	visrchsense = -visrchsense;
@@ -1122,6 +1145,7 @@ virepeatsearch(char **args)
 	    }
 	}
     }
+    feep();
     return 1;
 }
 
@@ -1170,6 +1194,7 @@ historybeginningsearchbackward(char **args)
 	    }
 	}
     }
+    feep();
     return 1;
 }
 
@@ -1206,5 +1231,6 @@ historybeginningsearchforward(char **args)
 	    }
 	}
     }
+    feep();
     return 1;
 }
diff --git a/Src/Zle/zle_keymap.c b/Src/Zle/zle_keymap.c
index 28bc96b64..7504ed809 100644
--- a/Src/Zle/zle_keymap.c
+++ b/Src/Zle/zle_keymap.c
@@ -98,7 +98,7 @@ struct bindstate {
 /* currently selected keymap, and its name */
 
 /**/
-Keymap curkeymap, localkeymap;
+Keymap curkeymap;
 /**/
 char *curkeymapname;
 
@@ -216,7 +216,7 @@ freekeynode(HashNode hn)
 static HashTable copyto;
 
 /**/
-Keymap
+static Keymap
 newkeymap(Keymap tocopy, char *kmname)
 {
     Keymap km = zcalloc(sizeof(*km));
@@ -250,7 +250,7 @@ scancopykeys(HashNode hn, int flags)
 }
 
 /**/
-void
+static void
 deletekeymap(Keymap km)
 {
     int i;
@@ -322,21 +322,21 @@ openkeymap(char *name)
 }
 
 /**/
-int
-unlinkkeymap(char *name, int ignm)
+static int
+unlinkkeymap(char *name)
 {
     KeymapName n = (KeymapName) keymapnamtab->getnode(keymapnamtab, name);
     if(!n)
 	return 2;
-    if(!ignm && (n->flags & KMN_IMMORTAL))
+    if(n->flags & KMN_IMMORTAL)
 	return 1;
     keymapnamtab->freenode(keymapnamtab->removenode(keymapnamtab, name));
     return 0;
 }
 
 /**/
-int
-linkkeymap(Keymap km, char *name, int imm)
+static int
+linkkeymap(Keymap km, char *name)
 {
     KeymapName n = (KeymapName) keymapnamtab->getnode(keymapnamtab, name);
     if(n) {
@@ -347,12 +347,9 @@ linkkeymap(Keymap km, char *name, int imm)
 	if(!--n->keymap->rc)
 	    deletekeymap(n->keymap);
 	n->keymap = km;
-    } else {
-	n = makekeymapnamnode(km);
-	if (imm)
-	    n->flags |= KMN_IMMORTAL;
-	keymapnamtab->addnode(keymapnamtab, ztrdup(name), n);
-    }
+    } else
+	keymapnamtab->addnode(keymapnamtab, ztrdup(name),
+	    makekeymapnamnode(km));
     km->rc++;
     return 0;
 }
@@ -382,15 +379,6 @@ selectkeymap(char *name, int fb)
     return 0;
 }
 
-/* Select a local key map. */
-
-/**/
-void
-selectlocalmap(Keymap m)
-{
-    localkeymap = m;
-}
-
 /* Reopen the currently selected keymap, in case it got deleted.  This *
  * should be called after doing anything that might have run an        *
  * arbitrary user-specified command.                                   */
@@ -654,7 +642,7 @@ bin_bindkey(char *name, char **argv, char *ops, int func)
 	    return 1;
 	}
 	if(ops['e'] || ops['v'])
-	    linkkeymap(km, "main", 0);
+	    linkkeymap(km, "main");
     } else {
 	kmname = NULL;
 	km = NULL;
@@ -727,7 +715,7 @@ bin_bindkey_del(char *name, char *kmname, Keymap km, char **argv, char *ops, cha
     int ret = 0;
 
     do {
-	int r = unlinkkeymap(*argv, 0);
+	int r = unlinkkeymap(*argv);
 	if(r == 1)
 	    zwarnnam(name, "keymap name `%s' is protected", *argv, 0);
 	else if(r == 2)
@@ -747,7 +735,7 @@ bin_bindkey_link(char *name, char *kmname, Keymap km, char **argv, char *ops, ch
     if(!km) {
 	zwarnnam(name, "no such keymap `%s'", argv[0], 0);
 	return 1;
-    } else if(linkkeymap(km, argv[1], 0)) {
+    } else if(linkkeymap(km, argv[1])) {
 	zwarnnam(name, "keymap name `%s' is protected", argv[1], 0);
 	return 1;
     }
@@ -774,7 +762,7 @@ bin_bindkey_new(char *name, char *kmname, Keymap km, char **argv, char *ops, cha
 	}
     } else
 	km = NULL;
-    linkkeymap(newkeymap(km, argv[0]), argv[0], 0);
+    linkkeymap(newkeymap(km, argv[0]), argv[0]);
     return 0;
 }
 
@@ -1120,18 +1108,20 @@ default_bindings(void)
      * will be linked to the "emacs" keymap, except that if VISUAL *
      * or EDITOR contain the string "vi" then it will be linked to *
      * the "viins" keymap.                                         */
-    linkkeymap(vmap, "viins", 0);
-    linkkeymap(emap, "emacs", 0);
-    linkkeymap(amap, "vicmd", 0);
-    linkkeymap(smap, ".safe", 1);
+    linkkeymap(vmap, "viins");
+    linkkeymap(emap, "emacs");
+    linkkeymap(amap, "vicmd");
+    linkkeymap(smap, ".safe");
     if (((ed = zgetenv("VISUAL")) && strstr(ed, "vi")) ||
 	((ed = zgetenv("EDITOR")) && strstr(ed, "vi")))
-	linkkeymap(vmap, "main", 0);
+	linkkeymap(vmap, "main");
     else
-	linkkeymap(emap, "main", 0);
+	linkkeymap(emap, "main");
 
     /* the .safe map cannot be modified or deleted */
     smap->flags |= KM_IMMUTABLE;
+    ((KeymapName) keymapnamtab->getnode(keymapnamtab, ".safe"))->flags
+	|= KMN_IMMORTAL;
 }
 
 /*************************/
@@ -1152,12 +1142,7 @@ getkeymapcmd(Keymap km, Thingy *funcp, char **strp)
     keybuf[0] = 0;
     while((c = getkeybuf(!!lastlen)) != EOF) {
 	char *s;
-	Thingy f;
-	int loc = 1;
-
-	if (!localkeymap ||
-	    (f = keybind(localkeymap, keybuf, &s)) == t_undefinedkey)
-	    loc = 0, f = keybind(km, keybuf, &s);
+	Thingy f = keybind(km, keybuf, &s);
 
 	if(f != t_undefinedkey) {
 	    lastlen = keybuflen;
@@ -1165,7 +1150,7 @@ getkeymapcmd(Keymap km, Thingy *funcp, char **strp)
 	    str = s;
 	    lastc = c;
 	}
-	if(!keyisprefix((loc ? localkeymap : km), keybuf))
+	if(!keyisprefix(km, keybuf))
 	    break;
     }
     if(!lastlen && keybuflen)
diff --git a/Src/Zle/zle_main.c b/Src/Zle/zle_main.c
index 8f6dfdf75..e2b64cb3c 100644
--- a/Src/Zle/zle_main.c
+++ b/Src/Zle/zle_main.c
@@ -106,7 +106,13 @@ struct modifier zmod;
 /**/
 int prefixflag;
 
+/* != 0 if there is a pending beep (usually indicating an error) */
+
+/**/
+int feepflag;
+ 
 /* Number of characters waiting to be read by the ungetkeys mechanism */
+
 /**/
 int kungetct;
 
@@ -501,7 +507,6 @@ zleread(char *lp, char *rp, int flags)
 	viinsbegin = 0;
 	statusline = NULL;
 	selectkeymap("main", 1);
-	selectlocalmap(NULL);
 	fixsuffix();
 	if ((s = (unsigned char *)getlinknode(bufstack))) {
 	    setline((char *)s);
@@ -530,21 +535,20 @@ zleread(char *lp, char *rp, int flags)
 	lastcol = -1;
 	initmodifier(&zmod);
 	prefixflag = 0;
+	feepflag = 0;
 	zrefresh();
 	while (!done && !errflag) {
 
 	    statusline = NULL;
 	    vilinerange = 0;
 	    reselectkeymap();
-	    selectlocalmap(NULL);
 	    bindk = getkeycmd();
 	    if (!ll && isfirstln && c == eofchar) {
 		eofsent = 1;
 		break;
 	    }
 	    if (bindk) {
-		if (execzlefunc(bindk, zlenoargs))
-		    handlefeep(zlenoargs);
+		execzlefunc(bindk, zlenoargs);
 		handleprefixes();
 		/* for vi mode, make sure the cursor isn't somewhere illegal */
 		if (invicmdmode() && cs > findbol() &&
@@ -569,6 +573,7 @@ zleread(char *lp, char *rp, int flags)
 #endif
 		if (!kungetct)
 		    zrefresh();
+	    handlefeep();
 	}
 	statusline = NULL;
 	invalidatelist();
@@ -608,7 +613,7 @@ execzlefunc(Thingy func, char **args)
 	zsfree(nm);
 	showmsg(msg);
 	zsfree(msg);
-	ret = 1;
+	feep();
     } else if((w = func->widget)->flags & (WIDGET_INT|WIDGET_NCOMP)) {
 	int wflags = w->flags;
 
@@ -641,7 +646,7 @@ execzlefunc(Thingy func, char **args)
 	    zsfree(nm);
 	    showmsg(msg);
 	    zsfree(msg);
-	    ret = 1;
+	    feep();
 	} else {
 	    int osc = sfcontext, osi = movefd(0), olv = lastval;
 	    LinkList largs = NULL;
@@ -948,17 +953,7 @@ trashzle(void)
 static struct builtin bintab[] = {
     BUILTIN("bindkey", 0, bin_bindkey, 0, -1, 0, "evaMldDANmrsLR", NULL),
     BUILTIN("vared",   0, bin_vared,   1,  7, 0, NULL,             NULL),
-    BUILTIN("zle",     0, bin_zle,     0, -1, 0, "lDANCLmMgGcRa",  NULL),
-};
-
-/* The order of the entries in this table has to match the *HOOK
- * macros in zle.h */
-
-/**/
-struct hookdef zlehooks[] = {
-    HOOKDEF("list_matches", ilistmatches, 0),
-    HOOKDEF("insert_match", NULL, HOOKF_ALL),
-    HOOKDEF("menu_start", NULL, HOOKF_ALL),
+    BUILTIN("zle",     0, bin_zle,     0, -1, 0, "lDANCLmMgGcR",  NULL),
 };
 
 /**/
@@ -1004,7 +999,6 @@ int
 boot_zle(Module m)
 {
     addbuiltins(m->nam, bintab, sizeof(bintab)/sizeof(*bintab));
-    addhookdefs(m->nam, zlehooks, sizeof(zlehooks)/sizeof(*zlehooks));
     return 0;
 }
 
@@ -1020,7 +1014,6 @@ cleanup_zle(Module m)
 	return 1;
     }
     deletebuiltins(m->nam, bintab, sizeof(bintab)/sizeof(*bintab));
-    deletehookdefs(m->nam, zlehooks, sizeof(zlehooks)/sizeof(*zlehooks));
     return 0;
 }
 
diff --git a/Src/Zle/zle_misc.c b/Src/Zle/zle_misc.c
index a51cdf92e..4d731a21c 100644
--- a/Src/Zle/zle_misc.c
+++ b/Src/Zle/zle_misc.c
@@ -98,6 +98,7 @@ deletechar(char **args)
 	backdel(zmult);
 	return 0;
     }
+    feep();
     return 1;
 }
 
@@ -181,6 +182,7 @@ gosmacstransposechars(char **args)
 	if (cs == ll || line[cs] == '\n' ||
 	    ((cs + 1 == ll || line[cs + 1] == '\n') &&
 	     (!cs || line[cs - 1] == '\n'))) {
+	    feep();
 	    return 1;
 	}
 	cs += (cs == 0 || line[cs - 1] == '\n') ? 2 : 1;
@@ -203,8 +205,10 @@ transposechars(char **args)
 	n = -n;
     while (n--) {
 	if (!(ct = cs) || line[cs - 1] == '\n') {
-	    if (ll == cs || line[cs] == '\n')
+	    if (ll == cs || line[cs] == '\n') {
+		feep();
 		return 1;
+	    }
 	    if (!neg)
 		cs++;
 	    ct++;
@@ -221,8 +225,10 @@ transposechars(char **args)
 	}
 	if (ct == ll || line[ct] == '\n')
 	    ct--;
-	if (ct < 1 || line[ct - 1] == '\n')
+	if (ct < 1 || line[ct - 1] == '\n') {
+	    feep();
 	    return 1;
+	}
 	cc = line[ct - 1];
 	line[ct - 1] = line[ct];
 	line[ct] = cc;
@@ -344,8 +350,10 @@ yank(char **args)
 	return 1;
     if (zmod.flags & MOD_VIBUF)
 	buf = &vibuf[zmod.vibuf];
-    if (!buf->buf)
+    if (!buf->buf) {
+	feep();
 	return 1;
+    }
     mark = cs;
     yankb = cs;
     while (n--) {
@@ -364,8 +372,10 @@ yankpop(char **args)
 {
     int cc;
 
-    if (!(lastcmd & ZLE_YANK) || !kring[kct].buf)
+    if (!(lastcmd & ZLE_YANK) || !kring[kct].buf) {
+	feep();
 	return 1;
+    }
     cs = yankb;
     foredel(yanke - yankb);
     cc = kring[kct].len;
@@ -428,6 +438,7 @@ whatcursorposition(char **args)
 int
 undefinedkey(char **args)
 {
+    feep();
     return 1;
 }
 
@@ -446,9 +457,10 @@ quotedinsert(char **args)
 #ifndef HAS_TIO
     zsetterm();
 #endif
-    if (c < 0)
+    if (c < 0) {
+	feep();
 	return 1;
-    else
+    } else
 	return selfinsert(args);
 }
 
@@ -458,8 +470,10 @@ digitargument(char **args)
 {
     int sign = (zmult < 0) ? -1 : 1;
 
-    if (c < '0' || c > '9')
+    if (c < '0' || c > '9') {
+	feep();
 	return 1;
+    }
 
     if (!(zmod.flags & MOD_TMULT))
 	zmod.tmult = 0;
@@ -479,8 +493,10 @@ digitargument(char **args)
 int
 negargument(char **args)
 {
-    if (zmod.flags & MOD_TMULT)
+    if (zmod.flags & MOD_TMULT) {
+	feep();
 	return 1;
+    }
     zmod.tmult = -1;
     zmod.flags |= MOD_TMULT|MOD_NEG;
     prefixflag = 1;
@@ -639,7 +655,7 @@ Thingy
 executenamedcommand(char *prmt)
 {
     Thingy cmd;
-    int len, l = strlen(prmt), ols = listshown, feep = 0;
+    int len, l = strlen(prmt), ols = listshown;
     char *ptr;
     char *okeymap = curkeymapname;
 
@@ -672,12 +688,12 @@ executenamedcommand(char *prmt)
 	    zrefresh();
 	    c = getkey(0);
 	    if(c == EOF || !c || len == NAMLEN)
-		feep = 1;
+		feep();
 	    else
 		*ptr++ = c, len++;
 	} else if(cmd == Th(z_quotedinsert)) {
 	    if((c = getkey(0)) == EOF || !c || len == NAMLEN)
-		feep = 1;
+		feep();
 	    else
 		*ptr++ = c, len++;
 	} else if(cmd == Th(z_backwarddeletechar) ||
@@ -728,7 +744,7 @@ executenamedcommand(char *prmt)
 		    scanhashtable(thingytab, 1, 0, DISABLED, scancompcmd, 0);
 		} LASTALLOC;
 		if (empty(cmdll))
-		    feep = 1;
+		    feep();
 		else if (cmd == Th(z_listchoices) ||
 		    cmd == Th(z_deletecharorlist)) {
 		    int zmultsav = zmult;
@@ -750,7 +766,7 @@ executenamedcommand(char *prmt)
 			!(isset(LISTAMBIGUOUS) && cmdambig > len)) {
 			int zmultsav = zmult;
 			if (isset(LISTBEEP))
-			    feep = 1;
+			    feep();
 			statusll = l + cmdambig + 1;
 			zmult = 1;
 			listlist(cmdll);
@@ -760,14 +776,12 @@ executenamedcommand(char *prmt)
 		}
 	    } else {
 		if (len == NAMLEN || icntrl(c) || cmd != Th(z_selfinsert))
-		    feep = 1;
+		    feep();
 		else
 		    *ptr++ = c, len++;
 	    }
 	}
-	if (feep)
-	    handlefeep(zlenoargs);
-	feep = 0;
+	handlefeep();
     }
 }
 
diff --git a/Src/Zle/zle_move.c b/Src/Zle/zle_move.c
index 9189218f1..e2096f6cf 100644
--- a/Src/Zle/zle_move.c
+++ b/Src/Zle/zle_move.c
@@ -228,6 +228,7 @@ vimatchbracket(char **args)
 
   otog:
     if (cs == ll || line[cs] == '\n') {
+	feep();
 	cs = ocs;
 	return 1;
     }
@@ -272,6 +273,7 @@ vimatchbracket(char **args)
 	    ct++;
     }
     if (cs < 0 || cs >= ll) {
+	feep();
 	cs = ocs;
 	return 1;
     } else if(dir > 0 && virangeflag)
@@ -293,8 +295,10 @@ viforwardchar(char **args)
 	zmult = n;
 	return ret;
     }
-    if (cs >= lim)
+    if (cs >= lim) {
+	feep();
 	return 1;
+    }
     while (n-- && cs < lim)
 	cs++;
     return 0;
@@ -313,8 +317,10 @@ vibackwardchar(char **args)
 	zmult = n;
 	return ret;
     }
-    if (cs == findbol())
+    if (cs == findbol()) {
+	feep();
 	return 1;
+    }
     while (n--) {
 	cs--;
 	if (cs < 0 || line[cs] == '\n') {
@@ -331,11 +337,14 @@ viendofline(char **args)
 {
     int oldcs = cs, n = zmult;
 
-    if (n < 1)
+    if (n < 1) {
+	feep();
 	return 1;
+    }
     while(n--) {
 	if (cs > ll) {
 	    cs = oldcs;
+	    feep();
 	    return 1;
 	}
 	cs = findeol() + 1;
@@ -376,7 +385,7 @@ vifindprevchar(char **args)
 	tailadd = 0;
 	return virepeatfind(args);
     }
-    return 1;
+    return 0;
 }
 
 /**/
@@ -409,8 +418,10 @@ virepeatfind(char **args)
 {
     int ocs = cs, n = zmult;
 
-    if (!vfinddir)
+    if (!vfinddir) {
+	feep();
 	return 1;
+    }
     if (n < 0) {
 	int ret;
 	zmult = -n;
@@ -423,6 +434,7 @@ virepeatfind(char **args)
 	    cs += vfinddir;
 	while (cs >= 0 && cs < ll && line[cs] != vfindchar && line[cs] != '\n');
 	if (cs < 0 || cs >= ll || line[cs] == '\n') {
+	    feep();
 	    cs = ocs;
 	    return 1;
 	}
@@ -468,8 +480,10 @@ visetmark(char **args)
     int ch;
 
     ch = getkey(0);
-    if (ch < 'a' || ch > 'z')
+    if (ch < 'a' || ch > 'z') {
+	feep();
 	return 1;
+    }
     ch -= 'a';
     vimarkcs[ch] = cs;
     vimarkline[ch] = histline;
@@ -486,14 +500,19 @@ vigotomark(char **args)
     if (ch == c)
 	ch = 26;
     else {
-	if (ch < 'a' || ch > 'z')
+	if (ch < 'a' || ch > 'z') {
+	    feep();
 	    return 1;
+	}
 	ch -= 'a';
     }
-    if (!vimarkline[ch])
+    if (!vimarkline[ch]) {
+	feep();
 	return 1;
+    }
     if (curhist != vimarkline[ch] && !zle_goto_hist(vimarkline[ch], 0, 0)) {
 	vimarkline[ch] = 0;
+	feep();
 	return 1;
     }
     cs = vimarkcs[ch];
diff --git a/Src/Zle/zle_params.c b/Src/Zle/zle_params.c
index bac399e7d..221440a46 100644
--- a/Src/Zle/zle_params.c
+++ b/Src/Zle/zle_params.c
@@ -84,7 +84,7 @@ makezleparams(int ro)
 
     for(zp = zleparams; zp->name; zp++) {
 	Param pm = createparam(zp->name, (zp->type |PM_SPECIAL|PM_REMOVABLE|
-					  PM_LOCAL|(ro ? PM_READONLY : 0)));
+					  (ro ? PM_READONLY : 0)));
 	if (!pm)
 	    pm = (Param) paramtab->getnode(paramtab, zp->name);
 	DPUTS(!pm, "param not set in makezleparams");
diff --git a/Src/Zle/zle_thingy.c b/Src/Zle/zle_thingy.c
index cf01f2fc1..2950d55d9 100644
--- a/Src/Zle/zle_thingy.c
+++ b/Src/Zle/zle_thingy.c
@@ -318,10 +318,9 @@ deletezlefunction(Widget w)
 /*
  * The available operations are:
  *
- *   -l   list widgets/test for existence
+ *   -l   list user-defined widgets (no arguments)
  *   -D   delete widget names
  *   -A   link the two named widgets (2 arguments)
- *   -C   create completion widget (3 arguments)
  *   -N   create new user-defined widget (1 or 2 arguments)
  *        invoke a widget (1 argument)
  */
@@ -335,7 +334,7 @@ bin_zle(char *name, char **args, char *ops, int func)
 	int (*func) _((char *, char **, char *, char));
 	int min, max;
     } const opns[] = {
-	{ 'l', bin_zle_list, 0, -1 },
+	{ 'l', bin_zle_list, 0,  0 },
 	{ 'D', bin_zle_del,  1, -1 },
 	{ 'A', bin_zle_link, 2,  2 },
 	{ 'N', bin_zle_new,  1,  2 },
@@ -374,21 +373,8 @@ bin_zle(char *name, char **args, char *ops, int func)
 static int
 bin_zle_list(char *name, char **args, char *ops, char func)
 {
-    if (!*args) {
-	scanhashtable(thingytab, 1, 0, DISABLED, scanlistwidgets,
-		      (ops['a'] ? -1 : ops['L']));
-	return 0;
-    } else {
-	int ret = 0;
-	Thingy t;
-
-	for (; *args && !ret; args++) {
-	    if (!(t = (Thingy) thingytab->getnode2(thingytab, *args)) ||
-		(!ops['a'] && (t->widget->flags & WIDGET_INT)))
-		ret = 1;
-	}
-	return ret;
-    }
+    scanhashtable(thingytab, 1, 0, DISABLED, scanlistwidgets, ops['L']);
+    return 0;
 }
 
 /**/
@@ -419,10 +405,6 @@ scanlistwidgets(HashNode hn, int list)
     Thingy t = (Thingy) hn;
     Widget w = t->widget;
 
-    if(list < 0) {
-	printf("%s\n", hn->nam);
-	return;
-    }
     if(w->flags & WIDGET_INT)
 	return;
     if(list) {
@@ -554,7 +536,6 @@ bin_zle_call(char *name, char **args, char *ops, char func)
     Thingy t;
     struct modifier modsave;
     int ret, saveflag = 0;
-    char *wname = *args++;
 
     if(!zleactive || incompctlfunc || incompfunc) {
 	zerrnam(name, "widgets can only be called when ZLE is active",
@@ -562,12 +543,6 @@ bin_zle_call(char *name, char **args, char *ops, char func)
 	return 1;
     }
 
-    if (!wname) {
-	zwarnnam(name, "wrong number of arguments", NULL, 0);
-	if (saveflag)
-	    zmod = modsave;
-	return 1;
-    }
     while (*args && **args == '-') {
 	char *num;
 	if (!args[0][1] || args[0][1] == '-') {
@@ -602,8 +577,14 @@ bin_zle_call(char *name, char **args, char *ops, char func)
 	}
 	args++;
     }
+    if (!args[0]) {
+	zwarnnam(name, "wrong number of arguments", NULL, 0);
+	if (saveflag)
+	    zmod = modsave;
+	return 1;
+    }
 
-    t = rthingy(wname);
+    t = rthingy(*args++);
     PERMALLOC {
         ret = execzlefunc(t, args);
     } LASTALLOC;
diff --git a/Src/Zle/zle_tricky.c b/Src/Zle/zle_tricky.c
index 65e1aeae9..bb0a3cac0 100644
--- a/Src/Zle/zle_tricky.c
+++ b/Src/Zle/zle_tricky.c
@@ -110,10 +110,20 @@ static int movetoend;
 
 static int menucmp;
 
-/* Information about menucompletion. */
+/* Pointers to the current position in the groups list and in the menu-    *
+ * completion array (the one that was put in the command line last).       */
 
-/**/
-struct menuinfo minfo;
+static Cmgroup menugrp;
+static Cmatch *menucur;
+
+/* menupos is the point (in the command line) where the menu-completion   *
+ * strings are inserted.  menulen is the length of the string that was    *
+ * inserted last.  menuend is the end position of this string in the      *
+ * command line.  menuwe is non-zero if the cursor was at the end of the  *
+ * word (meaning that suffixes should go before the cursor).  menuinsc is *
+ * the length of any suffix that has been temporarily added.              */
+
+static int menupos, menulen, menuend, menuwe, menuinsc;
 
 /* This is for completion inside a brace expansion. brbeg and brend hold  *
  * strings that were temporarily removed from the string to complete.     *
@@ -378,8 +388,7 @@ completecall(char **args)
     cfargs = args;
     cfret = 0;
     compfunc = compwidget->u.comp.func;
-    if (compwidget->u.comp.fn(zlenoargs) && !cfret)
-	cfret = 1;
+    compwidget->u.comp.fn(zlenoargs);
     compfunc = NULL;
 
     return cfret;
@@ -437,8 +446,8 @@ spellword(char **args)
 int
 deletecharorlist(char **args)
 {
-    Cmgroup mg = minfo.group;
-    Cmatch *mc = minfo.cur;
+    Cmgroup mg = menugrp;
+    Cmatch *mc = menucur;
     int ret;
 
     usemenu = !!isset(MENUCOMPLETE);
@@ -449,8 +458,8 @@ deletecharorlist(char **args)
     } else
 	ret = docomplete(COMP_LIST_COMPLETE);
 
-    minfo.cur = mc;
-    minfo.group = mg;
+    menucur = mc;
+    menugrp = mg;
     return ret;
 }
 
@@ -513,16 +522,16 @@ reversemenucomplete(char **args)
 	return menucomplete(args);
 
     HEAPALLOC {
-	if (minfo.cur == (minfo.group)->matches) {
+	if (menucur == menugrp->matches) {
 	    do {
-		if (!(minfo.group = (minfo.group)->prev))
-		    minfo.group = lmatches;
-	    } while (!(minfo.group)->mcount);
-	    minfo.cur = (minfo.group)->matches + (minfo.group)->mcount - 1;
+		if (!(menugrp = menugrp->prev))
+		    menugrp = lmatches;
+	    } while (!menugrp->mcount);
+	    menucur = menugrp->matches + menugrp->mcount - 1;
 	} else
-	    minfo.cur--;
+	    menucur--;
 	metafy_line();
-	do_single(*(minfo.cur));
+	do_single(*menucur);
 	unmetafy_line();
     } LASTALLOC;
     return 0;
@@ -532,8 +541,7 @@ reversemenucomplete(char **args)
  * with the next completions. This gives you a way to   *
  * accept several selections from the list of matches.  */
 
-/**/
-void
+static void
 acceptlast(void)
 {
     if (brbeg && *brbeg) {
@@ -549,13 +557,13 @@ acceptlast(void)
 	brbeg[l] = ',';
 	brbeg[l + 1] = '\0';
     } else {
-	cs = minfo.pos + minfo.len + minfo.insc;
+	cs = menupos + menulen + menuinsc;
 	iremovesuffix(' ', 1);
 
 	inststrlen(" ", 1, 1);
-	minfo.insc = minfo.len = 0;
-	minfo.pos = cs;
-	minfo.we = 1;
+	menuinsc = menulen = 0;
+	menupos = cs;
+	menuwe = 1;
     }
 }
 
@@ -563,8 +571,10 @@ acceptlast(void)
 int
 acceptandmenucomplete(char **args)
 {
-    if (!menucmp)
+    if (!menucmp) {
+	feep();
 	return 1;
+    }
     acceptlast();
     return menucomplete(args);
 }
@@ -797,7 +807,7 @@ static int
 docomplete(int lst)
 {
     char *s, *ol;
-    int olst = lst, chl = 0, ne = noerrs, ocs, ret = 0, omc = menucmp;
+    int olst = lst, chl = 0, ne = noerrs, ocs, ret = 0;;
 
     if (showagain && validlist)
 	showinglist = -2;
@@ -879,6 +889,7 @@ docomplete(int lst)
 	    ll = strlen((char *) line);
 	    cs = ocs;
 	    unmetafy_line();
+	    feep();
 	    return 1;
 	}
 	ocs = cs;
@@ -1051,15 +1062,6 @@ docomplete(int lst)
     popheap();
     zsfree(qword);
     unmetafy_line();
-
-    if (menucmp && !omc) {
-	struct chdata dat;
-
-	dat.matches = amatches;
-	dat.num = nmatches;
-	dat.cur = NULL;
-	runhookdef(MENUSTARTHOOK, (void *) &dat);
-    }
     return ret;
 }
 
@@ -1069,7 +1071,7 @@ docomplete(int lst)
  * insert the next completion.                                              */
 
 /**/
-void
+static void
 do_menucmp(int lst)
 {
     /* Just list the matches if the list was requested. */
@@ -1079,16 +1081,16 @@ do_menucmp(int lst)
     }
     /* Otherwise go to the next match in the array... */
     HEAPALLOC {
-	if (!*++(minfo.cur)) {
+	if (!*++menucur) {
 	    do {
-		if (!(minfo.group = (minfo.group)->next))
-		    minfo.group = amatches;
-	    } while (!(minfo.group)->mcount);
-	    minfo.cur = minfo.group->matches;
+		if (!(menugrp = menugrp->next))
+		    menugrp = amatches;
+	    } while (!menugrp->mcount);
+	    menucur = menugrp->matches;
 	}
 	/* ... and insert it into the command line. */
 	metafy_line();
-	do_single(*(minfo.cur));
+	do_single(*menucur);
 	unmetafy_line();
     } LASTALLOC;
 }
@@ -1442,6 +1444,7 @@ get_comp_string(void)
 		lexrestore();
 		goto start;
 	    }
+	    feep();
 	    noaliases = 0;
 	    lexrestore();
 	    LASTALLOC_RETURN NULL;
@@ -1754,8 +1757,11 @@ doexpansion(char *s, int lst, int olst, int explincmd)
 	}
 	if (errflag)
 	    goto end;
-	if (empty(vl) || !*(char *)peekfirst(vl))
+	if (empty(vl) || !*(char *)peekfirst(vl)) {
+	    if (!noerrs)
+		feep();
 	    goto end;
+	}
 	if (peekfirst(vl) == (void *) ss ||
 		(olst == COMP_EXPAND_COMPLETE &&
 		 !nextnode(firstnode(vl)) && *s == Tilde &&
@@ -1765,6 +1771,8 @@ doexpansion(char *s, int lst, int olst, int explincmd)
 	     * expandorcomplete was called, otherwise, just beep.     */
 	    if (lst == COMP_EXPAND_COMPLETE)
 		docompletion(s, COMP_COMPLETE, explincmd);
+	    else
+		feep();
 	    goto end;
 	}
 	if (lst == COMP_LIST_EXPAND) {
@@ -3816,10 +3824,6 @@ addmatches(Cadata dat, char **argv)
 		    lpre = quotename(lpre, NULL);
 		    lsuf = quotename(lsuf, NULL);
 		}
-		if (dat->ppre)
-		    dat->ppre = quotename(dat->ppre, NULL);
-		if (dat->psuf)
-		    dat->psuf = quotename(dat->psuf, NULL);
 	    }
 	    /* Walk through the matches given. */
 	    for (; (s = *argv); argv++) {
@@ -3845,10 +3849,8 @@ addmatches(Cadata dat, char **argv)
 		    }
 		}
 		if (!(dat->aflags & CAF_MATCH)) {
-		    if (dat->aflags & CAF_QUOTE)
-			ms = dupstring(s);
-		    else
-			sl = strlen(ms = quotename(s, NULL));
+		    ms = ((dat->aflags & CAF_QUOTE) ? dupstring(s) :
+			  quotename(s, NULL));
 		    lc = bld_parts(ms, sl, -1, NULL);
 		    isexact = 0;
 		} else if (!(ms = comp_match(lpre, lsuf, s, cp, &lc,
@@ -4356,6 +4358,7 @@ docompletion(char *s, int lst, int incmd)
 	    foredel(ll);
 	    inststr(origline);
 	    cs = origcs;
+	    feep();
 	    clearlist = 1;
 	    ret = 1;
 	    goto compend;
@@ -4367,17 +4370,17 @@ docompletion(char *s, int lst, int incmd)
 	    showinglist = -2;
 	else if (useline) {
 	    /* We have matches. */
-	    if (nmatches > 1) {
+	    if (nmatches > 1)
 		/* There is more than one match. */
-		ret = do_ambiguous();
-	    } else if (nmatches == 1) {
+		    do_ambiguous();
+
+	    else if (nmatches == 1) {
 		/* Only one match. */
 		Cmgroup m = amatches;
 
 		while (!m->mcount)
 		    m = m->next;
-		minfo.cur = NULL;
-		minfo.asked = 0;
+		menucur = NULL;
 		do_single(m->matches[0]);
 		invalidatelist();
 	    }
@@ -4391,7 +4394,7 @@ docompletion(char *s, int lst, int incmd)
 	    int up = 0, tr = 1, nn = 0;
 
 	    if (!nmatches)
-		ret = 1;
+		feep();
 
 	    while (g) {
 		if ((e = g->expls))
@@ -4633,8 +4636,8 @@ callcompfunc(char *s, char *fn)
 	    else
 		compoldlist = "yes";
 	    kset |= CP_OLDLIST;
-	    if (minfo.cur) {
-		sprintf(buf, "%d", (*(minfo.cur))->gnum);
+	    if (menucur) {
+		sprintf(buf, "%d", (*menucur)->gnum);
 		compoldins = buf;
 		kset |= CP_OLDINS;
 	    } else
@@ -4715,7 +4718,7 @@ callcompfunc(char *s, char *fn)
 	    movetoend = 2;
 
 	oldlist = (hasperm && compoldlist && !strcmp(compoldlist, "keep"));
-	oldins = (hasperm && minfo.cur &&
+	oldins = (hasperm && menucur &&
 		  compoldins && !strcmp(compoldins, "keep"));
 
 	zfree(comprpms, CP_REALPARAMS * sizeof(Param));
@@ -5632,7 +5635,7 @@ makecomplistext(Compctl occ, char *os, int incmd)
 		    case CCT_RANGEPAT:
 			if (cc->type == CCT_RANGEPAT)
 			    tokenize(sc = dupstring(cc->u.l.a[i]));
-			for (j = clwpos - 1; j > 0; j--) {
+			for (j = clwpos; j; j--) {
 			    untokenize(s = ztrdup(clwords[j]));
 			    if (cc->type == CCT_RANGESTR)
 				sc = rembslash(cc->u.l.a[i]);
@@ -6362,14 +6365,20 @@ makecomplistflags(Compctl cc, char *s, int incmd, int compadd)
     if (cc->mask & (CC_JOBS | CC_RUNNING | CC_STOPPED)) {
 	/* Get job names. */
 	int i;
-	char *j;
+	char *j, *jj;
 
 	for (i = 0; i < MAXJOB; i++)
 	    if ((jobtab[i].stat & STAT_INUSE) &&
 		jobtab[i].procs && jobtab[i].procs->text) {
 		int stopped = jobtab[i].stat & STAT_STOPPED;
 
-		j = dupstring(jobtab[i].procs->text);
+		j = jj = dupstring(jobtab[i].procs->text);
+		/* Find the first word. */
+		for (; *jj; jj++)
+		    if (*jj == ' ') {
+			*jj = '\0';
+			break;
+		    }
 		if ((cc->mask & CC_JOBS) ||
 		    (stopped && (cc->mask & CC_STOPPED)) ||
 		    (!stopped && (cc->mask & CC_RUNNING)))
@@ -6616,8 +6625,7 @@ invalidatelist(void)
     if (validlist)
 	freematches();
     lastambig = menucmp = validlist = showinglist = fromcomp = 0;
-    minfo.cur = NULL;
-    minfo.asked = 0;
+    menucur = NULL;
     compwidget = NULL;
 }
 
@@ -7384,20 +7392,19 @@ instmatch(Cmatch m, int *scs)
 /* Handle the case were we found more than one match. */
 
 /**/
-static int
+static void
 do_ambiguous(void)
 {
-    int ret = 0;
     menucmp = 0;
 
     /* If we have to insert the first match, call do_single().  This is *
      * how REC_EXACT takes effect.  We effectively turn the ambiguous   *
      * completion into an unambiguous one.                              */
     if (ainfo && ainfo->exact == 1 && useexact && !(fromcomp & FC_LINE)) {
-	minfo.cur = NULL;
+	menucur = NULL;
 	do_single(ainfo->exactm);
 	invalidatelist();
-	return ret;
+	return;
     }
     /* Setting lastambig here means that the completion is ambiguous and *
      * AUTO_MENU might want to start a menu completion next time round,  *
@@ -7417,8 +7424,7 @@ do_ambiguous(void)
 	int atend = (cs == we), oll = ll, la, eq, tcs;
 	VARARR(char, oline, ll);
 
-	minfo.cur = NULL;
-	minfo.asked = 0;
+	menucur = NULL;
 
 	/* Copy the line buffer to be able to easily test if it changed. */
 	memcpy(oline, line, ll);
@@ -7467,21 +7473,19 @@ do_ambiguous(void)
 	    fromcomp = fc;
 	    lastambig = 0;
 	    clearlist = 1;
-	    return ret;
+	    return;
 	}
     } else
-	return ret;
+	return;
 
     /* At this point, we might want a completion listing.  Show the listing *
      * if it is needed.                                                     */
     if (isset(LISTBEEP))
-	ret = 1;
-    if (uselist && (usemenu != 2 || (!showinglist && !oldlist)) &&
-	((!showinglist && (!listshown || !oldlist)) ||
-	 (usemenu == 3 && !oldlist)) &&
+	feep();
+    if (uselist && usemenu != 2 &&
+	(!showinglist || (usemenu == 3 && !oldlist)) &&
 	(smatches >= 2 || (compforcelist && *compforcelist)))
 	showinglist = -2;
-    return ret;
 }
 
 /* This is a stat that ignores backslashes in the filename.  The `ls' *
@@ -7491,7 +7495,7 @@ do_ambiguous(void)
  * (l)stat().                                                         */
 
 /**/
-int
+static int
 ztat(char *nam, struct stat *buf, int ls)
 {
     char b[PATH_MAX], *p;
@@ -7509,7 +7513,7 @@ ztat(char *nam, struct stat *buf, int ls)
 /* Insert a single match in the command line. */
 
 /**/
-void
+static void
 do_single(Cmatch m)
 {
     int l, sr = 0, scs;
@@ -7522,39 +7526,39 @@ do_single(Cmatch m)
 
     fixsuffix();
 
-    if (!minfo.cur) {
+    if (!menucur) {
 	/* We are currently not in a menu-completion, *
 	 * so set the position variables.             */
-	minfo.pos = wb;
-	minfo.we = (movetoend >= 2 || (movetoend == 1 && !menucmp));
-	minfo.end = we;
+	menupos = wb;
+	menuwe = (movetoend >= 2 || (movetoend == 1 && !menucmp));
+	menuend = we;
     }
     /* If we are already in a menu-completion or if we have done a *
      * glob completion, we have to delete some of the stuff on the *
      * command line.                                               */
-    if (minfo.cur)
-	l = minfo.len + minfo.insc;
+    if (menucur)
+	l = menulen + menuinsc;
     else
 	l = we - wb;
 
-    minfo.insc = 0;
-    cs = minfo.pos;
+    menuinsc = 0;
+    cs = menupos;
     foredel(l);
 
     /* And then we insert the new string. */
-    minfo.len = instmatch(m, &scs);
-    minfo.end = cs;
-    cs = minfo.pos + minfo.len;
+    menulen = instmatch(m, &scs);
+    menuend = cs;
+    cs = menupos + menulen;
 
     if (m->suf) {
 	havesuff = 1;
-	minfo.insc = ztrlen(m->suf);
-	minfo.len -= minfo.insc;
-	if (minfo.we) {
-	    minfo.end += minfo.insc;
+	menuinsc = ztrlen(m->suf);
+	menulen -= menuinsc;
+	if (menuwe) {
+	    menuend += menuinsc;
 	    if (m->flags & CMF_REMOVE) {
-		makesuffixstr(m->remf, m->rems, minfo.insc);
-		if (minfo.insc == 1)
+		makesuffixstr(m->remf, m->rems, menuinsc);
+		if (menuinsc == 1)
 		    suffixlen[STOUC(m->suf[0])] = 1;
 	    }
 	}
@@ -7570,11 +7574,11 @@ do_single(Cmatch m)
 	    cs += eparq;
 	    for (pq = parq; pq; pq--)
 		inststrlen("\"", 1, 1);
-	    minfo.insc += parq;
+	    menuinsc += parq;
 	    inststrlen("}", 1, 1);
-	    minfo.insc++;
-	    if (minfo.we)
-		minfo.end += minfo.insc;
+	    menuinsc++;
+	    if (menuwe)
+		menuend += menuinsc;
 	}
 	if ((m->flags & CMF_FILE) || (m->ripre && isset(AUTOPARAMSLASH))) {
 	    /* If we have a filename or we completed a parameter name      *
@@ -7610,10 +7614,10 @@ do_single(Cmatch m)
 		/* It is a directory, so add the slash. */
 		havesuff = 1;
 		inststrlen("/", 1, 1);
-		minfo.insc++;
-		if (minfo.we)
-		    minfo.end++;
-		if (!menucmp || minfo.we) {
+		menuinsc++;
+		if (menuwe)
+		    menuend++;
+		if (!menucmp || menuwe) {
 		    if (m->remf || m->rems)
 			makesuffixstr(m->remf, m->rems, 1);
 		    else if (isset(AUTOREMOVESLASH)) {
@@ -7623,8 +7627,8 @@ do_single(Cmatch m)
 		}
 	    }
 	}
-	if (!minfo.insc)
-	    cs = minfo.pos + minfo.len;
+	if (!menuinsc)
+	    cs = menupos + menulen;
     }
     /* If completing in a brace expansion... */
     if (brbeg) {
@@ -7640,9 +7644,9 @@ do_single(Cmatch m)
 	    cs = scs;
 	    havesuff = 1;
 	    inststrlen(",", 1, 1);
-	    minfo.insc++;
+	    menuinsc++;
 	    makesuffix(1);
-	    if ((!menucmp || minfo.we) && isset(AUTOPARAMKEYS))
+	    if ((!menucmp || menuwe) && isset(AUTOPARAMKEYS))
 		suffixlen[','] = suffixlen['}'] = 1;
 	}
     } else if (!havesuff && (!(m->flags & CMF_FILE) || !sr)) {
@@ -7651,33 +7655,20 @@ do_single(Cmatch m)
 	 * the string doesn't name an existing file.             */
 	if (m->autoq && (!m->isuf || m->isuf[0] != m->autoq)) {
 	    inststrlen(&(m->autoq), 1, 1);
-	    minfo.insc++;
+	    menuinsc++;
 	}
-	if (!menucmp && usemenu != 3) {
+	if (!menucmp) {
 	    inststrlen(" ", 1, 1);
-	    minfo.insc++;
-	    if (minfo.we)
+	    menuinsc++;
+	    if (menuwe)
 		makesuffix(1);
 	}
     }
-    if (minfo.we && m->ripre && isset(AUTOPARAMKEYS))
-	makeparamsuffix(((m->flags & CMF_PARBR) ? 1 : 0), minfo.insc - parq);
-
-    if ((menucmp && !minfo.we) || !movetoend)
-	cs = minfo.end;
-    {
-	Cmatch *om = minfo.cur;
-	struct chdata dat;
+    if (menuwe && m->ripre && isset(AUTOPARAMKEYS))
+	makeparamsuffix(((m->flags & CMF_PARBR) ? 1 : 0), menuinsc - parq);
 
-	dat.matches = amatches;
-	dat.num = nmatches;
-	dat.cur = m;
-
-	if (menucmp)
-	    minfo.cur = &m;
-	runhookdef(INSERTMATCHHOOK, (void *) &dat);
-	minfo.cur = om;
-    }
+    if ((menucmp && !menuwe) || !movetoend)
+	cs = menuend;
 }
 
 /* This maps the value in v into the range [0,m-1], decrementing v
@@ -7707,42 +7698,40 @@ do_ambig_menu(void)
 
     if (usemenu != 3) {
 	menucmp = 1;
-	minfo.cur = NULL;
+	menucur = NULL;
     } else {
 	if (oldlist) {
 	    if (oldins)
 		acceptlast();
 	} else
-	    minfo.cur = NULL;
+	    menucur = NULL;
     }
     if (insgroup) {
 	insgnum = comp_mod(insgnum, permgnum);
-	for (minfo.group = amatches;
-	     minfo.group && (minfo.group)->num != insgnum + 1;
-	     minfo.group = (minfo.group)->next);
-	if (!minfo.group || !(minfo.group)->mcount) {
-	    minfo.cur = NULL;
-	    minfo.asked = 0;
+	for (menugrp = amatches;
+	     menugrp && menugrp->num != insgnum + 1;
+	     menugrp = menugrp->next);
+	if (!menugrp || !menugrp->mcount) {
+	    menucur = NULL;
 	    return;
 	}
-	insmnum = comp_mod(insmnum, (minfo.group)->mcount);
+	insmnum = comp_mod(insmnum, menugrp->mcount);
     } else {
 	int c = 0;
 
 	insmnum = comp_mod(insmnum, permmnum);
-	for (minfo.group = amatches;
-	     minfo.group && (c += (minfo.group)->mcount) <= insmnum;
-	     minfo.group = (minfo.group)->next)
-	    insmnum -= (minfo.group)->mcount;
-	if (!minfo.group) {
-	    minfo.cur = NULL;
-	    minfo.asked = 0;
+	for (menugrp = amatches;
+	     menugrp && (c += menugrp->mcount) <= insmnum;
+	     menugrp = menugrp->next)
+	    insmnum -= menugrp->mcount;
+	if (!menugrp) {
+	    menucur = NULL;
 	    return;
 	}
     }
-    mc = (minfo.group)->matches + insmnum;
+    mc = menugrp->matches + insmnum;
     do_single(*mc);
-    minfo.cur = mc;
+    menucur = mc;
 }
 
 /* Return the length of the common prefix of s and t. */
@@ -7781,7 +7770,7 @@ sfxlen(char *s, char *t)
  * It returns the number of lines printed.       */
 
 /**/
-int
+static int
 printfmt(char *fmt, int n, int dopr)
 {
     char *p = fmt, nc[DIGBUFSIZE];
@@ -7864,8 +7853,7 @@ printfmt(char *fmt, int n, int dopr)
 
 /* This skips over matches that are not to be listed. */
 
-/**/
-Cmatch *
+static Cmatch *
 skipnolist(Cmatch *p)
 {
     while (*p && ((*p)->flags & CMF_NOLIST))
@@ -7880,7 +7868,11 @@ skipnolist(Cmatch *p)
 void
 listmatches(void)
 {
-    struct chdata dat;
+    Cmgroup g;
+    Cmatch *p, m;
+    Cexpl *e;
+    int nlines = 0, ncols, nlist = 0, longest = 1, pnl = 0;
+    int of = isset(LISTTYPES), opl = 0;
 
 #ifdef DEBUG
     /* Sanity check */
@@ -7890,22 +7882,6 @@ listmatches(void)
     }
 #endif
 
-    dat.matches = amatches;
-    dat.num = nmatches;
-    dat.cur = NULL;
-    runhookdef(LISTMATCHESHOOK, (void *) &dat);
-}
-
-/**/
-int
-ilistmatches(Hookdef dummy, Chdata dat)
-{
-    Cmgroup g;
-    Cmatch *p, m;
-    Cexpl *e;
-    int nlines = 0, ncols, nlist = 0, longest = 1, pnl = 0;
-    int of = isset(LISTTYPES), opl = 0;
-
     /* Set the cursor below the prompt. */
     trashzle();
     showinglist = listshown = 0;
@@ -7990,9 +7966,8 @@ ilistmatches(Hookdef dummy, Chdata dat)
     }
 
     /* Maybe we have to ask if the user wants to see the list. */
-    if ((!minfo.cur || !minfo.asked) &&
-	((complistmax && nlist > complistmax) ||
-	 (!complistmax && nlines >= lines))) {
+    if ((complistmax && nlist > complistmax) ||
+	(!complistmax && nlines >= lines)) {
 	int qup;
 	zsetterm();
 	qup = printfmt("zsh: do you wish to see all %n possibilities? ", nlist, 1);
@@ -8006,9 +7981,7 @@ ilistmatches(Hookdef dummy, Chdata dat)
 		tcmultout(TCUP, TCMULTUP, nlnct);
 	    } else
 		putc('\n', shout);
-	    if (minfo.cur)
-		minfo.asked = 2;
-	    return 0;
+	    return;
 	}
 	if (clearflag) {
 	    putc('\r', shout);
@@ -8018,8 +7991,6 @@ ilistmatches(Hookdef dummy, Chdata dat)
 	} else
 	    putc('\n', shout);
 	settyinfo(&shttyinfo);
-	if (minfo.cur)
-	    minfo.asked = 1;
     }
 
     /* Now print the matches. */
@@ -8139,7 +8110,6 @@ ilistmatches(Hookdef dummy, Chdata dat)
 	    clearflag = 0, putc('\n', shout);
     } else
 	putc('\n', shout);
-    return 0;
 }
 
 /* This is used to print expansions. */
@@ -8149,9 +8119,9 @@ void
 listlist(LinkList l)
 {
     struct cmgroup dg;
+    Cmgroup am = amatches;
     int vl = validlist, sm = smatches;
     char *oclp = complastprompt;
-    Cmgroup am = amatches;
 
     if (listshown)
 	showagain = 1;
@@ -8159,12 +8129,12 @@ listlist(LinkList l)
     complastprompt = ((zmult == 1) == !!isset(ALWAYSLASTPROMPT) ? "yes" : NULL);
     smatches = 1;
     validlist = 1;
+    amatches = &dg;
     memset(&dg, 0, sizeof(struct cmgroup));
     dg.ylist = (char **) makearray(l, 1, &(dg.lcount), NULL);
-    amatches = &dg;
-    ilistmatches(NULL, NULL);
-    amatches = am;
+    listmatches();
 
+    amatches = am;
     validlist = vl;
     smatches = sm;
     complastprompt = oclp;
@@ -8251,8 +8221,10 @@ magicspace(char **args)
 int
 expandhistory(char **args)
 {
-    if (!doexpandhist())
+    if (!doexpandhist()) {
+	feep();
 	return 1;
+    }
     return 0;
 }
 
@@ -8304,8 +8276,10 @@ processcmd(char **args)
     int m = zmult;
 
     s = getcurcmd();
-    if (!s)
+    if (!s) {
+	feep();
 	return 1;
+    }
     zmult = 1;
     pushline(zlenoargs);
     zmult = m;
@@ -8330,12 +8304,16 @@ expandcmdpath(char **args)
     noaliases = 1;
     s = getcurcmd();
     noaliases = na;
-    if (!s || cmdwb < 0 || cmdwe < cmdwb)
+    if (!s || cmdwb < 0 || cmdwe < cmdwb) {
+	feep();
 	return 1;
+    }
     str = findcmd(s, 1);
     zsfree(s);
-    if (!str)
+    if (!str) {
+	feep();
 	return 1;
+    }
     cs = cmdwb;
     foredel(cmdwe - cmdwb);
     spaceinline(strlen(str));
diff --git a/Src/Zle/zle_utils.c b/Src/Zle/zle_utils.c
index bd2f39a06..cc9c9bf37 100644
--- a/Src/Zle/zle_utils.c
+++ b/Src/Zle/zle_utils.c
@@ -409,11 +409,19 @@ showmsg(char const *msg)
 /* handle the error flag */
 
 /**/
-int
-handlefeep(char **args)
+void
+feep(void)
 {
-    zbeep();
-    return 0;
+    feepflag = 1;
+}
+
+/**/
+void
+handlefeep(void)
+{
+    if(feepflag)
+	zbeep();
+    feepflag = 0;
 }
 
 /***************/
@@ -551,8 +559,10 @@ undo(char **args)
 {
     handleundo();
     do {
-	if(!curchange->prev)
+	if(!curchange->prev) {
+	    feep();
 	    return 1;
+	}
 	unapplychange(curchange = curchange->prev);
     } while(curchange->flags & CH_PREV);
     setlastline();
@@ -588,8 +598,10 @@ redo(char **args)
 {
     handleundo();
     do {
-	if(!curchange->next)
+	if(!curchange->next) {
+	    feep();
 	    return 1;
+	}
 	applychange(curchange);
 	curchange = curchange->next;
     } while(curchange->prev->flags & CH_NEXT);
diff --git a/Src/Zle/zle_vi.c b/Src/Zle/zle_vi.c
index 71f766739..08de69c19 100644
--- a/Src/Zle/zle_vi.c
+++ b/Src/Zle/zle_vi.c
@@ -102,8 +102,10 @@ vigetkey(void)
     char m[3], *str;
     Thingy cmd;
 
-    if((c = getkey(0)) == EOF)
+    if((c = getkey(0)) == EOF) {
+	feep();
 	return -1;
+    }
 
     m[0] = c;
     metafy(m, 1, META_NOALLOC);
@@ -113,10 +115,13 @@ vigetkey(void)
 	cmd = t_undefinedkey;
 
     if (!cmd || cmd == Th(z_sendbreak)) {
+	feep();
 	return -1;
     } else if (cmd == Th(z_quotedinsert)) {
-	if ((c = getkey(0)) == EOF)
+	if ((c = getkey(0)) == EOF) {
+	    feep();
 	    return -1;
+	}
     } else if(cmd == Th(z_viquotedinsert)) {
 	char sav = line[cs];
 
@@ -124,8 +129,10 @@ vigetkey(void)
 	zrefresh();
 	c = getkey(0);
 	line[cs] = sav;
-	if(c == EOF)
+	if(c == EOF) {
+	    feep();
 	    return -1;
+	}
     } else if (cmd == Th(z_vicmdmode))
 	return -1;
     return c;
@@ -135,7 +142,7 @@ vigetkey(void)
 static int
 getvirange(int wf)
 {
-    int pos = cs, ret = 0;
+    int pos = cs;
     int mult1 = zmult, hist1 = histline;
     Thingy k2;
 
@@ -161,37 +168,39 @@ getvirange(int wf)
 		k2 == Th(z_sendbreak)) {
 	    wordflag = 0;
 	    virangeflag = 0;
+	    feep();
 	    return -1;
 	}
-	/*
-	 * With k2 == bindk, the command key is repeated:
-	 * a number of lines is used.  If the function used
-	 * returns 1, we fail.
-	 */
-	if ((k2 == bindk) ? dovilinerange() : execzlefunc(k2, zlenoargs))
-	    ret = -1;
+	if(k2 == bindk)
+	    /* The command key is repeated: a number of lines is used. */
+	    dovilinerange();
+	else
+	    execzlefunc(k2, zlenoargs);
 	if(vichgrepeat)
 	    zmult = mult1;
 	else
 	    zmult = mult1 * zmod.tmult;
-    } while(prefixflag && !ret);
+    } while(prefixflag);
     wordflag = 0;
     virangeflag = 0;
 
     /* It is an error to use a non-movement command to delimit the *
      * range.  We here reject the case where the command modified  *
      * the line, or selected a different history line.             */
-    if (histline != hist1 || ll != lastll || memcmp(line, lastline, ll)) {
+    if(histline != hist1 || ll != lastll || memcmp(line, lastline, ll)) {
 	histline = hist1;
 	memcpy(line, lastline, ll = lastll);
 	cs = pos;
+	feep();
 	return -1;
     }
 
     /* Can't handle an empty file.  Also, if the movement command *
      * failed, or didn't move, it is an error.                    */
-    if (!ll || (cs == pos && virangeflag != 2) || ret == -1)
+    if (!ll || (cs == pos && virangeflag != 2)) {
+	feep();
 	return -1;
+    }
 
     /* vi-match-bracket changes the value of virangeflag when *
      * moving to the opening bracket, meaning that we need to *
@@ -224,7 +233,7 @@ getvirange(int wf)
 }
 
 /**/
-static int
+static void
 dovilinerange(void)
 {
     int pos = cs, n = zmult;
@@ -234,14 +243,17 @@ dovilinerange(void)
      * downward, otherwise upward.  The repeat count gives the    *
      * number of lines.                                           */
     vilinerange = 1;
-    if (!n)
-	return 1;
+    if (!n) {
+	feep();
+	return;
+    }
     if (n > 0) {
 	while(n-- && cs <= ll)
 	    cs = findeol() + 1;
 	if (n != -1) {
 	    cs = pos;
-	    return 1;
+	    feep();
+	    return;
 	}
 	cs--;
     } else {
@@ -249,12 +261,12 @@ dovilinerange(void)
 	    cs = findbol() - 1;
 	if (n != 1) {
 	    cs = pos;
-	    return 1;
+	    feep();
+	    return;
 	}
 	cs++;
     }
     virangeflag = 2;
-    return 0;
 }
 
 /**/
@@ -297,12 +309,11 @@ viinsertbol(char **args)
 int
 videlete(char **args)
 {
-    int c2, ret = 1;
+    int c2;
 
     startvichange(1);
     if ((c2 = getvirange(0)) != -1) {
 	forekill(c2 - cs, 0);
-	ret = 0;
 	if (vilinerange && ll) {
 	    if (cs == ll)
 		cs--;
@@ -311,7 +322,7 @@ videlete(char **args)
 	}
     }
     vichgflag = 0;
-    return ret;
+    return 0;
 }
 
 /**/
@@ -330,8 +341,10 @@ videletechar(char **args)
 	return ret;
     }
     /* it is an error to be on the end of line */
-    if (cs == ll || line[cs] == '\n')
+    if (cs == ll || line[cs] == '\n') {
+	feep();
 	return 1;
+    }
     /* Put argument into the acceptable range -- it is not an error to  *
      * specify a greater count than the number of available characters. */
     if (n > findeol() - cs)
@@ -345,17 +358,16 @@ videletechar(char **args)
 int
 vichange(char **args)
 {
-    int c2, ret = 1;
+    int c2;
 
     startvichange(1);
     if ((c2 = getvirange(1)) != -1) {
-	ret = 0;
 	forekill(c2 - cs, 0);
 	selectkeymap("main", 1);
 	viinsbegin = cs;
 	undoing = 0;
     }
-    return ret;
+    return 0;
 }
 
 /**/
@@ -365,11 +377,15 @@ visubstitute(char **args)
     int n = zmult;
 
     startvichange(1);
-    if (n < 0)
+    if (n < 0) {
+	feep();
 	return 1;
+    }
     /* it is an error to be on the end of line */
-    if (cs == ll || line[cs] == '\n')
+    if (cs == ll || line[cs] == '\n') {
+	feep();
 	return 1;
+    }
     /* Put argument into the acceptable range -- it is not an error to  *
      * specify a greater count than the number of available characters. */
     if (n > findeol() - cs)
@@ -420,8 +436,10 @@ viyankeol(char **args)
     int x = findeol();
 
     startvichange(-1);
-    if (x == cs)
+    if (x == cs) {
+	feep();
 	return 1;
+    }
     cut(cs, x - cs, 0);
     return 0;
 }
@@ -438,6 +456,7 @@ viyankwholeline(char **args)
 	return 1;
     while(n--) {
      if (cs > ll) {
+	feep();
 	cs = oldcs;
 	return 1;
      }
@@ -479,18 +498,23 @@ vireplacechars(char **args)
     startvichange(1);
     /* check argument range */
     if (n < 1 || n + cs > findeol()) {
-	if(vichgrepeat)
+	if(vichgrepeat) {
+	    int ofeep = feepflag;
 	    vigetkey();
+	    feepflag = ofeep;
+	}
 	if(vichgflag) {
 	    free(vichgbuf);
 	    vichgbuf = NULL;
 	    vichgflag = 0;
 	}
+	feep();
 	return 1;
     }
     /* get key */
     if((ch = vigetkey()) == -1) {
 	vichgflag = 0;
+	feep();
 	return 1;
     }
     /* do change */
@@ -513,7 +537,7 @@ int
 vicmdmode(char **args)
 {
     if (invicmdmode() || selectkeymap("vicmd", 0))
-	return 1;
+	feep();
     undoing = 1;
     vichgflag = 0;
     if (cs != findbol())
@@ -549,7 +573,7 @@ viopenlineabove(char **args)
 int
 vioperswapcase(char **args)
 {
-    int oldcs, c2, ret = 1;
+    int oldcs, c2;
 
     /* get the range */
     startvichange(1);
@@ -565,13 +589,12 @@ vioperswapcase(char **args)
 	}
 	/* go back to the first line of the range */
 	cs = oldcs;
-	ret = 0;
 #if 0
 	vifirstnonblank();
 #endif
     }
     vichgflag = 0;
-    return ret;
+    return 0;
 }
 
 /**/
@@ -579,8 +602,10 @@ int
 virepeatchange(char **args)
 {
     /* make sure we have a change to repeat */
-    if (!vichgbuf || vichgflag)
+    if (!vichgbuf || vichgflag) {
+	feep();
 	return 1;
+    }
     /* restore or update the saved count and buffer */
     if (zmod.flags & MOD_MULT) {
 	lastmod.mult = zmod.mult;
@@ -612,6 +637,7 @@ viindent(char **args)
     vichgflag = 0;
     /* must be a line range */
     if (!vilinerange) {
+	feep();
 	cs = oldcs;
 	return 1;
     }
@@ -643,6 +669,7 @@ viunindent(char **args)
     vichgflag = 0;
     /* must be a line range */
     if (!vilinerange) {
+	feep();
 	cs = oldcs;
 	return 1;
     }
@@ -678,6 +705,7 @@ vibackwarddeletechar(char **args)
     /* It is an error to be at the beginning of the line, or (in *
      * insert mode) to delete past the beginning of insertion.   */
     if ((!invicmdmode() && cs - n < viinsbegin) || cs == findbol()) {
+	feep();
 	return 1;
     }
     /* Put argument into the acceptable range -- it is not an error to  *
@@ -693,8 +721,10 @@ vibackwarddeletechar(char **args)
 int
 vikillline(char **args)
 {
-    if (viinsbegin > cs)
+    if (viinsbegin > cs) {
+	feep();
 	return 1;
+    }
     backdel(cs - viinsbegin);
     return 0;
 }
@@ -711,8 +741,10 @@ viputbefore(char **args)
 	return 1;
     if (zmod.flags & MOD_VIBUF)
 	buf = &vibuf[zmod.vibuf];
-    if (!buf->buf)
+    if (!buf->buf) {
+	feep();
 	return 1;
+    }
     if(buf->flags & CUTBUFFER_LINE) {
 	cs = findbol();
 	spaceinline(buf->len + 1);
@@ -743,8 +775,10 @@ viputafter(char **args)
 	return 1;
     if (zmod.flags & MOD_VIBUF)
 	buf = &vibuf[zmod.vibuf];
-    if (!buf->buf)
+    if (!buf->buf) {
+	feep();
 	return 1;
+    }
     if(buf->flags & CUTBUFFER_LINE) {
 	cs = findeol();
 	spaceinline(buf->len + 1);
@@ -772,8 +806,10 @@ vijoin(char **args)
     int x;
 
     startvichange(-1);
-    if ((x = findeol()) == ll)
+    if ((x = findeol()) == ll) {
+	feep();
 	return 1;
+    }
     cs = x + 1;
     for (x = 1; cs != ll && iblank(line[cs]); cs++, x++);
     backdel(x);
@@ -830,8 +866,10 @@ visetbuffer(char **args)
 
     if ((zmod.flags & MOD_VIBUF) ||
 	(((ch = getkey(0)) < '1' || ch > '9') &&
-	 (ch < 'a' || ch > 'z') && (ch < 'A' || ch > 'Z')))
+	 (ch < 'a' || ch > 'z') && (ch < 'A' || ch > 'Z'))) {
+	feep();
 	return 1;
+    }
     if (ch >= 'A' && ch <= 'Z')	/* needed in cut() */
 	zmod.flags |= MOD_VIAPP;
     else
@@ -851,6 +889,7 @@ vikilleol(char **args)
     startvichange(-1);
     if (!n) {
 	/* error -- line already empty */
+	feep();
 	return 1;
     }
     /* delete to end of line */
@@ -902,9 +941,10 @@ viquotedinsert(char **args)
     zsetterm();
 #endif
     foredel(1);
-    if(c < 0)
+    if(c < 0) {
+	feep();
 	return 1;
-    else
+    } else
 	return selfinsert(args);
 }
 
diff --git a/Src/Zle/zle_word.c b/Src/Zle/zle_word.c
index 31f83a2df..e768cbefa 100644
--- a/Src/Zle/zle_word.c
+++ b/Src/Zle/zle_word.c
@@ -300,8 +300,10 @@ vibackwardkillword(char **args)
     int x = cs, lim = (viinsbegin > findbol()) ? viinsbegin : findbol();
     int n = zmult;
 
-    if (n < 0)
+    if (n < 0) {
+	feep();
 	return 1;
+    }
 /* this taken from "vibackwardword" */
     while (n--) {
 	while ((x > lim) && iblank(line[x - 1]))
@@ -477,16 +479,22 @@ transposewords(char **args)
 	    x = cs;
 	    while (x && line[x - 1] != '\n' && !iword(line[x]))
 		x--;
-	    if (!x || line[x - 1] == '\n')
+	    if (!x || line[x - 1] == '\n') {
+		feep();
 		return 1;
+	    }
 	}
 	for (p4 = x; p4 != ll && iword(line[p4]); p4++);
 	for (p3 = p4; p3 && iword(line[p3 - 1]); p3--);
-	if (!p3)
+	if (!p3) {
+	    feep();
 	    return 1;
+	}
 	for (p2 = p3; p2 && !iword(line[p2 - 1]); p2--);
-	if (!p2)
+	if (!p2) {
+	    feep();
 	    return 1;
+	}
 	for (p1 = p2; p1 && iword(line[p1 - 1]); p1--);
 	pp = temp = (char *)zhalloc(p4 - p1 + 1);
 	struncpy(&pp, (char *) line + p3, p4 - p3);
diff --git a/Src/builtin.c b/Src/builtin.c
index 8fe112cb5..26bd9d74f 100644
--- a/Src/builtin.c
+++ b/Src/builtin.c
@@ -50,7 +50,7 @@ static struct builtin builtins[] =
     BUILTIN("cd", 0, bin_cd, 0, 2, BIN_CD, NULL, NULL),
     BUILTIN("chdir", 0, bin_cd, 0, 2, BIN_CD, NULL, NULL),
     BUILTIN("continue", BINF_PSPECIAL, bin_break, 0, 1, BIN_CONTINUE, NULL, NULL),
-    BUILTIN("declare", BINF_TYPEOPTS | BINF_MAGICEQUALS | BINF_PSPECIAL, bin_typeset, 0, -1, 0, "ALRTUZafgilrtux", NULL),
+    BUILTIN("declare", BINF_TYPEOPTS | BINF_MAGICEQUALS | BINF_PSPECIAL, bin_typeset, 0, -1, 0, "ALRTUZafilrtux", NULL),
     BUILTIN("dirs", 0, bin_dirs, 0, -1, 0, "v", NULL),
     BUILTIN("disable", 0, bin_enable, 0, -1, BIN_DISABLE, "afmr", NULL),
     BUILTIN("disown", 0, bin_fg, 0, -1, BIN_DISOWN, NULL, NULL),
@@ -60,7 +60,7 @@ static struct builtin builtins[] =
     BUILTIN("enable", 0, bin_enable, 0, -1, BIN_ENABLE, "afmr", NULL),
     BUILTIN("eval", BINF_PSPECIAL, bin_eval, 0, -1, BIN_EVAL, NULL, NULL),
     BUILTIN("exit", BINF_PSPECIAL, bin_break, 0, 1, BIN_EXIT, NULL, NULL),
-    BUILTIN("export", BINF_TYPEOPTS | BINF_MAGICEQUALS | BINF_PSPECIAL, bin_typeset, 0, -1, BIN_EXPORT, "LRTUZafilrtu", "xg"),
+    BUILTIN("export", BINF_TYPEOPTS | BINF_MAGICEQUALS | BINF_PSPECIAL, bin_typeset, 0, -1, BIN_EXPORT, "LRTUZafilrtu", "x"),
     BUILTIN("false", 0, bin_false, 0, -1, 0, NULL, NULL),
     BUILTIN("fc", BINF_FCOPTS, bin_fc, 0, -1, BIN_FC, "nlreIRWAdDfEim", NULL),
     BUILTIN("fg", 0, bin_fg, 0, -1, BIN_FG, NULL, NULL),
@@ -74,7 +74,7 @@ static struct builtin builtins[] =
 #endif
 
     BUILTIN("history", 0, bin_fc, 0, -1, BIN_FC, "nrdDfEim", "l"),
-    BUILTIN("integer", BINF_TYPEOPTS | BINF_MAGICEQUALS | BINF_PSPECIAL, bin_typeset, 0, -1, 0, "glrtux", "i"),
+    BUILTIN("integer", BINF_TYPEOPTS | BINF_MAGICEQUALS | BINF_PSPECIAL, bin_typeset, 0, -1, 0, "lrtux", "i"),
     BUILTIN("jobs", 0, bin_fg, 0, -1, BIN_JOBS, "dlpZrs", NULL),
     BUILTIN("kill", 0, bin_kill, 0, -1, 0, NULL, NULL),
     BUILTIN("let", 0, bin_let, 1, -1, 0, NULL, NULL),
@@ -93,7 +93,7 @@ static struct builtin builtins[] =
     BUILTIN("pwd", 0, bin_pwd, 0, 0, 0, "rLP", NULL),
     BUILTIN("r", BINF_R, bin_fc, 0, -1, BIN_FC, "nrl", NULL),
     BUILTIN("read", 0, bin_read, 0, -1, 0, "rzu0123456789pkqecnAlE", NULL),
-    BUILTIN("readonly", BINF_TYPEOPTS | BINF_MAGICEQUALS | BINF_PSPECIAL, bin_typeset, 0, -1, 0, "ALRTUZafgiltux", "r"),
+    BUILTIN("readonly", BINF_TYPEOPTS | BINF_MAGICEQUALS | BINF_PSPECIAL, bin_typeset, 0, -1, 0, "ALRTUZafiltux", "r"),
     BUILTIN("rehash", 0, bin_hash, 0, 0, 0, "dfv", "r"),
     BUILTIN("return", BINF_PSPECIAL, bin_break, 0, 1, BIN_RETURN, NULL, NULL),
     BUILTIN("set", BINF_PSPECIAL, bin_set, 0, -1, 0, NULL, NULL),
@@ -107,7 +107,7 @@ static struct builtin builtins[] =
     BUILTIN("trap", BINF_PSPECIAL, bin_trap, 0, -1, 0, NULL, NULL),
     BUILTIN("true", 0, bin_true, 0, -1, 0, NULL, NULL),
     BUILTIN("type", 0, bin_whence, 0, -1, 0, "ampfsw", "v"),
-    BUILTIN("typeset", BINF_TYPEOPTS | BINF_MAGICEQUALS | BINF_PSPECIAL, bin_typeset, 0, -1, 0, "ALRTUZafgilrtuxm", NULL),
+    BUILTIN("typeset", BINF_TYPEOPTS | BINF_MAGICEQUALS | BINF_PSPECIAL, bin_typeset, 0, -1, 0, "ALRTUZafilrtuxm", NULL),
     BUILTIN("umask", 0, bin_umask, 0, 1, 0, "S", NULL),
     BUILTIN("unalias", 0, bin_unhash, 1, -1, 0, "m", "a"),
     BUILTIN("unfunction", 0, bin_unhash, 1, -1, 0, "m", "f"),
@@ -120,9 +120,7 @@ static struct builtin builtins[] =
     BUILTIN("which", 0, bin_whence, 0, -1, 0, "ampsw", "c"),
 
 #ifdef DYNAMIC
-    BUILTIN("zmodload", 0, bin_zmodload, 0, -1, 0, "ILabcdipue", NULL),
-#else
-    BUILTIN("zmodload", 0, bin_zmodload, 0, -1, 0, "e", NULL),
+    BUILTIN("zmodload", 0, bin_zmodload, 0, -1, 0, "ILabcdipu", NULL),
 #endif
 };
 
@@ -1494,14 +1492,8 @@ typeset_single(char *cname, char *pname, Param pm, int func,
 {
     int usepm, tc, keeplocal = 0;
 
-    /*
-     * Do we use the existing pm?  Note that this isn't the end of the
-     * story, because if we try and create a new pm at the same
-     * locallevel as an unset one we use the pm struct anyway: that's
-     * handled in createparam().  Here we just avoid using it for the
-     * present tests if it's unset.
-     */
-    usepm = pm && !(pm->flags & PM_UNSET);
+    /* use the existing pm? */
+    usepm = pm && !(pm->flags & (PM_UNSET | PM_AUTOLOAD));
 
     /* Always use an existing pm if special at current locallevel */
     if (pm && (pm->flags & PM_SPECIAL) && pm->level == locallevel)
@@ -1510,15 +1502,15 @@ typeset_single(char *cname, char *pname, Param pm, int func,
     /*
      * Don't use a non-special existing param if
      *   - the local level has changed, and
-     *   - we are really locallizing the parameter
+     *   - the function is not `export'.
      */
     if (usepm && !(pm->flags & PM_SPECIAL) &&
-	locallevel != pm->level && (on & PM_LOCAL))
+	locallevel != pm->level && func != BIN_EXPORT)
 	usepm = 0;
 
     /* attempting a type conversion, or making a tied colonarray? */
     if ((tc = usepm && (((off & pm->flags) | (on & ~pm->flags)) &
-			(PM_INTEGER|PM_HASHED|PM_ARRAY|PM_TIED|PM_AUTOLOAD))))
+			(PM_INTEGER|PM_HASHED|PM_ARRAY|PM_TIED))))
 	usepm = 0;
     if (tc && (pm->flags & PM_SPECIAL)) {
 	zerrnam(cname, "%s: can't change type of a special parameter",
@@ -1527,7 +1519,6 @@ typeset_single(char *cname, char *pname, Param pm, int func,
     }
 
     if (usepm) {
-	on &= ~PM_LOCAL;
 	if (!on && !roff && !value) {
 	    paramtab->printnode((HashNode)pm, 0);
 	    return pm;
@@ -1614,7 +1605,7 @@ typeset_single(char *cname, char *pname, Param pm, int func,
 
     if (keeplocal)
 	pm->level = keeplocal;
-    else if (on & PM_LOCAL)
+    else if (func != BIN_EXPORT)
 	pm->level = locallevel;
     if (value && !(pm->flags & (PM_ARRAY|PM_HASHED)))
 	setsparam(pname, ztrdup(value));
@@ -1687,9 +1678,6 @@ bin_typeset(char *name, char **argv, char *ops, int func)
 	return 0;
     }
 
-    if (!ops['g'])
-	on |= PM_LOCAL;
-
     if (on & PM_TIED) {
 	Param apm;
 	struct asgment asg0;
@@ -3086,7 +3074,7 @@ bin_emulate(char *nam, char **argv, char *ops, int func)
 {
     emulate(*argv, ops['R']);
     if (ops['L'])
-	opts[LOCALOPTIONS] = opts[LOCALTRAPS] = 1;
+	dosetopt(LOCALOPTIONS, 1, 0);
     return 0;
 }
 
diff --git a/Src/exec.c b/Src/exec.c
index 5ae4f0d33..768706f4c 100644
--- a/Src/exec.c
+++ b/Src/exec.c
@@ -901,9 +901,6 @@ execpline(Sublist l, int how, int last1)
 		    DPUTS(!list_pipe_pid, "invalid list_pipe_pid");
 		    addproc(list_pipe_pid, list_pipe_text);
 
-		    if (!jn->procs->next)
-			jn->gleader = mypgrp;
-
 		    for (pn = jobtab[jn->other].procs; pn; pn = pn->next)
 			if (WIFSTOPPED(pn->status))
 			    break;
@@ -917,10 +914,8 @@ execpline(Sublist l, int how, int last1)
 		    jn->stat |= STAT_STOPPED | STAT_CHANGED;
 		    printjob(jn, !!isset(LONGLISTJOBS), 1);
 		}
-		else if (newjob != list_pipe_job)
-		    deletejob(jn);
 		else
-		    lastwj = -1;
+		    deletejob(jn);
 	    }
 
 	    for (; !nowait;) {
@@ -936,10 +931,7 @@ execpline(Sublist l, int how, int last1)
 		    lastval2 & 0200)
 		    killpg(mypgrp, lastval2 & ~0200);
 		if ((list_pipe || last1 || pline_level) &&
-		    !list_pipe_child && 
-		    ((jn->stat & STAT_STOPPED) ||
-		     (list_pipe_job && pline_level &&
-		      (jobtab[list_pipe_job].stat & STAT_STOPPED)))) {
+		    !list_pipe_child && jn->stat & STAT_STOPPED) {
 		    pid_t pid;
 		    int synch[2];
 
@@ -965,28 +957,22 @@ execpline(Sublist l, int how, int last1)
 			close(synch[1]);
 			read(synch[0], &dummy, 1);
 			close(synch[0]);
-			/* If this job has finished, we leave it as a
-			 * normal (non-super-) job. */
-			if (!(jn->stat & STAT_DONE)) {
-			    jobtab[list_pipe_job].other = newjob;
-			    jobtab[list_pipe_job].stat |= STAT_SUPERJOB;
-			    jn->stat |= STAT_SUBJOB | STAT_NOPRINT;
-			    jn->other = pid;
-			}
-			if ((list_pipe || last1) && jobtab[list_pipe_job].procs)
+			jobtab[list_pipe_job].other = newjob;
+			jobtab[list_pipe_job].stat |= STAT_SUPERJOB;
+			jn->stat |= STAT_SUBJOB | STAT_NOPRINT;
+			jn->other = pid;
+			if (list_pipe || last1)
 			    killpg(jobtab[list_pipe_job].gleader, SIGSTOP);
 			break;
 		    }
 		    else {
 			close(synch[0]);
 			entersubsh(Z_ASYNC, 0, 0);
-			if (jobtab[list_pipe_job].procs)
-			    setpgrp(0L, mypgrp = jobtab[list_pipe_job].gleader);
+			setpgrp(0L, mypgrp = jobtab[list_pipe_job].gleader);
 			close(synch[1]);
 			kill(getpid(), SIGSTOP);
 			list_pipe = 0;
 			list_pipe_child = 1;
-			opts[INTERACTIVE] = 0;
 			break;
 		    }
 		}
@@ -2208,9 +2194,8 @@ entersubsh(int how, int cl, int fake)
 		    attachtty(jobtab[thisjob].gleader);
 	    }
 	}
-	else if (!(list_pipe || list_pipe_child || pline_level > 1) &&
-		 (!jobtab[thisjob].gleader ||
-		  setpgrp(0L, jobtab[thisjob].gleader) == -1)) {
+	else if (!jobtab[thisjob].gleader ||
+		 (setpgrp(0L, jobtab[thisjob].gleader) == -1)) {
 	    jobtab[thisjob].gleader = getpid();
 	    if (list_pipe_job != thisjob &&
 		!jobtab[list_pipe_job].gleader)
@@ -2798,13 +2783,14 @@ execshfunc(Cmd cmd, Shfunc shf, LinkList args)
     if (errflag)
 	return;
 
-    if (!list_pipe && thisjob != list_pipe_job) {
+    if (!list_pipe) {
 	/* Without this deletejob the process table *
 	 * would be filled by a recursive function. */
 	last_file_list = jobtab[thisjob].filelist;
 	jobtab[thisjob].filelist = NULL;
 	deletejob(jobtab + thisjob);
     }
+
     if (isset(XTRACE)) {
 	LinkNode lptr;
 	printprompt4();
@@ -2883,7 +2869,7 @@ doshfunc(char *name, List list, LinkList doshargs, int flags, int noreturnval)
 {
     char **tab, **x, *oargv0 = NULL;
     int oldzoptind, oldlastval;
-    char saveopts[OPT_SIZE], *oldscriptname;
+    char saveopts[OPT_SIZE];
     int obreaks = breaks;
 
     HEAPALLOC {
@@ -2895,8 +2881,6 @@ doshfunc(char *name, List list, LinkList doshargs, int flags, int noreturnval)
 	starttrapscope();
 
 	tab = pparams;
-	oldscriptname = scriptname;
-	scriptname = name;
 	oldzoptind = zoptind;
 	zoptind = 1;
 
@@ -2939,7 +2923,6 @@ doshfunc(char *name, List list, LinkList doshargs, int flags, int noreturnval)
 	    argzero = oargv0;
 	}
 	zoptind = oldzoptind;
-	scriptname = oldscriptname;
 	pparams = tab;
 
 	if (isset(LOCALOPTIONS)) {
diff --git a/Src/glob.c b/Src/glob.c
index ea4980b8b..93b497632 100644
--- a/Src/glob.c
+++ b/Src/glob.c
@@ -1993,7 +1993,7 @@ dyncat(char *s1, char *s2)
     char *ptr;
     int l1 = strlen(s1);
 
-    ptr = (char *)zhalloc(l1 + strlen(s2) + 1);
+    ptr = (char *)ncalloc(l1 + strlen(s2) + 1);
     strcpy(ptr, s1);
     strcpy(ptr + l1, s2);
     return ptr;
diff --git a/Src/hashtable.c b/Src/hashtable.c
index c4c0b00ac..e80461b4e 100644
--- a/Src/hashtable.c
+++ b/Src/hashtable.c
@@ -133,7 +133,6 @@ deletehashtable(HashTable ht)
 	ht->last->next = ht->next;
     else
 	firstht = ht->next;
-    zsfree(ht->tablename);
 #endif /* ZSH_HASH_DEBUG */
     zfree(ht->nodes, ht->hsize * sizeof(HashNode));
     zfree(ht, sizeof(*ht));
diff --git a/Src/init.c b/Src/init.c
index 51c2b88a5..10286ea87 100644
--- a/Src/init.c
+++ b/Src/init.c
@@ -390,16 +390,7 @@ init_io(void)
 #ifdef JOB_CONTROL
     /* If interactive, make the shell the foreground process */
     if (opts[MONITOR] && interact && (SHTTY != -1)) {
-      /* Since we now sometimes execute programs in the process group
-       * of the parent shell even when using job-control, we have to
-       * make sure that we run in our own process group. Otherwise if
-       * we are called from a program that doesn't put us in our own
-       * group a SIGTSTP that we ignore might stop our parent process.
-       * Instead of the two calls below we once had:
-       *   attachtty(GETPGRP());
-       */
-	attachtty(getpid());
-	setpgrp(0L, 0L);
+	attachtty(GETPGRP());
 	if ((mypgrp = GETPGRP()) > 0) {
 	    while ((ttpgrp = gettygrp()) != -1 && ttpgrp != mypgrp) {
 		sleep(1);
diff --git a/Src/jobs.c b/Src/jobs.c
index a50b84fd7..31861e284 100644
--- a/Src/jobs.c
+++ b/Src/jobs.c
@@ -92,13 +92,9 @@ makerunning(Job jn)
 
     jn->stat &= ~STAT_STOPPED;
     for (pn = jn->procs; pn; pn = pn->next)
-#if 0
 	if (WIFSTOPPED(pn->status) && 
 	    (!(jn->stat & STAT_SUPERJOB) || pn->next))
 	    pn->status = SP_RUNNING;
-#endif
-        if (WIFSTOPPED(pn->status))
-	    pn->status = SP_RUNNING;
 
     if (jn->stat & STAT_SUPERJOB)
 	makerunning(jobtab + jn->other);
@@ -185,9 +181,8 @@ update_job(Job jn)
 
 		for (i = 1; i < MAXJOB; i++)
 		    if ((jobtab[i].stat & STAT_SUPERJOB) &&
-			jobtab[i].other == job &&
-			jobtab[i].gleader) {
-			killpg(jobtab[i].gleader, SIGTSTP);
+			jobtab[i].other == job) {
+			killpg(jobtab[i].gleader, SIGSTOP);
 			break;
 		    }
 	    }
diff --git a/Src/loop.c b/Src/loop.c
index 16e4ff314..b35024d6b 100644
--- a/Src/loop.c
+++ b/Src/loop.c
@@ -378,7 +378,7 @@ execif(Cmd cmd, LinkList args, int flags)
     noerrexit = olderrexit;
 
     if (*t) {
-	cmdpush(*i ? (s ? CS_ELIFTHEN : CS_IFTHEN) : CS_ELSE);
+	cmdpush(s ? CS_ELIFTHEN : CS_IFTHEN);
 	execlist(*t, 1, flags & CFLAG_EXEC);
 	cmdpop();
     } else
diff --git a/Src/module.c b/Src/module.c
index ce926c27a..fa7dd2774 100644
--- a/Src/module.c
+++ b/Src/module.c
@@ -709,14 +709,7 @@ bin_zmodload(char *nam, char **args, char *ops, int func)
 	zwarnnam(nam, "what do you want to unload?", NULL, 0);
 	return 1;
     }
-    if (ops['e'] && (ops['I'] || ops['L'] || ops['a'] || ops['d'] ||
-		     ops['i'] || ops['u'])) {
-	zwarnnam(nam, "-e cannot be combined with other options", NULL, 0);
-	return 1;
-    }
-    if (ops['e'])
-	return bin_zmodload_exist(nam, args, ops);
-    else if (ops['d'])
+    if (ops['d'])
 	return bin_zmodload_dep(nam, args, ops);
     else if ((ops['a'] || ops['b']) && !(ops['c'] || ops['p']))
 	return bin_zmodload_auto(nam, args, ops);
@@ -734,46 +727,6 @@ bin_zmodload(char *nam, char **args, char *ops, int func)
 
 /**/
 static int
-bin_zmodload_exist(char *nam, char **args, char *ops)
-{
-    LinkNode node;
-    Module m;
-
-    if (!*args) {
-	for (node = firstnode(bltinmodules); node; incnode(node)) {
-	    nicezputs((char *) getdata(node), stdout);
-	    putchar('\n');
-	}
-	for (node = firstnode(modules); node; incnode(node)) {
-	    m = (Module) getdata(node);
-	    if (m->handle && !(m->flags & MOD_UNLOAD)) {
-		nicezputs(m->nam, stdout);
-		putchar('\n');
-	    }
-	}
-	return 0;
-    } else {
-	int ret = 0, f;
-
-	for (; !ret && *args; args++) {
-	    f = 0;
-	    for (node = firstnode(bltinmodules);
-		 !f && node; incnode(node))
-		f = !strcmp(*args, (char *) getdata(node));
-	    for (node = firstnode(modules);
-		 !f && node; incnode(node)) {
-		m = (Module) getdata(node);
-		if (m->handle && !(m->flags & MOD_UNLOAD))
-		    f = !strcmp(*args, m->nam);
-	    }
-	    ret = !f;
-	}
-	return ret;
-    }
-}
-
-/**/
-static int
 bin_zmodload_dep(char *nam, char **args, char *ops)
 {
     LinkNode node;
@@ -1163,37 +1116,6 @@ bin_zmodload_load(char *nam, char **args, char *ops)
 }
 
 /**/
-#else /* DYNAMIC */
-
-/* This is the version for shells without dynamic linking. */
-
-/**/
-int
-bin_zmodload(char *nam, char **args, char *ops, int func)
-{
-    /* We understand only the -e option. */
-
-    if (ops['e']) {
-	LinkNode node;
-
-	if (!*args) {
-	    for (node = firstnode(bltinmodules); node; incnode(node)) {
-		nicezputs((char *) getdata(node), stdout);
-		putchar('\n');
-	    }
-	} else {
-	    for (; *args; args++)
-		for (node = firstnode(bltinmodules); node; incnode(node))
-		    if (strcmp(*args, (char *) getdata(node)))
-			return 1;
-	}
-	return 0;
-    }
-    /* Otherwise we return 1 -- different from the dynamic version. */
-    return 1;
-}
-
-/**/
 #endif /* DYNAMIC */
 
 /* The list of module-defined conditions. */
@@ -1284,180 +1206,6 @@ addconddefs(char const *nam, Conddef c, int size)
     return hadf ? hads : 1;
 }
 
-/* This list of hook functions defined. */
-
-/**/
-Hookdef hooktab;
-
-/* Find a hook definition given the name. */
-
-/**/
-Hookdef
-gethookdef(char *n)
-{
-    Hookdef p;
-
-    for (p = hooktab; p; p = p->next)
-	if (!strcmp(n, p->name))
-	    return p;
-    return NULL;
-}
-
-/* This adds the given hook definition. The return value is zero on      *
- * success and 1 on failure.                                             */
-
-/**/
-int
-addhookdef(Hookdef h)
-{
-    if (gethookdef(h->name))
-	return 1;
-
-    h->next = hooktab;
-    hooktab = h;
-    PERMALLOC {
-	h->funcs = newlinklist();
-    } LASTALLOC;
-
-    return 0;
-}
-
-/* This adds multiple hook definitions. This is like addbuiltins(). */
-
-/**/
-int
-addhookdefs(char const *nam, Hookdef h, int size)
-{
-    int hads = 0, hadf = 0;
-
-    while (size--) {
-	if (addhookdef(h)) {
-	    zwarnnam(nam, "name clash when adding condition `%s'", h->name, 0);
-	    hadf = 1;
-	} else
-	    hads = 2;
-	h++;
-    }
-    return hadf ? hads : 1;
-}
-
-/* Delete hook definitions. */
-
-/**/
-int
-deletehookdef(Hookdef h)
-{
-    Hookdef p, q;
-
-    for (p = hooktab, q = NULL; p && p != h; q = p, p = p->next);
-
-    if (!p)
-	return 1;
-
-    if (q)
-	q->next = p->next;
-    else
-	hooktab = p->next;
-    freelinklist(p->funcs, NULL);
-    return 0;
-}
-
-/**/
-int
-deletehookdefs(char const *nam, Hookdef h, int size)
-{
-    while (size--) {
-	deletehookdef(h);
-	h++;
-    }
-    return 1;
-}
-
-/* Add a function to a hook. */
-
-/**/
-int
-addhookdeffunc(Hookdef h, Hookfn f)
-{
-    PERMALLOC {
-	addlinknode(h->funcs, (void *) f);
-    } LASTALLOC;
-    return 0;
-}
-
-/**/
-int
-addhookfunc(char *n, Hookfn f)
-{
-    Hookdef h = gethookdef(n);
-
-    if (h)
-	return addhookdeffunc(h, f);
-    return 1;
-}
-
-/* Delete a function from a hook. */
-
-/**/
-int
-deletehookdeffunc(Hookdef h, Hookfn f)
-{
-    LinkNode p;
-
-    for (p = firstnode(h->funcs); p; incnode(p))
-	if (f == (Hookfn) getdata(p)) {
-	    remnode(h->funcs, p);
-	    return 0;
-	}
-    return 1;
-}
-
-/**/
-int
-deletehookfunc(char *n, Hookfn f)
-{
-    Hookdef h = gethookdef(n);
-
-    if (h)
-	return deletehookdeffunc(h, f);
-    return 1;
-}
-
-/* Run the function(s) for a hook. */
-
-/**/
-int
-runhookdef(Hookdef h, void *d)
-{
-    if (empty(h->funcs)) {
-	if (h->def)
-	    return h->def(h, d);
-	return 0;
-    } else if (h->flags & HOOKF_ALL) {
-	LinkNode p;
-	int r;
-
-	for (p = firstnode(h->funcs); p; incnode(p))
-	    if ((r = ((Hookfn) getdata(p))(h, d)))
-		return r;
-	if (h->def)
-	    return h->def(h, d);
-	return 0;
-    } else
-	return ((Hookfn) getdata(lastnode(h->funcs)))(h, d);
-}
-
-/**/
-int
-runhook(char *n, void *d)
-{
-    Hookdef h = gethookdef(n);
-
-    if (h)
-	return runhookdef(h, d);
-    return 0;
-}
-
 /* This adds the given parameter definition. The return value is zero on *
  * success and 1 on failure. */
 
diff --git a/Src/params.c b/Src/params.c
index d71cfb46e..b9f3d33a0 100644
--- a/Src/params.c
+++ b/Src/params.c
@@ -588,7 +588,7 @@ createparam(char *name, int flags)
 
 	DPUTS(oldpm && oldpm->level > locallevel,
 	      "BUG:  old local parameter not deleteed");
-	if (oldpm && (oldpm->level == locallevel || !(flags & PM_LOCAL))) {
+	if (oldpm && oldpm->level == locallevel) {
 	    if (!(oldpm->flags & PM_UNSET) || (oldpm->flags & PM_SPECIAL)) {
 		oldpm->flags &= ~PM_UNSET;
 		return NULL;
@@ -616,7 +616,7 @@ createparam(char *name, int flags)
 	pm = (Param) alloc(sizeof *pm);
 	pm->nam = nulstring;
     }
-    pm->flags = flags & ~PM_LOCAL;
+    pm->flags = flags;
 
     if(!(pm->flags & PM_SPECIAL))
 	assigngetset(pm);
@@ -1898,7 +1898,7 @@ arrhashsetfn(Param pm, char **val)
      * since that could cause trouble for special hashes.  This way, *
      * it's up to pm->sets.hfn() what to do.                         */
     int alen = arrlen(val);
-    HashTable opmtab = paramtab, ht = 0;
+    HashTable opmtab = paramtab, ht;
     char **aptr = val;
     Value v = (Value) hcalloc(sizeof *v);
     v->b = -1;
@@ -1909,8 +1909,7 @@ arrhashsetfn(Param pm, char **val)
 	     NULL, 0);
 	return;
     }
-    if (alen)
-	ht = paramtab = newparamtable(17, pm->nam);
+    ht = paramtab = newparamtable(17, pm->nam);
     while (*aptr) {
 	/* The parameter name is ztrdup'd... */
 	v->pm = createparam(*aptr, PM_SCALAR|PM_UNSET);
diff --git a/Src/subst.c b/Src/subst.c
index 18d815404..ab6bf84fb 100644
--- a/Src/subst.c
+++ b/Src/subst.c
@@ -1328,15 +1328,10 @@ paramsubst(LinkList l, LinkNode n, char **str, int qt, int ssub)
 			else
 			    t = aval;
 		    } else if (!isarr) {
-			if (!*val && arrasg > 1) {
-			    arr[0] = NULL;
-			    l = 0;
-			} else {
-			    arr[0] = val;
-			    arr[1] = NULL;
-			    l = 1;
-			}
+			arr[0] = val;
+			arr[1] = NULL;
 			t = aval = arr;
+			l = 1;
 		    } else
 			l = arrlen(aval), t = aval;
 		    p = a = zalloc(sizeof(char *) * (l + 1));
diff --git a/Src/utils.c b/Src/utils.c
index a409ab03c..16dbe9229 100644
--- a/Src/utils.c
+++ b/Src/utils.c
@@ -62,10 +62,9 @@ zerr(const char *fmt, const char *str, int num)
     /*
      * scriptname is set when sourcing scripts, so that we get the
      * correct name instead of the generic name of whatever
-     * program/script is running.  It's also set in shell functions,
-     * so test locallevel, too.
+     * program/script is running.
      */
-    nicezputs((isset(SHINSTDIN) && !locallevel) ? "zsh" :
+    nicezputs(isset(SHINSTDIN) ? "zsh" :
 	      scriptname ? scriptname : argzero, stderr);
     fputs(": ", stderr);
     zerrnam(NULL, fmt, str, num);
@@ -80,7 +79,7 @@ zerrnam(const char *cmd, const char *fmt, const char *str, int num)
 	    return;
 	errflag = 1;
 	trashzle();
-	if (unset(SHINSTDIN) || locallevel) {
+	if(unset(SHINSTDIN)) {
 	    nicezputs(scriptname ? scriptname : argzero, stderr);
 	    fputs(": ", stderr);
 	}
@@ -134,7 +133,7 @@ zerrnam(const char *cmd, const char *fmt, const char *str, int num)
 	    putc(*fmt == Meta ? *++fmt ^ 32 : *fmt, stderr);
 	    fmt++;
 	}
-    if ((unset(SHINSTDIN) || locallevel) && lineno)
+    if (unset(SHINSTDIN) && lineno)
 	fprintf(stderr, " [%ld]\n", (long)lineno);
     else
 	putc('\n', stderr);
@@ -2134,12 +2133,7 @@ mkarray(char *s)
 void
 zbeep(void)
 {
-    char *vb;
-    if ((vb = getsparam("ZBEEP"))) {
-	int len;
-	vb = getkeystring(vb, &len, 2, NULL);
-	write(SHTTY, vb, len);
-    } else if (isset(BEEP))
+    if (isset(BEEP))
 	write(SHTTY, "\07", 1);
 }
 
diff --git a/Src/xmods.conf b/Src/xmods.conf
index 6b7f1701a..c36105721 100644
--- a/Src/xmods.conf
+++ b/Src/xmods.conf
@@ -3,4 +3,3 @@ comp1
 zle
 compctl
 sched
-complist
diff --git a/Src/zsh.export b/Src/zsh.export
index 5a3a94c70..9cb186ffa 100644
--- a/Src/zsh.export
+++ b/Src/zsh.export
@@ -5,8 +5,6 @@ addconddefs
 addedx
 addhashnode
 addhistnum
-addhookdefs
-addhookfunc
 addparamdefs
 addwrapper
 arrvargetfn
@@ -45,8 +43,6 @@ current_limits
 deletebuiltins
 deleteconddefs
 deletehashtable
-deletehookdefs
-deletehookfunc
 deleteparamdefs
 deleteparamtable
 deletewrapper
@@ -211,7 +207,6 @@ resetneeded
 restoredir
 reswdtab
 retflag
-runhookdef
 runshfunc
 scancountparams
 scanhashtable
diff --git a/Src/zsh.h b/Src/zsh.h
index 45691039e..23e84b2ec 100644
--- a/Src/zsh.h
+++ b/Src/zsh.h
@@ -278,9 +278,8 @@ typedef struct heapstack *Heapstack;
 typedef struct histent   *Histent;
 typedef struct forcmd    *Forcmd;
 typedef struct autofn    *AutoFn;
-typedef struct hookdef   *Hookdef;
 
-typedef struct asgment   *Asgment;
+typedef struct asgment  *Asgment;
 
 
 /********************************/
@@ -888,22 +887,6 @@ struct module {
 #define MOD_UNLOAD  (1<<1)
 #define MOD_SETUP   (1<<2)
 
-/* C-function hooks */
-
-typedef int (*Hookfn) _((Hookdef, void *));
-
-struct hookdef {
-    Hookdef next;
-    char *name;
-    Hookfn def;
-    int flags;
-    LinkList funcs;
-};
-
-#define HOOKF_ALL 1
-
-#define HOOKDEF(name, func, flags) { NULL, name, (Hookfn) func, flags, NULL }
-
 /* node used in parameter hash table (paramtab) */
 
 struct param {
@@ -976,13 +959,12 @@ struct param {
 #define PM_UNALIASED	(1<<11)	/* do not expand aliases when autoloading     */
 
 #define PM_TIED 	(1<<12)	/* array tied to colon-path or v.v. */
-#define PM_LOCAL	(1<<13) /* this parameter will be made local */
-#define PM_SPECIAL	(1<<14) /* special builtin parameter                  */
-#define PM_DONTIMPORT	(1<<15)	/* do not import this variable                */
-#define PM_RESTRICTED	(1<<16) /* cannot be changed in restricted mode       */
-#define PM_UNSET	(1<<17)	/* has null value                             */
-#define PM_REMOVABLE	(1<<18)	/* special can be removed from paramtab */
-#define PM_AUTOLOAD     (1<<19) /* autoloaded from module */
+#define PM_SPECIAL	(1<<13) /* special builtin parameter                  */
+#define PM_DONTIMPORT	(1<<14)	/* do not import this variable                */
+#define PM_RESTRICTED	(1<<15) /* cannot be changed in restricted mode       */
+#define PM_UNSET	(1<<16)	/* has null value                             */
+#define PM_REMOVABLE	(1<<17)	/* special can be removed from paramtab */
+#define PM_AUTOLOAD     (1<<18) /* autoloaded from module */
 
 /* Flags for extracting elements of arrays and associative arrays */
 #define SCANPM_WANTVALS   (1<<0)