summaryrefslogtreecommitdiff
path: root/lib/libedit/emacs.c
diff options
context:
space:
mode:
authorOtto Moerbeek <otto@cvs.openbsd.org>2003-10-31 08:42:25 +0000
committerOtto Moerbeek <otto@cvs.openbsd.org>2003-10-31 08:42:25 +0000
commit6ff1c1765c2b4495f0292fe730d9bb9a5daef063 (patch)
treef9b79c5d3b01533c847610f8410f66661df68535 /lib/libedit/emacs.c
parent4c1c60ce562b0cf6d8cb6e2e49e2b53193359874 (diff)
Update to NetBSD libedit (from Oct 1, 2003), adding some string
cleaning and history bug fixes. The code includes GNU libreadline functionality, but the corresponding header files are not installed, since some libreadline functions are missing. There are some minor API changes, notably: old: EditLine *el_init(const char *, FILE *, FILE *); new: EditLine *el_init(const char *, FILE *, FILE *, FILE *); old: HistEvent *history(History *h, int op, ...); new: int history(History *h, HistEvent *ev, int op, ...); plus some changes in operation names. See editline(3) for details. Tested by djm@, mouring@, jmc@. ok deraadt@
Diffstat (limited to 'lib/libedit/emacs.c')
-rw-r--r--lib/libedit/emacs.c500
1 files changed, 239 insertions, 261 deletions
diff --git a/lib/libedit/emacs.c b/lib/libedit/emacs.c
index b4d92cf5aa1..59b01ac31fc 100644
--- a/lib/libedit/emacs.c
+++ b/lib/libedit/emacs.c
@@ -1,5 +1,5 @@
-/* $OpenBSD: emacs.c,v 1.5 2003/06/02 20:18:40 millert Exp $ */
-/* $NetBSD: emacs.c,v 1.3 1997/01/11 06:47:54 lukem Exp $ */
+/* $OpenBSD: emacs.c,v 1.6 2003/10/31 08:42:24 otto Exp $ */
+/* $NetBSD: emacs.c,v 1.15 2003/08/07 16:44:31 agc Exp $ */
/*-
* Copyright (c) 1992, 1993
@@ -33,18 +33,18 @@
* SUCH DAMAGE.
*/
+#include "config.h"
#if !defined(lint) && !defined(SCCSID)
#if 0
static char sccsid[] = "@(#)emacs.c 8.1 (Berkeley) 6/4/93";
#else
-static const char rcsid[] = "$OpenBSD: emacs.c,v 1.5 2003/06/02 20:18:40 millert Exp $";
+static const char rcsid[] = "$OpenBSD: emacs.c,v 1.6 2003/10/31 08:42:24 otto Exp $";
#endif
#endif /* not lint && not SCCSID */
-/*
+/*
* emacs.c: Emacs functions
*/
-#include "sys.h"
#include "el.h"
/* em_delete_or_list():
@@ -53,28 +53,31 @@ static const char rcsid[] = "$OpenBSD: emacs.c,v 1.5 2003/06/02 20:18:40 millert
*/
protected el_action_t
/*ARGSUSED*/
-em_delete_or_list(el, c)
- EditLine *el;
- int c;
+em_delete_or_list(EditLine *el, int c __attribute__((__unused__)))
{
- if (el->el_line.cursor == el->el_line.lastchar) { /* if I'm at the end */
- if (el->el_line.cursor == el->el_line.buffer) { /* and the beginning */
- term_overwrite(el, STReof, 4);/* then do a EOF */
- term__flush();
- return CC_EOF;
- }
- else {
- /* Here we could list completions, but it is an error right now */
- term_beep(el);
- return CC_ERROR;
+
+ if (el->el_line.cursor == el->el_line.lastchar) {
+ /* if I'm at the end */
+ if (el->el_line.cursor == el->el_line.buffer) {
+ /* and the beginning */
+ term_overwrite(el, STReof, 4); /* then do a EOF */
+ term__flush();
+ return (CC_EOF);
+ } else {
+ /*
+ * Here we could list completions, but it is an
+ * error right now
+ */
+ term_beep(el);
+ return (CC_ERROR);
+ }
+ } else {
+ c_delafter(el, el->el_state.argument); /* delete after dot */
+ if (el->el_line.cursor > el->el_line.lastchar)
+ el->el_line.cursor = el->el_line.lastchar;
+ /* bounds check */
+ return (CC_REFRESH);
}
- }
- else {
- c_delafter(el, el->el_state.argument); /* delete after dot */
- if (el->el_line.cursor > el->el_line.lastchar)
- el->el_line.cursor = el->el_line.lastchar; /* bounds check */
- return CC_REFRESH;
- }
}
@@ -84,27 +87,26 @@ em_delete_or_list(el, c)
*/
protected el_action_t
/*ARGSUSED*/
-em_delete_next_word(el, c)
- EditLine *el;
- int c;
+em_delete_next_word(EditLine *el, int c __attribute__((__unused__)))
{
- char *cp, *p, *kp;
+ char *cp, *p, *kp;
- if (el->el_line.cursor == el->el_line.lastchar)
- return CC_ERROR;
+ if (el->el_line.cursor == el->el_line.lastchar)
+ return (CC_ERROR);
- cp = c__next_word(el->el_line.cursor, el->el_line.lastchar,
- el->el_state.argument, ce__isword);
+ cp = c__next_word(el->el_line.cursor, el->el_line.lastchar,
+ el->el_state.argument, ce__isword);
- for (p = el->el_line.cursor, kp = el->el_chared.c_kill.buf; p < cp; p++)
- /* save the text */
- *kp++ = *p;
- el->el_chared.c_kill.last = kp;
+ for (p = el->el_line.cursor, kp = el->el_chared.c_kill.buf; p < cp; p++)
+ /* save the text */
+ *kp++ = *p;
+ el->el_chared.c_kill.last = kp;
- c_delafter(el, cp - el->el_line.cursor); /* delete after dot */
- if (el->el_line.cursor > el->el_line.lastchar)
- el->el_line.cursor = el->el_line.lastchar; /* bounds check */
- return CC_REFRESH;
+ c_delafter(el, cp - el->el_line.cursor); /* delete after dot */
+ if (el->el_line.cursor > el->el_line.lastchar)
+ el->el_line.cursor = el->el_line.lastchar;
+ /* bounds check */
+ return (CC_REFRESH);
}
@@ -114,34 +116,34 @@ em_delete_next_word(el, c)
*/
protected el_action_t
/*ARGSUSED*/
-em_yank(el, c)
- EditLine *el;
- int c;
+em_yank(EditLine *el, int c __attribute__((__unused__)))
{
- char *kp, *cp;
+ char *kp, *cp;
- if (el->el_chared.c_kill.last == el->el_chared.c_kill.buf)
- return CC_ERROR;
+ if (el->el_chared.c_kill.last == el->el_chared.c_kill.buf) {
+ if (!ch_enlargebufs(el, 1))
+ return (CC_ERROR);
+ }
- if (el->el_line.lastchar +
- (el->el_chared.c_kill.last - el->el_chared.c_kill.buf) >=
- el->el_line.limit)
- return CC_ERROR;
+ if (el->el_line.lastchar +
+ (el->el_chared.c_kill.last - el->el_chared.c_kill.buf) >=
+ el->el_line.limit)
+ return (CC_ERROR);
- el->el_chared.c_kill.mark = el->el_line.cursor;
- cp = el->el_line.cursor;
+ el->el_chared.c_kill.mark = el->el_line.cursor;
+ cp = el->el_line.cursor;
- /* open the space, */
- c_insert(el, el->el_chared.c_kill.last - el->el_chared.c_kill.buf);
- /* copy the chars */
- for (kp = el->el_chared.c_kill.buf; kp < el->el_chared.c_kill.last; kp++)
- *cp++ = *kp;
+ /* open the space, */
+ c_insert(el, el->el_chared.c_kill.last - el->el_chared.c_kill.buf);
+ /* copy the chars */
+ for (kp = el->el_chared.c_kill.buf; kp < el->el_chared.c_kill.last; kp++)
+ *cp++ = *kp;
- /* if an arg, cursor at beginning else cursor at end */
- if (el->el_state.argument == 1)
- el->el_line.cursor = cp;
+ /* if an arg, cursor at beginning else cursor at end */
+ if (el->el_state.argument == 1)
+ el->el_line.cursor = cp;
- return CC_REFRESH;
+ return (CC_REFRESH);
}
@@ -151,20 +153,19 @@ em_yank(el, c)
*/
protected el_action_t
/*ARGSUSED*/
-em_kill_line(el, c)
- EditLine *el;
- int c;
+em_kill_line(EditLine *el, int c __attribute__((__unused__)))
{
- char *kp, *cp;
-
- cp = el->el_line.buffer;
- kp = el->el_chared.c_kill.buf;
- while (cp < el->el_line.lastchar)
- *kp++ = *cp++; /* copy it */
- el->el_chared.c_kill.last = kp;
- el->el_line.lastchar = el->el_line.buffer; /* zap! -- delete all of it */
- el->el_line.cursor = el->el_line.buffer;
- return CC_REFRESH;
+ char *kp, *cp;
+
+ cp = el->el_line.buffer;
+ kp = el->el_chared.c_kill.buf;
+ while (cp < el->el_line.lastchar)
+ *kp++ = *cp++; /* copy it */
+ el->el_chared.c_kill.last = kp;
+ /* zap! -- delete all of it */
+ el->el_line.lastchar = el->el_line.buffer;
+ el->el_line.cursor = el->el_line.buffer;
+ return (CC_REFRESH);
}
@@ -174,33 +175,30 @@ em_kill_line(el, c)
*/
protected el_action_t
/*ARGSUSED*/
-em_kill_region(el, c)
- EditLine *el;
- int c;
+em_kill_region(EditLine *el, int c __attribute__((__unused__)))
{
- char *kp, *cp;
-
- if (!el->el_chared.c_kill.mark)
- return CC_ERROR;
-
- if (el->el_chared.c_kill.mark > el->el_line.cursor) {
- cp = el->el_line.cursor;
- kp = el->el_chared.c_kill.buf;
- while (cp < el->el_chared.c_kill.mark)
- *kp++ = *cp++; /* copy it */
- el->el_chared.c_kill.last = kp;
- c_delafter(el, cp - el->el_line.cursor);
- }
- else { /* mark is before cursor */
- cp = el->el_chared.c_kill.mark;
- kp = el->el_chared.c_kill.buf;
- while (cp < el->el_line.cursor)
- *kp++ = *cp++; /* copy it */
- el->el_chared.c_kill.last = kp;
- c_delbefore(el, cp - el->el_chared.c_kill.mark);
- el->el_line.cursor = el->el_chared.c_kill.mark;
- }
- return CC_REFRESH;
+ char *kp, *cp;
+
+ if (!el->el_chared.c_kill.mark)
+ return (CC_ERROR);
+
+ if (el->el_chared.c_kill.mark > el->el_line.cursor) {
+ cp = el->el_line.cursor;
+ kp = el->el_chared.c_kill.buf;
+ while (cp < el->el_chared.c_kill.mark)
+ *kp++ = *cp++; /* copy it */
+ el->el_chared.c_kill.last = kp;
+ c_delafter(el, cp - el->el_line.cursor);
+ } else { /* mark is before cursor */
+ cp = el->el_chared.c_kill.mark;
+ kp = el->el_chared.c_kill.buf;
+ while (cp < el->el_line.cursor)
+ *kp++ = *cp++; /* copy it */
+ el->el_chared.c_kill.last = kp;
+ c_delbefore(el, cp - el->el_chared.c_kill.mark);
+ el->el_line.cursor = el->el_chared.c_kill.mark;
+ }
+ return (CC_REFRESH);
}
@@ -210,52 +208,46 @@ em_kill_region(el, c)
*/
protected el_action_t
/*ARGSUSED*/
-em_copy_region(el, c)
- EditLine *el;
- int c;
+em_copy_region(EditLine *el, int c __attribute__((__unused__)))
{
- char *kp, *cp;
-
- if (el->el_chared.c_kill.mark)
- return CC_ERROR;
-
- if (el->el_chared.c_kill.mark > el->el_line.cursor) {
- cp = el->el_line.cursor;
- kp = el->el_chared.c_kill.buf;
- while (cp < el->el_chared.c_kill.mark)
- *kp++ = *cp++; /* copy it */
- el->el_chared.c_kill.last = kp;
- }
- else {
- cp = el->el_chared.c_kill.mark;
- kp = el->el_chared.c_kill.buf;
- while (cp < el->el_line.cursor)
- *kp++ = *cp++; /* copy it */
- el->el_chared.c_kill.last = kp;
- }
- return CC_NORM;
+ char *kp, *cp;
+
+ if (!el->el_chared.c_kill.mark)
+ return (CC_ERROR);
+
+ if (el->el_chared.c_kill.mark > el->el_line.cursor) {
+ cp = el->el_line.cursor;
+ kp = el->el_chared.c_kill.buf;
+ while (cp < el->el_chared.c_kill.mark)
+ *kp++ = *cp++; /* copy it */
+ el->el_chared.c_kill.last = kp;
+ } else {
+ cp = el->el_chared.c_kill.mark;
+ kp = el->el_chared.c_kill.buf;
+ while (cp < el->el_line.cursor)
+ *kp++ = *cp++; /* copy it */
+ el->el_chared.c_kill.last = kp;
+ }
+ return (CC_NORM);
}
-/* em_gosmacs_traspose():
+/* em_gosmacs_transpose():
* Exchange the two characters before the cursor
* Gosling emacs transpose chars [^T]
*/
protected el_action_t
-em_gosmacs_traspose(el, c)
- EditLine *el;
- int c;
+em_gosmacs_transpose(EditLine *el, int c)
{
- if (el->el_line.cursor > &el->el_line.buffer[1]) {
- /* must have at least two chars entered */
- c = el->el_line.cursor[-2];
- el->el_line.cursor[-2] = el->el_line.cursor[-1];
- el->el_line.cursor[-1] = c;
- return CC_REFRESH;
- }
- else
- return CC_ERROR;
+ if (el->el_line.cursor > &el->el_line.buffer[1]) {
+ /* must have at least two chars entered */
+ c = el->el_line.cursor[-2];
+ el->el_line.cursor[-2] = el->el_line.cursor[-1];
+ el->el_line.cursor[-1] = c;
+ return (CC_REFRESH);
+ } else
+ return (CC_ERROR);
}
@@ -265,49 +257,46 @@ em_gosmacs_traspose(el, c)
*/
protected el_action_t
/*ARGSUSED*/
-em_next_word(el, c)
- EditLine *el;
- int c;
+em_next_word(EditLine *el, int c __attribute__((__unused__)))
{
- if (el->el_line.cursor == el->el_line.lastchar)
- return CC_ERROR;
-
- el->el_line.cursor = c__next_word(el->el_line.cursor, el->el_line.lastchar,
- el->el_state.argument,
- ce__isword);
-
- if (el->el_map.type == MAP_VI)
- if (el->el_chared.c_vcmd.action & DELETE) {
- cv_delfini(el);
- return CC_REFRESH;
- }
-
- return CC_CURSOR;
+ if (el->el_line.cursor == el->el_line.lastchar)
+ return (CC_ERROR);
+
+ el->el_line.cursor = c__next_word(el->el_line.cursor,
+ el->el_line.lastchar,
+ el->el_state.argument,
+ ce__isword);
+
+ if (el->el_map.type == MAP_VI)
+ if (el->el_chared.c_vcmd.action != NOP) {
+ cv_delfini(el);
+ return (CC_REFRESH);
+ }
+ return (CC_CURSOR);
}
+
/* em_upper_case():
* Uppercase the characters from cursor to end of current word
* [M-u]
*/
protected el_action_t
/*ARGSUSED*/
-em_upper_case(el, c)
- EditLine *el;
- int c;
+em_upper_case(EditLine *el, int c __attribute__((__unused__)))
{
- char *cp, *ep;
+ char *cp, *ep;
- ep = c__next_word(el->el_line.cursor, el->el_line.lastchar,
- el->el_state.argument, ce__isword);
+ ep = c__next_word(el->el_line.cursor, el->el_line.lastchar,
+ el->el_state.argument, ce__isword);
- for (cp = el->el_line.cursor; cp < ep; cp++)
- if (islower(*cp))
- *cp = toupper(*cp);
+ for (cp = el->el_line.cursor; cp < ep; cp++)
+ if (islower((unsigned char) *cp))
+ *cp = toupper(*cp);
- el->el_line.cursor = ep;
- if (el->el_line.cursor > el->el_line.lastchar)
- el->el_line.cursor = el->el_line.lastchar;
- return CC_REFRESH;
+ el->el_line.cursor = ep;
+ if (el->el_line.cursor > el->el_line.lastchar)
+ el->el_line.cursor = el->el_line.lastchar;
+ return (CC_REFRESH);
}
@@ -317,56 +306,53 @@ em_upper_case(el, c)
*/
protected el_action_t
/*ARGSUSED*/
-em_capitol_case(el, c)
- EditLine *el;
- int c;
+em_capitol_case(EditLine *el, int c __attribute__((__unused__)))
{
- char *cp, *ep;
-
- ep = c__next_word(el->el_line.cursor, el->el_line.lastchar,
- el->el_state.argument, ce__isword);
-
- for (cp = el->el_line.cursor; cp < ep; cp++) {
- if (isalpha(*cp)) {
- if (islower(*cp))
- *cp = toupper(*cp);
- cp++;
- break;
+ char *cp, *ep;
+
+ ep = c__next_word(el->el_line.cursor, el->el_line.lastchar,
+ el->el_state.argument, ce__isword);
+
+ for (cp = el->el_line.cursor; cp < ep; cp++) {
+ if (isalpha((unsigned char) *cp)) {
+ if (islower((unsigned char) *cp))
+ *cp = toupper(*cp);
+ cp++;
+ break;
+ }
}
- }
- for (; cp < ep; cp++)
- if (isupper(*cp))
- *cp = tolower(*cp);
-
- el->el_line.cursor = ep;
- if (el->el_line.cursor > el->el_line.lastchar)
- el->el_line.cursor = el->el_line.lastchar;
- return CC_REFRESH;
+ for (; cp < ep; cp++)
+ if (isupper((unsigned char) *cp))
+ *cp = tolower(*cp);
+
+ el->el_line.cursor = ep;
+ if (el->el_line.cursor > el->el_line.lastchar)
+ el->el_line.cursor = el->el_line.lastchar;
+ return (CC_REFRESH);
}
+
/* em_lower_case():
* Lowercase the characters from cursor to end of current word
* [M-l]
*/
protected el_action_t
/*ARGSUSED*/
-em_lower_case(el, c)
- EditLine *el;
- int c;
+em_lower_case(EditLine *el, int c __attribute__((__unused__)))
{
- char *cp, *ep;
+ char *cp, *ep;
- ep = c__next_word(el->el_line.cursor, el->el_line.lastchar,
- el->el_state.argument, ce__isword);
+ ep = c__next_word(el->el_line.cursor, el->el_line.lastchar,
+ el->el_state.argument, ce__isword);
- for (cp = el->el_line.cursor; cp < ep; cp++)
- if (isupper(*cp))
- *cp = tolower(*cp);
+ for (cp = el->el_line.cursor; cp < ep; cp++)
+ if (isupper((unsigned char) *cp))
+ *cp = tolower(*cp);
- el->el_line.cursor = ep;
- if (el->el_line.cursor > el->el_line.lastchar)
- el->el_line.cursor = el->el_line.lastchar;
- return CC_REFRESH;
+ el->el_line.cursor = ep;
+ if (el->el_line.cursor > el->el_line.lastchar)
+ el->el_line.cursor = el->el_line.lastchar;
+ return (CC_REFRESH);
}
@@ -376,62 +362,59 @@ em_lower_case(el, c)
*/
protected el_action_t
/*ARGSUSED*/
-em_set_mark(el, c)
- EditLine *el;
- int c;
+em_set_mark(EditLine *el, int c __attribute__((__unused__)))
{
- el->el_chared.c_kill.mark = el->el_line.cursor;
- return CC_NORM;
+
+ el->el_chared.c_kill.mark = el->el_line.cursor;
+ return (CC_NORM);
}
/* em_exchange_mark():
- * Exchange the cursor and mark
+ * Exchange the cursor and mark
* [^X^X]
*/
protected el_action_t
/*ARGSUSED*/
-em_exchange_mark(el, c)
- EditLine *el;
- int c;
+em_exchange_mark(EditLine *el, int c __attribute__((__unused__)))
{
- register char *cp;
+ char *cp;
- cp = el->el_line.cursor;
- el->el_line.cursor = el->el_chared.c_kill.mark;
- el->el_chared.c_kill.mark = cp;
- return CC_CURSOR;
+ cp = el->el_line.cursor;
+ el->el_line.cursor = el->el_chared.c_kill.mark;
+ el->el_chared.c_kill.mark = cp;
+ return (CC_CURSOR);
}
+
/* em_universal_argument():
* Universal argument (argument times 4)
* [^U]
*/
protected el_action_t
/*ARGSUSED*/
-em_universal_argument(el, c)
- EditLine *el;
- int c;
+em_universal_argument(EditLine *el, int c __attribute__((__unused__)))
{ /* multiply current argument by 4 */
- if (el->el_state.argument > 1000000)
- return CC_ERROR;
- el->el_state.doingarg = 1;
- el->el_state.argument *= 4;
- return CC_ARGHACK;
+
+ if (el->el_state.argument > 1000000)
+ return (CC_ERROR);
+ el->el_state.doingarg = 1;
+ el->el_state.argument *= 4;
+ return (CC_ARGHACK);
}
+
/* em_meta_next():
* Add 8th bit to next character typed
* [<ESC>]
*/
protected el_action_t
/*ARGSUSED*/
-em_meta_next(el, c)
- EditLine *el;
- int c;
+em_meta_next(EditLine *el, int c __attribute__((__unused__)))
{
- el->el_state.metanext = 1;
- return CC_ARGHACK;
+
+ el->el_state.metanext = 1;
+ return (CC_ARGHACK);
}
@@ -440,13 +423,12 @@ em_meta_next(el, c)
*/
protected el_action_t
/*ARGSUSED*/
-em_toggle_overwrite(el, c)
- EditLine *el;
- int c;
+em_toggle_overwrite(EditLine *el, int c __attribute__((__unused__)))
{
- el->el_state.inputmode =
- (el->el_state.inputmode == MODE_INSERT) ? MODE_REPLACE : MODE_INSERT;
- return CC_NORM;
+
+ el->el_state.inputmode = (el->el_state.inputmode == MODE_INSERT) ?
+ MODE_REPLACE : MODE_INSERT;
+ return (CC_NORM);
}
@@ -455,27 +437,25 @@ em_toggle_overwrite(el, c)
*/
protected el_action_t
/*ARGSUSED*/
-em_copy_prev_word(el, c)
- EditLine *el;
- int c;
+em_copy_prev_word(EditLine *el, int c __attribute__((__unused__)))
{
- char *cp, *oldc, *dp;
+ char *cp, *oldc, *dp;
- if (el->el_line.cursor == el->el_line.buffer)
- return CC_ERROR;
+ if (el->el_line.cursor == el->el_line.buffer)
+ return (CC_ERROR);
- oldc = el->el_line.cursor;
- /* does a bounds check */
- cp = c__prev_word(el->el_line.cursor, el->el_line.buffer,
- el->el_state.argument, ce__isword);
+ oldc = el->el_line.cursor;
+ /* does a bounds check */
+ cp = c__prev_word(el->el_line.cursor, el->el_line.buffer,
+ el->el_state.argument, ce__isword);
- c_insert(el, oldc - cp);
- for (dp = oldc; cp < oldc && dp < el->el_line.lastchar; cp++)
- *dp++ = *cp;
+ c_insert(el, oldc - cp);
+ for (dp = oldc; cp < oldc && dp < el->el_line.lastchar; cp++)
+ *dp++ = *cp;
- el->el_line.cursor = dp; /* put cursor at end */
+ el->el_line.cursor = dp;/* put cursor at end */
- return CC_REFRESH;
+ return (CC_REFRESH);
}
@@ -484,12 +464,11 @@ em_copy_prev_word(el, c)
*/
protected el_action_t
/*ARGSUSED*/
-em_inc_search_next(el, c)
- EditLine *el;
- int c;
+em_inc_search_next(EditLine *el, int c __attribute__((__unused__)))
{
- el->el_search.patlen = 0;
- return ce_inc_search(el, ED_SEARCH_NEXT_HISTORY);
+
+ el->el_search.patlen = 0;
+ return (ce_inc_search(el, ED_SEARCH_NEXT_HISTORY));
}
@@ -498,10 +477,9 @@ em_inc_search_next(el, c)
*/
protected el_action_t
/*ARGSUSED*/
-em_inc_search_prev(el, c)
- EditLine *el;
- int c;
+em_inc_search_prev(EditLine *el, int c __attribute__((__unused__)))
{
- el->el_search.patlen = 0;
- return ce_inc_search(el, ED_SEARCH_PREV_HISTORY);
+
+ el->el_search.patlen = 0;
+ return (ce_inc_search(el, ED_SEARCH_PREV_HISTORY));
}