GNU bug report logs - #22743
25.0.91: set-quit-char does not work if emacs lacks a controlling tty

Previous Next

Package: emacs;

Reported by: Duncan Burke <duncankburke <at> gmail.com>

Date: Sat, 20 Feb 2016 06:58:02 UTC

Severity: wishlist

Found in version 25.0.91

To reply to this bug, email your comments to 22743 AT debbugs.gnu.org.

Toggle the display of automated, internal messages from the tracker.

View this report as an mbox folder, status mbox, maintainer mbox


Report forwarded to bug-gnu-emacs <at> gnu.org:
bug#22743; Package emacs. (Sat, 20 Feb 2016 06:58:02 GMT) Full text and rfc822 format available.

Acknowledgement sent to Duncan Burke <duncankburke <at> gmail.com>:
New bug report received and forwarded. Copy sent to bug-gnu-emacs <at> gnu.org. (Sat, 20 Feb 2016 06:58:02 GMT) Full text and rfc822 format available.

Message #5 received at submit <at> debbugs.gnu.org (full text, mbox):

From: Duncan Burke <duncankburke <at> gmail.com>
To: bug-gnu-emacs <at> gnu.org
Subject: 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 part 1 (text/plain, inline)]
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.
[0001-Fix-set-quit-char-when-there-s-no-controlling-tty.patch (text/x-patch, attachment)]

Information forwarded to bug-gnu-emacs <at> gnu.org:
bug#22743; Package emacs. (Sat, 20 Feb 2016 08:05:02 GMT) Full text and rfc822 format available.

Message #8 received at 22743 <at> debbugs.gnu.org (full text, mbox):

From: John Wiegley <jwiegley <at> gmail.com>
To: Duncan Burke <duncankburke <at> gmail.com>
Cc: 22743 <at> debbugs.gnu.org
Subject: Re: bug#22743: 25.0.91: set-quit-char does not work if emacs lacks a
 controlling tty
Date: Sat, 20 Feb 2016 00:04:01 -0800
>>>>> Duncan Burke <duncankburke <at> gmail.com> writes:

> I have heavily customised keybindings on a dvorak layout and this
> necessitates rebinding quit away from its default value of C-g.

Hi Duncan,

I'm also a Dvorak user of many years; I find C-g to be quite convenient,
actually; why did you need to rebind it?  (I ask mainly out of curiosity).

-- 
John Wiegley                  GPG fingerprint = 4710 CF98 AF9B 327B B80F
http://newartisans.com                          60E1 46C4 BD1A 7AC1 4BA2




Information forwarded to bug-gnu-emacs <at> gnu.org:
bug#22743; Package emacs. (Sat, 20 Feb 2016 09:41:02 GMT) Full text and rfc822 format available.

Message #11 received at 22743 <at> debbugs.gnu.org (full text, mbox):

From: Eli Zaretskii <eliz <at> gnu.org>
To: Duncan Burke <duncankburke <at> gmail.com>
Cc: 22743 <at> debbugs.gnu.org
Subject: Re: bug#22743: 25.0.91: set-quit-char does not work if emacs lacks a
 controlling tty
Date: Sat, 20 Feb 2016 11:40:13 +0200
> From: Duncan Burke <duncankburke <at> gmail.com>
> Date: Sat, 20 Feb 2016 16:31:54 +1100
> 
> 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.

That's documented in the doc string of set-quit-char, so this is by
design.  On a TTY, C-g triggers a signal, and Emacs uses a system API
to change the character which does that.  But on GUI frames, this is
not possible.

> 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.

I don't think this patch will work reliably, because the parts of code
you changed are not the whole picture.  C-g is supported implicitly
and explicitly in many more places.  Grep the Lisp sources for C-g to
see that.

FWIW, my NSHO is that we should deprecate set-quit-char and remove it
in a future Emacs version.  It is no longer reasonable to have a
feature that only works on text terminals.




Information forwarded to bug-gnu-emacs <at> gnu.org:
bug#22743; Package emacs. (Sat, 20 Feb 2016 11:39:01 GMT) Full text and rfc822 format available.

Message #14 received at 22743 <at> debbugs.gnu.org (full text, mbox):

From: Duncan Burke <duncankburke <at> gmail.com>
To: Eli Zaretskii <eliz <at> gnu.org>
Cc: 22743 <at> debbugs.gnu.org
Subject: Re: bug#22743: 25.0.91: set-quit-char does not work if emacs lacks a
 controlling tty
Date: Sat, 20 Feb 2016 22:37:56 +1100
On 20/02/16 20:40, Eli Zaretskii wrote:
> I don't think this patch will work reliably, because the parts of code
> you changed are not the whole picture.  C-g is supported implicitly
> and explicitly in many more places.  Grep the Lisp sources for C-g to
> see that.

I think it should be possible to rebind C-g. If it cannot be rebound, then
that is an exceptional wart which significantly compromises emacs'
configurability.

It is extremely common for lisp code, whether in emacs or an external 
package,
to make assumptions about default bindings. C-g is far from unique in this
respect and while it would be nice if emacs had a way of globally changing
these assumptions, this is an understood cost when one deviates 
significantly
from emacs defaults. I accept that changing something fundamental like this
requires scouring through lisp source and finding all the places this
assumption is made. Anything in lisp can be patched or configured at 
runtime,
so I am not particularly concerned about such issues.

This patch is required because in this specific instance an assumption 
is made
in the C code about the user's intended purpose of C-g, which has an 
effect in
a graphical frame (demonstrated by my example), but that cannot be 
configured
through lisp from a graphical frame.

> That's documented in the doc string of set-quit-char, so this is by
> design.  On a TTY, C-g triggers a signal, and Emacs uses a system API
> to change the character which does that.  But on GUI frames, this is
> not possible.

If this is the intended behaviour of set-quit-char, then how is one supposed
to set quit_char from a graphical frame? quit_char is demonstrably not
TTY-specific, so it should be configurable and I cannot see a better place
than set-quit-char.

> FWIW, my NSHO is that we should deprecate set-quit-char and remove it
> in a future Emacs version.  It is no longer reasonable to have a
> feature that only works on text terminals.

Do you mean that quit_char should be removed entirely from the C code? 
Perhaps
that would be best, I do not know enough to have an informed
optinion. However, as long as quit_char exists I have a demonstrated need to
be able to configure it at runtime.




Information forwarded to bug-gnu-emacs <at> gnu.org:
bug#22743; Package emacs. (Sat, 20 Feb 2016 11:49:02 GMT) Full text and rfc822 format available.

Message #17 received at 22743 <at> debbugs.gnu.org (full text, mbox):

From: Duncan Burke <duncankburke <at> gmail.com>
To: John Wiegley <johnw <at> gnu.org>
Cc: 22743 <at> debbugs.gnu.org
Subject: Re: bug#22743: 25.0.91: set-quit-char does not work if emacs lacks a
 controlling tty
Date: Sat, 20 Feb 2016 22:48:28 +1100

On 20/02/16 19:04, John Wiegley wrote:
>>>>>> Duncan Burke <duncankburke <at> gmail.com> writes:
>> I have heavily customised keybindings on a dvorak layout and this
>> necessitates rebinding quit away from its default value of C-g.
> Hi Duncan,
>
> I'm also a Dvorak user of many years; I find C-g to be quite convenient,
> actually; why did you need to rebind it?  (I ask mainly out of curiosity).
>
You're right, C-g is actually pretty convenient for Dvorak, I move it 
because
it conflicts with other bindings I've chosen.

I have C-h/t/n/s as backward-char, previous-line, next-line and forward 
char.
Then, M-h/t/n/s are backward-word, backward-paragraph, 
forward-paragraph, and
forward-word. M-H/T/N/S continue this pattern, and C-M-h/t/n/s move between
windows.

Going up one row, the commands are the same except killing instead of 
movement
so C-g/c/r/l are backward-delete-char, kill-previous-line, 
kill-next-line and
delete-forward-char.





Information forwarded to bug-gnu-emacs <at> gnu.org:
bug#22743; Package emacs. (Sat, 20 Feb 2016 20:38:01 GMT) Full text and rfc822 format available.

Message #20 received at 22743 <at> debbugs.gnu.org (full text, mbox):

From: Glenn Morris <rgm <at> gnu.org>
To: Eli Zaretskii <eliz <at> gnu.org>
Cc: Duncan Burke <duncankburke <at> gmail.com>, 22743 <at> debbugs.gnu.org
Subject: Re: bug#22743: 25.0.91: set-quit-char does not work if emacs lacks a
 controlling tty
Date: Sat, 20 Feb 2016 15:36:50 -0500
Eli Zaretskii wrote:

>  C-g is supported implicitly and explicitly in many more places. Grep
> the Lisp sources for C-g to see that.

This is http://debbugs.gnu.org/1218, which has seen zero interest since
it was filed 6 years ago, following

http://lists.gnu.org/archive/html/emacs-devel/2008-10/msg00485.html

and subsequent.




Severity set to 'wishlist' from 'normal' Request was from Glenn Morris <rgm <at> gnu.org> to control <at> debbugs.gnu.org. (Sat, 20 Feb 2016 20:38:02 GMT) Full text and rfc822 format available.

Information forwarded to bug-gnu-emacs <at> gnu.org:
bug#22743; Package emacs. (Sat, 20 Feb 2016 20:45:01 GMT) Full text and rfc822 format available.

Message #25 received at 22743 <at> debbugs.gnu.org (full text, mbox):

From: Eli Zaretskii <eliz <at> gnu.org>
To: Glenn Morris <rgm <at> gnu.org>
Cc: duncankburke <at> gmail.com, 22743 <at> debbugs.gnu.org
Subject: Re: bug#22743: 25.0.91: set-quit-char does not work if emacs lacks a
 controlling tty
Date: Sat, 20 Feb 2016 22:44:17 +0200
> From: Glenn Morris <rgm <at> gnu.org>
> Cc: Duncan Burke <duncankburke <at> gmail.com>,  22743 <at> debbugs.gnu.org
> Date: Sat, 20 Feb 2016 15:36:50 -0500
> 
> Eli Zaretskii wrote:
> 
> >  C-g is supported implicitly and explicitly in many more places. Grep
> > the Lisp sources for C-g to see that.
> 
> This is http://debbugs.gnu.org/1218, which has seen zero interest since
> it was filed 6 years ago, following
> 
> http://lists.gnu.org/archive/html/emacs-devel/2008-10/msg00485.html

In which there's a suggestion to remove the feature.




Information forwarded to bug-gnu-emacs <at> gnu.org:
bug#22743; Package emacs. (Sat, 20 Feb 2016 20:50:02 GMT) Full text and rfc822 format available.

Message #28 received at 22743 <at> debbugs.gnu.org (full text, mbox):

From: Glenn Morris <rgm <at> gnu.org>
To: Eli Zaretskii <eliz <at> gnu.org>
Cc: duncankburke <at> gmail.com, 22743 <at> debbugs.gnu.org
Subject: Re: bug#22743: 25.0.91: set-quit-char does not work if emacs lacks a
 controlling tty
Date: Sat, 20 Feb 2016 15:49:15 -0500
Eli Zaretskii wrote:

>> http://lists.gnu.org/archive/html/emacs-devel/2008-10/msg00485.html
>
> In which there's a suggestion to remove the feature.

Indeed (gets my vote), but IIUC you objected at that time

http://lists.gnu.org/archive/html/emacs-devel/2008-10/msg00487.html




Information forwarded to bug-gnu-emacs <at> gnu.org:
bug#22743; Package emacs. (Sat, 20 Feb 2016 21:05:01 GMT) Full text and rfc822 format available.

Message #31 received at 22743 <at> debbugs.gnu.org (full text, mbox):

From: Eli Zaretskii <eliz <at> gnu.org>
To: Glenn Morris <rgm <at> gnu.org>
Cc: duncankburke <at> gmail.com, 22743 <at> debbugs.gnu.org
Subject: Re: bug#22743: 25.0.91: set-quit-char does not work if emacs lacks a
 controlling tty
Date: Sat, 20 Feb 2016 23:04:09 +0200
> From: Glenn Morris <rgm <at> gnu.org>
> Cc: duncankburke <at> gmail.com,  22743 <at> debbugs.gnu.org
> Date: Sat, 20 Feb 2016 15:49:15 -0500
> 
> Eli Zaretskii wrote:
> 
> >> http://lists.gnu.org/archive/html/emacs-devel/2008-10/msg00485.html
> >
> > In which there's a suggestion to remove the feature.
> 
> Indeed (gets my vote), but IIUC you objected at that time
> 
> http://lists.gnu.org/archive/html/emacs-devel/2008-10/msg00487.html

Yeah, seven and half years ago!  Lots of water under the bridge since
then.




This bug report was last modified 9 years and 115 days ago.

Previous Next


GNU bug tracking system
Copyright (C) 1999 Darren O. Benham, 1997,2003 nCipher Corporation Ltd, 1994-97 Ian Jackson.