diff --git a/ChangeLog b/ChangeLog index 4a898b292fb252a380d56eb2333301394d960829..abcecb0f4f261e5954c32c207ed51cf0b6997624 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,4 +1,9 @@ -2015-06-17 Benno Schulenberg <bensberg@justemail.net> +2015-06-20 Benno Schulenberg <bensberg@justemail.net> + * 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 <n> in vim/less. + +2015-06-18 Benno Schulenberg <bensberg@justemail.net> * 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 e00621d7e02f66e69ea9d3a03ae911d28c366f8f..b2e0807940d8170c391e6b19c01e36ffa9643a32 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! */