about summary refs log tree commit diff
path: root/Src/Zle/zle_hist.c
diff options
context:
space:
mode:
Diffstat (limited to 'Src/Zle/zle_hist.c')
-rw-r--r--Src/Zle/zle_hist.c78
1 files changed, 26 insertions, 52 deletions
diff --git a/Src/Zle/zle_hist.c b/Src/Zle/zle_hist.c
index 66abbe438..f85fa00a6 100644
--- a/Src/Zle/zle_hist.c
+++ b/Src/Zle/zle_hist.c
@@ -77,10 +77,8 @@ int
 uphistory(char **args)
 {
     int nodups = isset(HISTIGNOREDUPS);
-    if (!zle_goto_hist(histline, -zmult, nodups) && isset(HISTBEEP)) {
-	feep();
+    if (!zle_goto_hist(histline, -zmult, nodups) && isset(HISTBEEP))
 	return 1;
-    }
     return 0;
 }
 
@@ -128,10 +126,8 @@ uplineorhistory(char **args)
 	int m = zmult, ret;
 
 	cs = ocs;
-	if (virangeflag || !histallowed) {
-	    feep();
+	if (virangeflag || !histallowed)
 	    return 1;
-	}
 	zmult = n;
 	ret = uphistory(args);
 	zmult = m;
@@ -160,10 +156,8 @@ uplineorsearch(char **args)
 	int m = zmult, ret;
 
 	cs = ocs;
-	if (virangeflag || !histallowed) {
-	    feep();
+	if (virangeflag || !histallowed)
 	    return 1;
-	}
 	zmult = n;
 	ret = historysearchbackward(args);
 	zmult = m;
@@ -216,10 +210,8 @@ downlineorhistory(char **args)
 	int m = zmult, ret;
 
 	cs = ocs;
-	if (virangeflag || !histallowed) {
-	    feep();
+	if (virangeflag || !histallowed)
 	    return 1;
-	}
 	zmult = n;
 	ret = downhistory(args);
 	zmult = m;
@@ -248,10 +240,8 @@ downlineorsearch(char **args)
 	int m = zmult, ret;
 
 	cs = ocs;
-	if (virangeflag || !histallowed) {
-	    feep();
+	if (virangeflag || !histallowed)
 	    return 1;
-	}
 	zmult = n;
 	ret = historysearchforward(args);
 	zmult = m;
@@ -266,10 +256,8 @@ acceptlineanddownhistory(char **args)
 {
     Histent he;
 
-    if (!(he = movehistent(quietgethist(histline), 1, HIST_FOREIGN))) {
-	feep();
+    if (!(he = movehistent(quietgethist(histline), 1, HIST_FOREIGN)))
 	return 1;
-    }
     pushnode(bufstack, ztrdup(ZLETEXT(he)));
     done = 1;
     stackhist = he->histnum;
@@ -281,10 +269,8 @@ int
 downhistory(char **args)
 {
     int nodups = isset(HISTIGNOREDUPS);
-    if (!zle_goto_hist(histline, zmult, nodups) && isset(HISTBEEP)) {
-	feep();
+    if (!zle_goto_hist(histline, zmult, nodups) && isset(HISTBEEP))
 	return 1;
-    }
     return 0;
 }
 
@@ -336,7 +322,6 @@ historysearchbackward(char **args)
 	    }
 	}
     }
-    feep();
     return 1;
 }
 
@@ -385,7 +370,6 @@ historysearchforward(char **args)
 	    }
 	}
     }
-    feep();
     return 1;
 }
 
@@ -404,10 +388,8 @@ beginningofbufferorhistory(char **args)
 int
 beginningofhistory(char **args)
 {
-    if (!zle_goto_hist(firsthist(), 0, 0) && isset(HISTBEEP)) {
-	feep();
+    if (!zle_goto_hist(firsthist(), 0, 0) && isset(HISTBEEP))
 	return 1;
-    }
     return 0;
 }
 
@@ -457,19 +439,15 @@ insertlastword(char **args)
 	zsfree(lastinsert);
 	lastinsert = NULL;
     }
-    if (!(he = quietgethist(evhist)) || !he->nwords) {
-	feep();
+    if (!(he = quietgethist(evhist)) || !he->nwords)
 	return 1;
-    }
     if (zmult > 0) {
 	n = he->nwords - (zmult - 1);
     } else {
 	n = 1 - zmult;
     }
-    if (n < 1 || n > he->nwords) {
-	feep();
+    if (n < 1 || n > he->nwords)
 	return 1;
-    }
     s = he->text + he->words[2*n-2];
     t = he->text + he->words[2*n-1];
     save = *t;
@@ -591,7 +569,6 @@ getline(char **args)
     char *s = (char *)getlinknode(bufstack);
 
     if (!s) {
-	feep();
 	return 1;
     } else {
 	int cc;
@@ -693,7 +670,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;
+    int hl = histline, savekeys = -1, feep = 0;
     Thingy cmd;
     char *okeymap = curkeymapname;
     static char *previous_search = NULL;
@@ -762,7 +739,7 @@ doisearch(char **args, int dir)
 		    get_isrch_spot(top_spot, &hl, &pos, &cs, &sbptr,
 				   &dir, &nomatch);
 		    if (!nomatch) {
-			feep();
+			feep = 1;
 			nomatch = 1;
 		    }
 		    he = quietgethist(hl);
@@ -803,7 +780,7 @@ doisearch(char **args, int dir)
 	    goto ref;
 	} else if(cmd == Th(z_vicmdmode)) {
 	    if(selectkeymap(invicmdmode() ? "main" : "vicmd", 0))
-		feep();
+		feep = 1;
 	    goto ref;
 	} else if(cmd == Th(z_vibackwarddeletechar) ||
 	    	cmd == Th(z_backwarddeletechar)) {
@@ -811,7 +788,7 @@ doisearch(char **args, int dir)
 		get_isrch_spot(--top_spot, &hl, &pos, &cs, &sbptr,
 			       &dir, &nomatch);
 	    else
-		feep();
+		feep = 1;
 	    if (nomatch) {
 		statusline = ibuf;
 		skip_pos = 1;
@@ -878,7 +855,7 @@ doisearch(char **args, int dir)
 		zrefresh();
 	    }
 	    if ((c = getkey(0)) == EOF)
-		feep();
+		feep = 1;
 	    else
 		goto ins;
 	} else {
@@ -896,7 +873,7 @@ doisearch(char **args, int dir)
 	    }
 	ins:
 	    if (sbptr == PATH_MAX) {
-		feep();
+		feep = 1;
 		continue;
 	    }
 	    set_isrch_spot(top_spot++, hl, pos, cs, sbptr, dir, nomatch);
@@ -907,7 +884,9 @@ doisearch(char **args, int dir)
 	    }
 	    sbuf[sbptr++] = c;
 	}
-	handlefeep();
+	if (feep)
+	    handlefeep(zlenoargs);
+	feep = 0;
     }
     if (sbptr) {
 	zfree(previous_search, previous_search_len);
@@ -957,7 +936,6 @@ infernexthistory(char **args)
 	    return 0;
 	}
     }
-    feep();
     return 1;
 }
 
@@ -976,7 +954,6 @@ vifetchhistory(char **args)
     }
     if (!zle_goto_hist((zmod.flags & MOD_MULT) ? zmult : curhist, 0, 0) &&
 	isset(HISTBEEP)) {
-	feep();
 	return 1;
     }
     return 0;
@@ -992,7 +969,7 @@ static int
 getvisrchstr(void)
 {
     char *sbuf = zhalloc(80);
-    int sptr = 1, ret = 0, ssbuf = 80;
+    int sptr = 1, ret = 0, ssbuf = 80, feep = 0;
     Thingy cmd;
     char *okeymap = curkeymapname;
 
@@ -1045,7 +1022,7 @@ getvisrchstr(void)
 		zrefresh();
 	    }
 	    if ((c = getkey(0)) == EOF)
-		feep();
+		feep = 1;
 	    else
 		goto ins;
 	} else if(cmd == Th(z_selfinsertunmeta) || cmd == Th(z_selfinsert)) {
@@ -1062,9 +1039,11 @@ getvisrchstr(void)
 	    }
 	    sbuf[sptr++] = c;
 	} else {
-	    feep();
+	    feep = 1;
 	}
-	handlefeep();
+	if (feep)
+	    handlefeep(zlenoargs);
+	feep = 0;
     }
     statusline = NULL;
     selectkeymap(okeymap, 1);
@@ -1122,10 +1101,8 @@ virepeatsearch(char **args)
     int n = zmult;
     char *s;
 
-    if (!visrchstr) {
-	feep();
+    if (!visrchstr)
 	return 1;
-    }
     if (zmult < 0) {
 	n = -n;
 	visrchsense = -visrchsense;
@@ -1145,7 +1122,6 @@ virepeatsearch(char **args)
 	    }
 	}
     }
-    feep();
     return 1;
 }
 
@@ -1194,7 +1170,6 @@ historybeginningsearchbackward(char **args)
 	    }
 	}
     }
-    feep();
     return 1;
 }
 
@@ -1231,6 +1206,5 @@ historybeginningsearchforward(char **args)
 	    }
 	}
     }
-    feep();
     return 1;
 }