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.
This commit is contained in:
Benno Schulenberg
2026-07-07 16:51:24 +02:00
parent 9797150ffd
commit fde24946da
3 changed files with 14 additions and 0 deletions

View File

@@ -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);

View File

@@ -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);

View File

@@ -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"));