From 2a30b882161be517ca50e5a2a1ec6d2379047a35 Mon Sep 17 00:00:00 2001 From: Michael Elkins Date: Thu, 10 Oct 2002 09:33:05 +0000 Subject: [PATCH] Jeremy Lin wrote: > When I search with / and get a match, doing '/\r' doesn't move to the next > match. This behavior is unlike the less pager, and is rather useless, IMHO. Try the attached patch. --- pager.c | 35 +++++++++++++++++++++++++++++------ 1 file changed, 29 insertions(+), 6 deletions(-) diff --git a/pager.c b/pager.c index 75f06597b..54f1341cc 100644 --- a/pager.c +++ b/pager.c @@ -1,5 +1,5 @@ /* - * Copyright (C) 1996-2000 Michael R. Elkins + * Copyright (C) 1996-2002 Michael R. Elkins * * This program is free software; you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by @@ -1900,6 +1900,7 @@ mutt_pager (const char *banner, const char *fname, int flags, pager_t *extra) case OP_SEARCH_OPPOSITE: if (SearchCompiled) { +search_next: if ((!SearchBack && ch==OP_SEARCH_NEXT) || (SearchBack &&ch==OP_SEARCH_OPPOSITE)) { @@ -1942,17 +1943,39 @@ mutt_pager (const char *banner, const char *fname, int flags, pager_t *extra) case OP_SEARCH: case OP_SEARCH_REVERSE: + buffer[0] = 0; + if (mutt_get_field ((SearchBack ? _("Reverse search: ") : + _("Search: ")), buffer, sizeof (buffer), + M_CLEAR) != 0) + break; + + if (!buffer[0]) + { + if (SearchCompiled) + { + /* do an implicit search-next */ + if (ch == OP_SEARCH) + ch = OP_SEARCH_NEXT; + else + ch = OP_SEARCH_OPPOSITE; + + goto search_next; + } + /* + * preserve old behavior of doing nothing if there is no last + * used pattern. + */ + break; + } + + strfcpy (searchbuf, buffer, sizeof (searchbuf)); + /* leave SearchBack alone if ch == OP_SEARCH_NEXT */ if (ch == OP_SEARCH) SearchBack = 0; else if (ch == OP_SEARCH_REVERSE) SearchBack = 1; - if (mutt_get_field ((SearchBack ? _("Reverse search: ") : - _("Search: ")), searchbuf, sizeof (searchbuf), - M_CLEAR) != 0 || !searchbuf[0]) - break; - if (SearchCompiled) { regfree (&SearchRE); -- 2.40.0