From fde24946da241d92e975ceaed5aba360da11da6c Mon Sep 17 00:00:00 2001 From: Benno Schulenberg Date: Tue, 7 Jul 2026 16:51:24 +0200 Subject: [PATCH] bindings: add a blind ^T toggle in the WhereIs and GotoLine menus "Blind" meaning that the toggle is not shown in the help lines nor in the help text, and that its function (`flipgoto`) cannot be bound to another keystroke. This addresses https://savannah.gnu.org/bugs/?68503 and https://lists.gnu.org/archive/html/nano-devel/2026-07/msg00006.html. Apparently there are some users who are in the habit of typing ^W^T when they want to jump to a specific line. Avoid frustrating their muscle memory. In other words: handle ^W^T and ^/^T similar to how ^W^Y and ^W^V are handled since commit 8e302738 from seven years ago. --- src/global.c | 3 +++ src/prototypes.h | 1 + src/search.c | 10 ++++++++++ 3 files changed, 14 insertions(+) diff --git a/src/global.c b/src/global.c index 06294f4b..45d9cc25 100644 --- a/src/global.c +++ b/src/global.c @@ -313,6 +313,7 @@ void get_older_item(void) {;} void get_newer_item(void) {;} #endif void flip_replace(void) {;} +void flip_goto(void) {;} #ifdef ENABLE_BROWSER void to_files(void) {;} void goto_dir(void) {;} @@ -1501,6 +1502,8 @@ void shortcut_init(void) add_to_sclist(MWHEREIS|MREPLACE, "M-R", 0, regexp_void, 0); add_to_sclist(MWHEREIS|MREPLACE, "M-B", 0, backwards_void, 0); add_to_sclist(MWHEREIS|MREPLACE, "^R", 0, flip_replace, 0); + /* Add this blind keystroke for long-time users. */ + add_to_sclist(MWHEREIS|MGOTOLINE, "^T", 0, flip_goto, 0); #ifdef ENABLE_HISTORIES add_to_sclist(MWHEREIS|MREPLACE|MREPLACEWITH|MWHEREISFILE|MFINDINHELP|MEXECUTE, "^P", 0, get_older_item, 0); add_to_sclist(MWHEREIS|MREPLACE|MREPLACEWITH|MWHEREISFILE|MFINDINHELP|MEXECUTE, "^N", 0, get_newer_item, 0); diff --git a/src/prototypes.h b/src/prototypes.h index 18cd3eb2..1de24dd4 100644 --- a/src/prototypes.h +++ b/src/prototypes.h @@ -669,6 +669,7 @@ void get_older_item(void); void get_newer_item(void); #endif void flip_replace(void); +void flip_goto(void); #ifdef ENABLE_BROWSER void to_files(void); void goto_dir(void); diff --git a/src/search.c b/src/search.c index 61f81fc3..3b2a974e 100644 --- a/src/search.c +++ b/src/search.c @@ -153,6 +153,9 @@ void search_init(bool replacing, bool retain_answer) napms(600); } else replacing = !replacing; + } else if (function == flip_goto) { + ask_for_line_and_column(answer); + break; } else break; } @@ -778,6 +781,13 @@ void ask_for_line_and_column(char *provided) _("Enter line number, column number")); int doublesign = 0; + /* When switching to Search, retain what the user typed so far. */ + if (func_from_key(response) == flip_goto) { + UNSET(BACKWARDS_SEARCH); + search_init(FALSE, TRUE); + return; + } + /* When cancelled or blank, or when a function was run, we're done. */ if (response < 0) { statusbar(_("Cancelled"));