me scribbled: > the small patch below > defines a function called 'skip-csi-seq' that skips over the CSI > parameter, intermediate, and final bytes. This is assigned to "\e[". > Since bindings for longer sequences take precedence over shorter ones, > CSI sequences that do have functions bound to them continue to work. > [...] > This is working correctly here, including when adding bindings for > longer keycodes: no more odd characters being inserted when > accidentally hitting the wrong key.
Any interest in this? Perhaps without the default key binding? Andy > --- emacs_keymap.c 2009-01-04 19:32:32.000000000 +0000 > +++ emacs_keymap.c 2009-07-19 08:23:32.796875000 +0100 > @@ -417,7 +417,7 @@ > { ISFUNC, rl_do_lowercase_version }, /* Meta-Z */ > > /* Some more punctuation. */ > - { ISFUNC, (rl_command_func_t *)0x0 }, /* Meta-[ */ /* was > rl_arrow_keys */ > + { ISFUNC, rl_skip_csi_seq }, /* Meta-[ */ /* was > rl_arrow_keys */ > { ISFUNC, rl_delete_horizontal_space }, /* Meta-\ */ > { ISFUNC, (rl_command_func_t *)0x0 }, /* Meta-] */ > { ISFUNC, (rl_command_func_t *)0x0 }, /* Meta-^ */ > --- funmap.c 2009-01-04 19:32:33.000000000 +0000 > +++ funmap.c 2009-07-19 08:25:34.906250000 +0100 > @@ -123,6 +123,7 @@ > { "revert-line", rl_revert_line }, > { "self-insert", rl_insert }, > { "set-mark", rl_set_mark }, > + { "skip-csi-seq", rl_skip_csi_seq }, > { "start-kbd-macro", rl_start_kbd_macro }, > { "tab-insert", rl_tab_insert }, > { "tilde-expand", rl_tilde_expand }, > --- readline.h 2009-07-19 05:28:30.000000000 +0100 > +++ readline.h 2009-07-19 08:23:38.546875000 +0100 > @@ -197,6 +197,7 @@ > /* Miscellaneous bindable commands. */ > extern int rl_abort PARAMS((int, int)); > extern int rl_tty_status PARAMS((int, int)); > +extern int rl_skip_csi_seq PARAMS((int, int)); > > /* Bindable commands for incremental and non-incremental history > searching. */ > extern int rl_history_search_forward PARAMS((int, int)); > --- text.c 2009-01-04 19:32:34.000000000 +0000 > +++ text.c 2009-07-19 08:23:45.890625000 +0100 > @@ -571,6 +571,18 @@ > } > > int > +rl_skip_csi_seq (count, c) > + int count, c; > +{ > + RL_SETSTATE(RL_STATE_MOREINPUT); > + do > + c = rl_read_key (); > + while (c >= 0x20 && c < 0x40); > + RL_UNSETSTATE(RL_STATE_MOREINPUT); > + return 0; > +} > + > +int > rl_arrow_keys (count, c) > int count, c; > {