>From e33022f19c91012a9f2f158daa9e29cc2fbb79c5 Mon Sep 17 00:00:00 2001 From: Duncan Burke Date: Sat, 20 Feb 2016 00:33:58 +1100 Subject: [PATCH] Fix set-quit-char when there's no controlling tty set-quit-char currently does nothing if get_named_terminal("/dev/tty") is NULL. However it is useful to be able to set quit_char when in a graphical window as this allows it to be bound to something other than C-g in an alternate keybinding setup. This patch allows quit_char to be set when there is no controlling tty. quit_char is masked to 7 bits as the 8th bit is not used for the meta modifier in X. --- src/keyboard.c | 23 ++++++++++++++--------- 1 file changed, 14 insertions(+), 9 deletions(-) diff --git a/src/keyboard.c b/src/keyboard.c index 546c012..f3ce4b1 100644 --- a/src/keyboard.c +++ b/src/keyboard.c @@ -10557,24 +10557,29 @@ See also `current-input-mode'. */) struct terminal *t = get_named_terminal ("/dev/tty"); struct tty_display_info *tty; - if (!t) - return Qnil; - tty = t->display_info.tty; - if (NILP (quit) || !INTEGERP (quit) || XINT (quit) < 0 || XINT (quit) > 0400) error ("QUIT must be an ASCII character"); + if (t) + { + tty = t->display_info.tty; #ifndef DOS_NT - /* this causes startup screen to be restored and messes with the mouse */ - reset_sys_modes (tty); + /* this causes startup screen to be restored and messes with the mouse */ + reset_sys_modes (tty); #endif - /* Don't let this value be out of range. */ - quit_char = XINT (quit) & (tty->meta_key == 0 ? 0177 : 0377); + /* Don't let this value be out of range. */ + quit_char = XINT (quit) & (tty->meta_key == 0 ? 0177 : 0377); #ifndef DOS_NT - init_sys_modes (tty); + init_sys_modes (tty); #endif + } + else + { + /* No associated TTY, accept 7-bit ASCII characters */ + quit_char = XINT (quit) & 0177; + } return Qnil; } -- 2.7.0