From a26769944018dcb9b31e2c5733942b2ec79e330d Mon Sep 17 00:00:00 2001 From: Benno Schulenberg Date: Sat, 20 Jun 2015 08:10:25 +0000 Subject: [PATCH] Making M-W work also right after startup. git-svn-id: svn://svn.savannah.gnu.org/nano/trunk/nano@5258 35c25a1d-7b9e-4130-9fde-d3aeb78583b8 --- ChangeLog | 7 ++++++- src/search.c | 7 +++++++ 2 files changed, 13 insertions(+), 1 deletion(-) diff --git a/ChangeLog b/ChangeLog index 4a898b29..abcecb0f 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,4 +1,9 @@ -2015-06-17 Benno Schulenberg +2015-06-20 Benno Schulenberg + * src/search.c (do_research): If nothing was searched for yet during + this run of nano, take the most recent item from the search history. + This makes M-W work also right after startup, like in vim/less. + +2015-06-18 Benno Schulenberg * src/rcfile.c: Allow a tiny nano's ~/.nanorc to enable search and position histories. Also sort the options more strictly. * src/nano.h: Delete two unused things, and add two comments. diff --git a/src/search.c b/src/search.c index e00621d7..b2e08079 100644 --- a/src/search.c +++ b/src/search.c @@ -485,6 +485,13 @@ void do_research(void) focusing = TRUE; +#ifndef DISABLE_HISTORIES + /* If nothing was searched for yet during this run of nano, but + * there is a search history, take the most recent item. */ + if (last_search[0] == '\0' && searchbot->prev != NULL) + last_search = mallocstrcpy(last_search, searchbot->prev->data); +#endif + if (last_search[0] != '\0') { #ifdef HAVE_REGEX_H /* Since answer is "", use last_search! */ -- 2.39.5