From mboxrd@z Thu Jan 1 00:00:00 1970 Path: news.gmane.org!not-for-mail From: Duncan Burke Newsgroups: gmane.emacs.bugs Subject: bug#22743: 25.0.91: set-quit-char does not work if emacs lacks a controlling tty Date: Sat, 20 Feb 2016 16:31:54 +1100 Message-ID: <56C7FA4A.1030605@gmail.com> NNTP-Posting-Host: plane.gmane.org Mime-Version: 1.0 Content-Type: multipart/mixed; boundary="------------070205020301080304000601" X-Trace: ger.gmane.org 1455951504 25433 80.91.229.3 (20 Feb 2016 06:58:24 GMT) X-Complaints-To: usenet@ger.gmane.org NNTP-Posting-Date: Sat, 20 Feb 2016 06:58:24 +0000 (UTC) To: 22743@debbugs.gnu.org Original-X-From: bug-gnu-emacs-bounces+geb-bug-gnu-emacs=m.gmane.org@gnu.org Sat Feb 20 07:58:13 2016 Return-path: Envelope-to: geb-bug-gnu-emacs@m.gmane.org Original-Received: from lists.gnu.org ([208.118.235.17]) by plane.gmane.org with esmtp (Exim 4.69) (envelope-from ) id 1aX1Ua-0002mi-Ny for geb-bug-gnu-emacs@m.gmane.org; Sat, 20 Feb 2016 07:58:12 +0100 Original-Received: from localhost ([::1]:58705 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1aX1UZ-0006Y2-HI for geb-bug-gnu-emacs@m.gmane.org; Sat, 20 Feb 2016 01:58:11 -0500 Original-Received: from eggs.gnu.org ([2001:4830:134:3::10]:41559) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1aX1UU-0006Xl-U8 for bug-gnu-emacs@gnu.org; Sat, 20 Feb 2016 01:58:08 -0500 Original-Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1aX1UQ-0006sU-SU for bug-gnu-emacs@gnu.org; Sat, 20 Feb 2016 01:58:06 -0500 Original-Received: from debbugs.gnu.org ([208.118.235.43]:37348) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1aX1UQ-0006sP-NT for bug-gnu-emacs@gnu.org; Sat, 20 Feb 2016 01:58:02 -0500 Original-Received: from Debian-debbugs by debbugs.gnu.org with local (Exim 4.84) (envelope-from ) id 1aX1UQ-0008DW-Hm for bug-gnu-emacs@gnu.org; Sat, 20 Feb 2016 01:58:02 -0500 X-Loop: help-debbugs@gnu.org Resent-From: Duncan Burke Original-Sender: "Debbugs-submit" Resent-CC: bug-gnu-emacs@gnu.org Resent-Date: Sat, 20 Feb 2016 06:58:02 +0000 Resent-Message-ID: Resent-Sender: help-debbugs@gnu.org X-GNU-PR-Message: report 22743 X-GNU-PR-Package: emacs X-GNU-PR-Keywords: X-Debbugs-Original-To: bug-gnu-emacs@gnu.org Original-Received: via spool by submit@debbugs.gnu.org id=B.145595145231541 (code B ref -1); Sat, 20 Feb 2016 06:58:02 +0000 Original-Received: (at submit) by debbugs.gnu.org; 20 Feb 2016 06:57:32 +0000 Original-Received: from localhost ([127.0.0.1]:34473 helo=debbugs.gnu.org) by debbugs.gnu.org with esmtp (Exim 4.84) (envelope-from ) id 1aX1Tv-0008Cd-Or for submit@debbugs.gnu.org; Sat, 20 Feb 2016 01:57:32 -0500 Original-Received: from eggs.gnu.org ([208.118.235.92]:37496) by debbugs.gnu.org with esmtp (Exim 4.84) (envelope-from ) id 1aX09M-000656-CU for submit@debbugs.gnu.org; Sat, 20 Feb 2016 00:32:12 -0500 Original-Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1aX09F-00062i-Uk for submit@debbugs.gnu.org; Sat, 20 Feb 2016 00:32:07 -0500 Original-Received: from lists.gnu.org ([2001:4830:134:3::11]:41148) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1aX09F-00062e-SC for submit@debbugs.gnu.org; Sat, 20 Feb 2016 00:32:05 -0500 Original-Received: from eggs.gnu.org ([2001:4830:134:3::10]:56691) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1aX09E-0002MG-Oq for bug-gnu-emacs@gnu.org; Sat, 20 Feb 2016 00:32:05 -0500 Original-Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1aX099-00061l-Q7 for bug-gnu-emacs@gnu.org; Sat, 20 Feb 2016 00:32:04 -0500 Original-Received: from mail-pa0-x22b.google.com ([2607:f8b0:400e:c03::22b]:36424) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1aX099-00061Z-F2 for bug-gnu-emacs@gnu.org; Sat, 20 Feb 2016 00:31:59 -0500 Original-Received: by mail-pa0-x22b.google.com with SMTP id yy13so61414342pab.3 for ; Fri, 19 Feb 2016 21:31:59 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20120113; h=to:from:subject:message-id:date:user-agent:mime-version :content-type; bh=hCr7lnjlBMCRg2I+hlPztmRetg+R+T3pgR2tCd6yXmM=; b=pgSnYhi4GsgkT5BclOJKd6cdh1lAruep65LLeEswsoeSyc3QgJ2JgksDbCTz/7jemf s0rIypy0Rf7qOI8wRppD78FGYvYErsE3wKtv4VNcC/vfwqe4bQaiznh6sJYEAl39r1Bs /WIDYIP3ki2XEvnuE7HQqdQmp95BF6iNP119bp/yOg/lo8CJ29iDnmJQC11EcM5vMsCC nES7FLqDgykGSDLu+F9xOOHKU7t6WsZks/z3gN9sputkS2euVGvjTUn+xfMceZbqHWYd y9Yb0mpp5gJ7TefAB+h0Ekj9TXfzZ9YMr9L08sDtP+ZcomUUhWudrE1lUN1hA0Sj/U3f mxdw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20130820; h=x-gm-message-state:to:from:subject:message-id:date:user-agent :mime-version:content-type; bh=hCr7lnjlBMCRg2I+hlPztmRetg+R+T3pgR2tCd6yXmM=; b=E/8wElh5vQiPWS9Ptcr5d1Zg7fUMAoc+yVlsZ0VOgYWWcIRMqvQeuUjcTjDNMkWoeB V0yae1PBQ+bHqTfjL2V2r1N1yX20q3S2h+B9YMNYMVouZYEaMmacZ3eEOSCtyftz7Dey q+dhbViGEJjayJTYOkagClxiHCmg8/VCZojPWcoT7trqOVaFBPVCw6KGWPUBLsnU6m94 Hmrz5Ynn3ZMZntdHUZXX5yV4PbbGqhzJthLHBRvDoIwWJtBsU3RifE3MM9wo2UKjt6QM eAP1+OhVnd+zzNuoyFlQ2CbVvnB8uwSkEZKW+YNh3Lpy41pCW2UMAZj5eI/LxBjZtuUR xu3g== X-Gm-Message-State: AG10YORecJmZpnywwokZ1Y50/46jIkLssLGQZnHmzjmCvtIEIE8WoX1U+WwJceWcD+YVlQ== X-Received: by 10.66.141.11 with SMTP id rk11mr23601376pab.75.1455946318355; Fri, 19 Feb 2016 21:31:58 -0800 (PST) Original-Received: from betelgeuse.dkb.id.au (c122-106-239-94.belrs3.nsw.optusnet.com.au. [122.106.239.94]) by smtp.gmail.com with ESMTPSA id 195sm21479648pfa.5.2016.02.19.21.31.56 for (version=TLSv1/SSLv3 cipher=OTHER); Fri, 19 Feb 2016 21:31:57 -0800 (PST) User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:38.0) Gecko/20100101 Thunderbird/38.6.0 X-detected-operating-system: by eggs.gnu.org: GNU/Linux 2.2.x-3.x [generic] X-detected-operating-system: by eggs.gnu.org: GNU/Linux 2.6.x X-Mailman-Approved-At: Sat, 20 Feb 2016 01:57:31 -0500 X-BeenThere: debbugs-submit@debbugs.gnu.org X-Mailman-Version: 2.1.18 Precedence: list X-detected-operating-system: by eggs.gnu.org: GNU/Linux 2.2.x-3.x [generic] X-Received-From: 208.118.235.43 X-BeenThere: bug-gnu-emacs@gnu.org List-Id: "Bug reports for GNU Emacs, the Swiss army knife of text editors" List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: bug-gnu-emacs-bounces+geb-bug-gnu-emacs=m.gmane.org@gnu.org Original-Sender: bug-gnu-emacs-bounces+geb-bug-gnu-emacs=m.gmane.org@gnu.org Xref: news.gmane.org gmane.emacs.bugs:113331 Archived-At: This is a multi-part message in MIME format. --------------070205020301080304000601 Content-Type: text/plain; charset=utf-8; format=flowed Content-Transfer-Encoding: 7bit I have heavily customised keybindings on a dvorak layout and this necessitates rebinding quit away from its default value of C-g. I have rebound C-g in keymaps where it is already defined (such as global-map, minibuffer-local-map and query-replace-map), and have found this to work in most cases with one major issue in flyspell-mode. flyspell-post-command-hook calls flyspell-check-word-p, which calls sit-for, which ultimately calls read_char in keyboard.c. quit_char in keyboard.c is by default set to ?\C-g and as a consequence in flyspell-mode if C-g is pressed immediately after entering some text a quit is signalled rather than running the command bound to C-g. set-quit-char should be able to change quit_char to my desired value of ?\C-p, however I run emacs in a graphical window and set-quit-char silently does nothing if emacs does not have a controlling tty. To reproduce this issue in emacs 25.0.91.7 with emacs -Q in a graphical window: (define-key global-map [?\C-g] 'backward-delete-char) (define-key global-map [?\C-p] 'keyboard-quit) (set-quit-char ?\C-p) ;; observe that quit_char is unchanged from original value of ?\C-g (current-input-mode) By running flyspell mode, typing something and pressing C-g it can be observed that backward-delete-char is not run as would be expected. I have attached a patch that changes the behaviour of set-quit-char so that quit_char is set even if emacs does not have a controlling tty. --------------070205020301080304000601 Content-Type: text/x-patch; name="0001-Fix-set-quit-char-when-there-s-no-controlling-tty.patch" Content-Transfer-Encoding: 7bit Content-Disposition: attachment; filename*0="0001-Fix-set-quit-char-when-there-s-no-controlling-tty.patch" >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 --------------070205020301080304000601--