From 456240150557453f70c76961fc5e5caed9288d5d Mon Sep 17 00:00:00 2001
From: Benno Schulenberg <bensberg@telfort.nl>
Date: Sun, 13 Aug 2017 21:40:02 +0200
Subject: [PATCH] bindings: hard-bind Alt+Up and Alt+Down to findprevious and
 findnext

So that these functions have bindings by default, and easy bindings.
Add them to the help viewer too, so that searching backward becomes
possible there.
---
 doc/sample.nanorc.in | 4 +---
 src/global.c         | 5 +++++
 src/help.c           | 8 ++++++--
 src/winio.c          | 4 ++++
 4 files changed, 16 insertions(+), 5 deletions(-)

diff --git a/doc/sample.nanorc.in b/doc/sample.nanorc.in
index b6eebb15..725e1bfc 100644
--- a/doc/sample.nanorc.in
+++ b/doc/sample.nanorc.in
@@ -269,11 +269,9 @@
 ## Key bindings.
 ## See nanorc(5) (section REBINDING KEYS) for more details on this.
 ##
-## The following five functions are not bound to any key by default.
+## The following three functions are not bound to any key by default.
 ## You may wish to choose different keys than the ones suggested here.
 # bind ^S savefile main
-# bind M-Q findprevious main
-# bind M-W findnext main
 # bind M-B cutwordleft main
 # bind M-N cutwordright main
 
diff --git a/src/global.c b/src/global.c
index 9a8c8f55..c3c9ee57 100644
--- a/src/global.c
+++ b/src/global.c
@@ -1143,6 +1143,11 @@ void shortcut_init(void)
 	add_to_sclist(MMAIN, "M-\xE2\x86\x90", ALT_LEFT, switch_to_prev_buffer_void, 0);
 	add_to_sclist(MMAIN, "M-\xE2\x86\x92", ALT_RIGHT, switch_to_next_buffer_void, 0);
 #endif
+#ifndef NANO_TINY
+	add_to_sclist(MMAIN|MHELP, "M-\xE2\x86\x91", ALT_UP, do_findprevious, 0);
+	add_to_sclist(MMAIN|MHELP, "M-\xE2\x86\x93", ALT_DOWN, do_findnext, 0);
+#endif
+
     } else
 #endif
     {
diff --git a/src/help.c b/src/help.c
index 46aff4e7..05fdb92d 100644
--- a/src/help.c
+++ b/src/help.c
@@ -206,7 +206,10 @@ void do_help(void)
 	} else if (func == do_search) {
 	    do_search();
 	    bottombars(MHELP);
-	} else if (func == do_research) {
+	} else if (func == do_findprevious) {
+	    do_findprevious();
+	    currmenu = MHELP;
+	} else if (func == do_findnext || func == do_research) {
 	    do_research();
 	    currmenu = MHELP;
 #ifndef NANO_TINY
@@ -576,8 +579,9 @@ functionptrtype parse_help_input(int *kbinput)
 	    case '/':
 		return do_search;
 	    case 'N':
+		return do_findprevious;
 	    case 'n':
-		return do_research;
+		return do_findnext;
 	    case 'E':
 	    case 'e':
 	    case 'Q':
diff --git a/src/winio.c b/src/winio.c
index 723868b0..4fbb30a0 100644
--- a/src/winio.c
+++ b/src/winio.c
@@ -527,6 +527,10 @@ int parse_kbinput(WINDOW *win)
 	return ALT_LEFT;
     } else if (retval == altright) {
 	return ALT_RIGHT;
+    } else if (retval == altup) {
+	return ALT_UP;
+    } else if (retval == altdown) {
+	return ALT_DOWN;
     } else if (retval == shiftaltleft) {
 	shift_held = TRUE;
 	return KEY_HOME;
-- 
GitLab