all messages for Emacs-related lists mirrored at yhetil.org
 help / color / mirror / code / Atom feed
* Fixing key bindings on some terminals
       [not found] <1659521050.517588.1401091680002.JavaMail.root@insa-lyon.fr>
@ 2014-05-26  8:32 ` Kevin Le Gouguec
  2014-05-26 15:18   ` Drew Adams
  0 siblings, 1 reply; 7+ messages in thread
From: Kevin Le Gouguec @ 2014-05-26  8:32 UTC (permalink / raw
  To: help-gnu-emacs

Hi,

I'm running Emacs (23.2.1) in various terminals (Terminator 0.93, XTerm 261) and I'm trying to set the following behaviour:

(global-set-key (kbd "C-?") 'help-command)
(global-set-key (kbd "C-h") 'delete-backward-char)
(global-set-key (kbd "M-h") 'backward-kill-word)
(global-set-key (kbd "M-?") 'help)

I.e. move "help" to C-? so that I can use C-h to delete stuff backwards.

However with Terminator, C-? ends up behaving like C-h. Running "describe-key" and giving "C-?" as input gives information about the "DEL" key ; with XTerm, running "describe-key" and typing "C-?" prints the prompt in the minibuffer and waits for the final input, as expected.
I tried to test some other bindings like "C-," ; again, XTerm recognized the shortcut, while Terminator only recognized ",".

I know this is not really a problem with Emacs, but I'd like to know how I can pinpoint what application "eats" my shortcuts (is it Terminator, Openbox (3.5.0), something else entirely?). Basically I'm trying to get C-? to work with Terminator (I tried replacing Terminator with multi-term in Emacs but I'm still not satisfied with it). While I'd love it if anyone could provide a complete graph of causes and effects and the steps needed to get what I want, I'd still be glad with just a few pointers on what I need to learn/look for to fix how Emacs receives key presses when running inside Terminator.

Thanks in advance!



^ permalink raw reply	[flat|nested] 7+ messages in thread

* RE: Fixing key bindings on some terminals
  2014-05-26  8:32 ` Fixing key bindings on some terminals Kevin Le Gouguec
@ 2014-05-26 15:18   ` Drew Adams
  2014-05-26 15:50     ` Kevin Le Gouguec
  0 siblings, 1 reply; 7+ messages in thread
From: Drew Adams @ 2014-05-26 15:18 UTC (permalink / raw
  To: Kevin Le Gouguec, help-gnu-emacs

> (global-set-key (kbd "C-?") 'help-command)
> (global-set-key (kbd "C-h") 'delete-backward-char)
...
> I.e. move "help" to C-? so that I can use C-h to delete stuff backwards.

See option `normal-erase-is-backspace' for this part, at least.



^ permalink raw reply	[flat|nested] 7+ messages in thread

* Re: Fixing key bindings on some terminals
  2014-05-26 15:18   ` Drew Adams
@ 2014-05-26 15:50     ` Kevin Le Gouguec
  2014-05-26 18:32       ` Drew Adams
  0 siblings, 1 reply; 7+ messages in thread
From: Kevin Le Gouguec @ 2014-05-26 15:50 UTC (permalink / raw
  To: Drew Adams; +Cc: help-gnu-emacs

Thanks, didn't know about that one!

This leaves getting C-? to work has "help-command" with Terminator. Right now it behaves like DEL or BACKSPACE, i.e. it deletes forward, since I set "normal-erase-is-backspace" to t.

To sum up, with "normal-erase-is-backspace" on:

- With Terminator, "describe-key" "C-?" returns "C-d".
- With XTerm, "describe-key" "C-?" prints "C-?-" and waits for completion.

I tried to dig some more and apparently this has to do with Terminator being an ASCII-based terminal, like gnome-terminal. I haven't read enough to know for sure, so right now I guess my options are:

a) digging real hard into Terminator to see how I can tell it to send C-<punctuation> when I type C-<punctuation> (if that's even possible)
b) switch completely to XTerm (find out how I can toggle fullscreen with Openbox) and find a way to split the window into many terminals, either
  (1) using screen (and finding a suitable shortcut to sacrifice as an escape key)
  (2) using Emacs's multi-term mode (and find a way to make it behave *exactly* like term-mode, instead of having its own little quirks)

Does anyone know anything about a) ? (I haven't found the Terminator community to be very reactive, at least not on launchpad)


----- Original Message -----
From: "Drew Adams" <drew.adams@oracle.com>
To: "Kevin Le Gouguec" <kevin.le-gouguec@insa-lyon.fr>, help-gnu-emacs@gnu.org
Sent: Monday, May 26, 2014 5:18:02 PM
Subject: RE: Fixing key bindings on some terminals

> (global-set-key (kbd "C-?") 'help-command)
> (global-set-key (kbd "C-h") 'delete-backward-char)
...
> I.e. move "help" to C-? so that I can use C-h to delete stuff backwards.

See option `normal-erase-is-backspace' for this part, at least.



^ permalink raw reply	[flat|nested] 7+ messages in thread

* RE: Fixing key bindings on some terminals
  2014-05-26 15:50     ` Kevin Le Gouguec
@ 2014-05-26 18:32       ` Drew Adams
  2014-05-26 20:14         ` Kevin Le Gouguec
  0 siblings, 1 reply; 7+ messages in thread
From: Drew Adams @ 2014-05-26 18:32 UTC (permalink / raw
  To: Kevin Le Gouguec; +Cc: help-gnu-emacs

> > See option `normal-erase-is-backspace' for this part, at least.
>
> Thanks, didn't know about that one!
> 
> This leaves getting C-? to work has "help-command" with Terminator. Right
> now it behaves like DEL or BACKSPACE, i.e. it deletes forward, since I set
> "normal-erase-is-backspace" to t.

Actually, the *character* `CONTROL ?' (aka ^?, an ASCII control char)
*is* `DEL' (old name `DELETE').  And it is not the key `<backspace>',
the key `<delete>', or the key `C-?'.

That is (for the last part), it might be (and probably is) the case
that when you hold Control and hit `?', you keyboard does not send a
CONTROL ? character but something else.  Yes, this is confusing.

If you do `C-h k C-i', that is, hold Control and hit `i', Emacs always
writes `TAB'.  But the same does not happen for `C-?' (holding Control
and hitting `?').  Emacs distinguishes the character ^? (aka `DEL')
from the key that is sent from your keyboard when you hold Control and
hit `?'.

So `C-h k C-?' (holding Control and hitting `?') typically tells
you that "C-? is undefined".  It does not tell you that `DELL' is
bound to...

If you want `DEL') to invoke `help-command' then bind it to
`help-command':

(global-set-key (kbd "DEL") 'help-command)
(define-key help-map (kbd "DEL") 'help-for-help) ; for `DEL DEL'

Then you can use, for example, `DEL f' for `describe-function' and
`DEL DEL' for `help-for-help'.

You might need to bind `DEL' in additional keymaps also, as some
modes bind `DEL' to other commands.  For example, in Emacs Lisp
mode `DEL' is bound to `backward-delete-char-untabify'.

> To sum up, with "normal-erase-is-backspace" on:
> - With Terminator, "describe-key" "C-?" returns "C-d".
> - With XTerm, "describe-key" "C-?" prints "C-?-" and waits for completion.
> 
> I tried to dig some more and apparently this has to do with Terminator being
> an ASCII-based terminal, like gnome-terminal. I haven't read enough to know
> for sure, so right now I guess my options are:

Sorry, I know nothing about Terminator. 

An ASCII-based terminal should be able to handle `DEL'.  But it might
not be able to handle the key that your keyboard sends when you hold
down Control and hit `?'.

If your teminal can handle Control + `?' then you can bind it just as
you did:

(global-set-key (kbd "C-?") 'help-command)
(define-key help-map (kbd "C-?") 'help-for-help)

The fact that this does not work for you tells me that your terminal
does not recognize the key combination Control + `?'.  (That would be
the case for any ASCII terminal.)



^ permalink raw reply	[flat|nested] 7+ messages in thread

* Re: Fixing key bindings on some terminals
  2014-05-26 18:32       ` Drew Adams
@ 2014-05-26 20:14         ` Kevin Le Gouguec
  2014-05-26 21:51           ` Drew Adams
  0 siblings, 1 reply; 7+ messages in thread
From: Kevin Le Gouguec @ 2014-05-26 20:14 UTC (permalink / raw
  To: Drew Adams; +Cc: help-gnu-emacs

Woah, never realized ^? actually was the control character for DEL. Thanks!

Okay so I do not want to bind DEL to "help-command". I'd like "help-command" to be bound to "hold control then hit '?'". Right now doing this results in "delete-char", and trying to "describe-key" "C-?" gives me the description for "C-d".
I tried using 
(global-set-key (kbd "DEL") 'help-command)

But C-? still forward-deleted characters, and "describe-key" still told me I typed C-d. So I'm not sure what Terminator sends to Emacs when I hit C-? :/

Of course this is all in Terminator ; XTerm works fine. I.e. these lines...

(global-set-key (kbd "C-?") 'help-command)
(define-key help-map (kbd "C-?") 'help-for-help)

... actually do what I expect them to do.


Not sure what my options are. I don't know how hard it'd be to change Terminator to behave like XTerm when it comes to key presses. I guess it's just a matter of time before I switch to having one XTerm running Emacs with a bunch of terminals inside...


----- Original Message -----
From: "Drew Adams" <drew.adams@oracle.com>
To: "Kevin Le Gouguec" <kevin.le-gouguec@insa-lyon.fr>
Cc: help-gnu-emacs@gnu.org
Sent: Monday, May 26, 2014 8:32:41 PM
Subject: RE: Fixing key bindings on some terminals

> <snip>

Actually, the *character* `CONTROL ?' (aka ^?, an ASCII control char)
*is* `DEL' (old name `DELETE').  And it is not the key `<backspace>',
the key `<delete>', or the key `C-?'.

That is (for the last part), it might be (and probably is) the case
that when you hold Control and hit `?', you keyboard does not send a
CONTROL ? character but something else.  Yes, this is confusing.

If you do `C-h k C-i', that is, hold Control and hit `i', Emacs always
writes `TAB'.  But the same does not happen for `C-?' (holding Control
and hitting `?').  Emacs distinguishes the character ^? (aka `DEL')
from the key that is sent from your keyboard when you hold Control and
hit `?'.

So `C-h k C-?' (holding Control and hitting `?') typically tells
you that "C-? is undefined".  It does not tell you that `DELL' is
bound to...

If you want `DEL') to invoke `help-command' then bind it to
`help-command':

(global-set-key (kbd "DEL") 'help-command)
(define-key help-map (kbd "DEL") 'help-for-help) ; for `DEL DEL'

Then you can use, for example, `DEL f' for `describe-function' and
`DEL DEL' for `help-for-help'.

You might need to bind `DEL' in additional keymaps also, as some
modes bind `DEL' to other commands.  For example, in Emacs Lisp
mode `DEL' is bound to `backward-delete-char-untabify'.

> <snip>

Sorry, I know nothing about Terminator. 

An ASCII-based terminal should be able to handle `DEL'.  But it might
not be able to handle the key that your keyboard sends when you hold
down Control and hit `?'.

If your teminal can handle Control + `?' then you can bind it just as
you did:

(global-set-key (kbd "C-?") 'help-command)
(define-key help-map (kbd "C-?") 'help-for-help)

The fact that this does not work for you tells me that your terminal
does not recognize the key combination Control + `?'.  (That would be
the case for any ASCII terminal.)



^ permalink raw reply	[flat|nested] 7+ messages in thread

* RE: Fixing key bindings on some terminals
  2014-05-26 20:14         ` Kevin Le Gouguec
@ 2014-05-26 21:51           ` Drew Adams
  2014-05-26 22:39             ` Stefan Monnier
  0 siblings, 1 reply; 7+ messages in thread
From: Drew Adams @ 2014-05-26 21:51 UTC (permalink / raw
  To: Kevin Le Gouguec; +Cc: help-gnu-emacs

> C-? ... and "describe-key" still told me I typed C-d. So I'm not sure what
> Terminator sends to Emacs when I hit C-?

Emacs thinks it is sending `C-d'.

> Not sure what my options are.

Perhaps there is a Terminator doc or mailing list you can consult?
Or maybe someone here will know something about that.



^ permalink raw reply	[flat|nested] 7+ messages in thread

* Re: Fixing key bindings on some terminals
  2014-05-26 21:51           ` Drew Adams
@ 2014-05-26 22:39             ` Stefan Monnier
  0 siblings, 0 replies; 7+ messages in thread
From: Stefan Monnier @ 2014-05-26 22:39 UTC (permalink / raw
  To: help-gnu-emacs

>> C-? ... and "describe-key" still told me I typed C-d. So I'm not sure what
>> Terminator sends to Emacs when I hit C-?
> Emacs thinks it is sending `C-d'.

No, that's just the result of normal-erase-is-backspace-mode's rewrite.


        Stefan




^ permalink raw reply	[flat|nested] 7+ messages in thread

end of thread, other threads:[~2014-05-26 22:39 UTC | newest]

Thread overview: 7+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
     [not found] <1659521050.517588.1401091680002.JavaMail.root@insa-lyon.fr>
2014-05-26  8:32 ` Fixing key bindings on some terminals Kevin Le Gouguec
2014-05-26 15:18   ` Drew Adams
2014-05-26 15:50     ` Kevin Le Gouguec
2014-05-26 18:32       ` Drew Adams
2014-05-26 20:14         ` Kevin Le Gouguec
2014-05-26 21:51           ` Drew Adams
2014-05-26 22:39             ` Stefan Monnier

Code repositories for project(s) associated with this external index

	https://git.savannah.gnu.org/cgit/emacs.git
	https://git.savannah.gnu.org/cgit/emacs/org-mode.git

This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.