nano

nano with my custom patches
git clone git://bsandro.tech/nano
Log | Files | Refs | README | LICENSE

commit 40b03162c3f6fc62217f718301597050af599aff
parent 34f4ceb77e1956add894df260b39c5de217852f0
Author: Benno Schulenberg <bensberg@telfort.nl>
Date:   Mon,  6 Jul 2020 10:54:50 +0200

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>

Diffstat:
Msrc/global.c | 1+
Msrc/winio.c | 11++++++++---
2 files changed, 9 insertions(+), 3 deletions(-)

diff --git a/src/global.c b/src/global.c @@ -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); diff --git a/src/winio.c b/src/winio.c @@ -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 != '[')) {