2015-07-26 Benno Schulenberg <bensberg@justemail.net>
* src/search.c (do_replace_loop): When doing regex replacements, find
- each zero-length match only once. This fixes Savannah bug #45626.
+ each zero-length match only once. This fixes Savannah bug #45626.
+ * src/global.c (shortcut_init, strtosc), src/search.c (do_findnext,
+ do_findprevious), doc/man/nanorc.5, doc/texinfo/nano.texi: Add two
+ new bindable functions, 'findnext' and 'findprevious', which repeat
+ the last search command in a fixed direction without prompting.
2015-07-25 Benno Schulenberg <bensberg@justemail.net>
* src/global.c (shortcut_init, strtosc), src/files.c (savefile),
a string in the current list in the file browser.
.TP
.B searchagain
-Repeats the last search command.
+Repeats the last search command without prompting.
+.TP
+.B findprevious
+As \fBsearchagain\fR, but always in the backward direction.
+.TP
+.B findnext
+As \fBsearchagain\fR, but always in the forward direction.
.TP
.B replace
Interactively replaces text within the current buffer.
a string in the current list in the file browser
@item searchagain
-Repeats the last search command.
+Repeats the last search command without prompting.
+
+@item findprevious
+As @code{searchagain}, but always in the backward direction.
+
+@item findnext
+As @code{searchagain}, but always in the forward direction.
@item replace
Interactively replaces text within the current buffer.
N_("Suspend the editor (if suspend is enabled)");
#ifndef NANO_TINY
const char *nano_savefile_msg = N_("Save file without prompting");
+ const char *nano_findprev_msg = N_("Search next occurrence backward");
+ const char *nano_findnext_msg = N_("Search next occurrence forward");
const char *nano_case_msg =
N_("Toggle the case sensitivity of the search");
const char *nano_reverse_msg =
#ifndef NANO_TINY
add_to_funcs(do_savefile, MMAIN,
N_("Save"), IFSCHELP(nano_savefile_msg), BLANKAFTER, NOVIEW);
+
+ add_to_funcs(do_findprevious, MMAIN,
+ N_("Previous"), IFSCHELP(nano_findprev_msg), TOGETHER, VIEW);
+ add_to_funcs(do_findnext, MMAIN,
+ N_("Next"), IFSCHELP(nano_findnext_msg), BLANKAFTER, VIEW);
#endif
#ifndef DISABLE_HISTORIES
else if (!strcasecmp(input, "searchagain") ||
!strcasecmp(input, "research"))
s->scfunc = do_research;
+ else if (!strcasecmp(input, "findprevious"))
+ s->scfunc = do_findprevious;
+ else if (!strcasecmp(input, "findnext"))
+ s->scfunc = do_findnext;
#endif
else if (!strcasecmp(input, "replace"))
s->scfunc = do_replace;
const char *needle, size_t *needle_len);
void findnextstr_wrap_reset(void);
void do_search(void);
+#ifndef NANO_TINY
+void do_findprevious(void);
+void do_findnext(void);
+#endif
#if !defined(NANO_TINY) || !defined(DISABLE_BROWSER)
void do_research(void);
#endif
search_replace_abort();
}
+#ifndef NANO_TINY
+/* Search in the backward direction for the next occurrence. */
+void do_findprevious(void)
+{
+ if ISSET(BACKWARDS_SEARCH)
+ do_research();
+ else {
+ SET(BACKWARDS_SEARCH);
+ do_research();
+ UNSET(BACKWARDS_SEARCH);
+ }
+}
+
+/* Search in the forward direction for the next occurrence. */
+void do_findnext(void)
+{
+ if ISSET(BACKWARDS_SEARCH) {
+ UNSET(BACKWARDS_SEARCH);
+ do_research();
+ SET(BACKWARDS_SEARCH);
+ } else
+ do_research();
+}
+#endif
+
#if !defined(NANO_TINY) || !defined(DISABLE_BROWSER)
/* Search for the last string without prompting. */
void do_research(void)