From ba65cd48cccf7b98969f0ff00fe8ba06e78e9b37 Mon Sep 17 00:00:00 2001
From: Benno Schulenberg <bensberg@telfort.nl>
Date: Sun, 24 Sep 2017 20:49:35 +0200
Subject: [PATCH] bindings: make ^Q and ^S do something useful by default

^S will be the first thing people will try for saving a file,
and ^Q is somewhat mnemonic because it is to the left of ^W:
it searches backward.

Make these keystrokes available also in the tiny version.
---
 doc/sample.nanorc.in |  5 ++---
 src/files.c          |  2 --
 src/global.c         |  5 ++---
 src/nano.c           | 11 -----------
 src/proto.h          |  4 ----
 5 files changed, 4 insertions(+), 23 deletions(-)

diff --git a/doc/sample.nanorc.in b/doc/sample.nanorc.in
index 725e1bfc..9b3355a8 100644
--- a/doc/sample.nanorc.in
+++ b/doc/sample.nanorc.in
@@ -269,9 +269,8 @@
 ## Key bindings.
 ## See nanorc(5) (section REBINDING KEYS) for more details on this.
 ##
-## 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
+## The following two functions are not bound to any key by default.
+## You may wish to choose other keys than the ones suggested here.
 # bind M-B cutwordleft main
 # bind M-N cutwordright main
 
diff --git a/src/files.c b/src/files.c
index 53855bfc..0643e3d7 100644
--- a/src/files.c
+++ b/src/files.c
@@ -2272,14 +2272,12 @@ void do_writeout_void(void)
 	close_and_go();
 }
 
-#ifndef NANO_TINY
 /* If it has a name, write the current file to disk without prompting. */
 void do_savefile(void)
 {
     if (do_writeout(FALSE, FALSE) == 2)
 	close_and_go();
 }
-#endif
 
 /* Return a malloc()ed string containing the actual directory, used to
  * convert ~user/ and ~/ notation. */
diff --git a/src/global.c b/src/global.c
index 2926403b..4b5cd5c3 100644
--- a/src/global.c
+++ b/src/global.c
@@ -1079,11 +1079,13 @@ void shortcut_init(void)
     add_to_sclist(MMOST & ~MFINDINHELP, "F1", 0, do_help_void, 0);
     add_to_sclist(MMAIN|MHELP|MBROWSER, "^X", 0, do_exit, 0);
     add_to_sclist(MMAIN|MHELP|MBROWSER, "F2", 0, do_exit, 0);
+    add_to_sclist(MMAIN, "^S", 0, do_savefile, 0);
     add_to_sclist(MMAIN, "^O", 0, do_writeout_void, 0);
     add_to_sclist(MMAIN, "F3", 0, do_writeout_void, 0);
     add_to_sclist(MMAIN, "^R", 0, do_insertfile_void, 0);
     add_to_sclist(MMAIN, "F5", 0, do_insertfile_void, 0);
     add_to_sclist(MMAIN, "Ins", 0, do_insertfile_void, 0);
+    add_to_sclist(MMAIN, "^Q", 0, do_search_backward, 0);
     add_to_sclist(MMAIN|MHELP|MBROWSER, "^W", 0, do_search, 0);
     add_to_sclist(MMAIN|MHELP|MBROWSER, "F6", 0, do_search, 0);
     add_to_sclist(MMAIN, "^\\", 0, do_replace, 0);
@@ -1258,9 +1260,6 @@ void shortcut_init(void)
     add_to_sclist(MMAIN, "M-Z", 0, do_toggle_void, SUSPEND);
 #endif /* !NANO_TINY */
 
-    add_to_sclist(MMAIN, "^Q", 0, xon_complaint, 0);
-    add_to_sclist(MMAIN, "^S", 0, xoff_complaint, 0);
-
     add_to_sclist(((MMOST & ~MMAIN & ~MBROWSER) | MYESNO), "^C", 0, do_cancel, 0);
 
     add_to_sclist(MWHEREIS|MREPLACE, "M-C", 0, case_sens_void, 0);
diff --git a/src/nano.c b/src/nano.c
index aa2faee6..86ce037c 100644
--- a/src/nano.c
+++ b/src/nano.c
@@ -1731,17 +1731,6 @@ int do_input(bool allow_funcs)
     return input;
 }
 
-void xon_complaint(void)
-{
-    statusbar(_("XON ignored, mumble mumble"));
-}
-
-void xoff_complaint(void)
-{
-    statusbar(_("XOFF ignored, mumble mumble"));
-}
-
-
 #ifdef ENABLE_MOUSE
 /* Handle a mouse click on the edit window or the shortcut list. */
 int do_mouse(void)
diff --git a/src/proto.h b/src/proto.h
index 233032bd..617a2da3 100644
--- a/src/proto.h
+++ b/src/proto.h
@@ -309,9 +309,7 @@ bool write_marked_file(const char *name, FILE *f_open, bool tmp,
 #endif
 int do_writeout(bool exiting, bool withprompt);
 void do_writeout_void(void);
-#ifndef NANO_TINY
 void do_savefile(void);
-#endif
 char *real_dir_from_tilde(const char *buf);
 #if defined(ENABLE_TABCOMP) || defined(ENABLE_BROWSER)
 int diralphasort(const void *va, const void *vb);
@@ -691,8 +689,6 @@ void spotlight(bool active, size_t from_col, size_t to_col);
 #ifndef NANO_TINY
 void spotlight_softwrapped(bool active, size_t from_col, size_t to_col);
 #endif
-void xon_complaint(void);
-void xoff_complaint(void);
 void do_suspend_void(void);
 void disable_waiting(void);
 void enable_waiting(void);
-- 
GitLab