bindings: make <Alt+Backspace> delete a word backwards, like in Bash

It jars a bit that it is <Ctrl+Delete> that deletes a word rightward
and <Alt+Backspace> that deletes a word leftward.  But it's good to
also have a two-key keystroke bound by default to 'chopwordleft',
and not just the three-key <Ctrl+Shift+Delete>.

This fulfills https://savannah.gnu.org/bugs/?58709.
Requested-by: Axel Scheepers <axel.scheepers76+gnu@gmail.com>
This commit is contained in:
Benno Schulenberg 2020-07-06 10:54:50 +02:00
parent 34f4ceb77e
commit 40b03162c3
2 changed files with 9 additions and 3 deletions

View File

@ -1218,6 +1218,7 @@ void shortcut_init(void)
add_to_sclist(MMAIN, "M-;", 0, run_macro, 0);
add_to_sclist(MMAIN, "M-U", 0, do_undo, 0);
add_to_sclist(MMAIN, "M-E", 0, do_redo, 0);
add_to_sclist(MMAIN, "M-Bsp", CONTROL_SHIFT_DELETE, chop_previous_word, 0);
add_to_sclist(MMAIN, "Sh-^Del", CONTROL_SHIFT_DELETE, chop_previous_word, 0);
add_to_sclist(MMAIN, "^Del", CONTROL_DELETE, chop_next_word, 0);
add_to_sclist(MMAIN, "M-Del", ALT_DELETE, zap_text, 0);

View File

@ -935,9 +935,14 @@ int parse_kbinput(WINDOW *win)
retval = keycode;
break;
case 1:
if (keycode >= 0x80)
retval = keycode;
else if (keycode == '\t')
if (keycode >= 0x80) {
#ifndef NANO_TINY
if (keycode == KEY_BACKSPACE)
retval = CONTROL_SHIFT_DELETE;
else
#endif
retval = keycode;
} else if (keycode == '\t')
retval = SHIFT_TAB;
else if (key_buffer_len == 0 || *key_buffer == ESC_CODE ||
(keycode != 'O' && keycode != '[')) {