I want to use Alt+6 to switch to the 6th gnome terminal tab. But when I am in emacs under a terminal tab, the key will be passed to emacs, and not work on terminal.

Is the key first caught by terminal, and then the terminal pass it to emacs?

I don't want to change the keys for either emacs or for gnome terminal. Is there any way that I can add a escape modifier key before Alt+6, to make it not work on emacs but on gnome terminal?



1 Answer 1


Older versions of gnome-terminal, as shipped until Ubuntu Utopic, used to implement an "automatic" "dual" behavior. If you had at least 6 tabs, Alt+6 would switch to the 6th; otherwise it would send the keystroke to whichever app was running inside (e.g. emacs).

Newer versions (beginning with Ubuntu Vivid) don't have this automatic behavior anymore. Alt+1 – Alt+9 are bound by default to switch tabs, and hence do nothing if you don't have enough tabs open. You can undefine these in Edit->Preferences->Shortcuts or reassign these actions to other keys of your own choice, in which case Alt+6 will be sent to the application (emacs).

Alternatively, you can get used to pressing Esc 6 instead.

Is the key first caught by terminal, and then the terminal pass it to emacs?

Yes. The terminal has no way of knowing whether the application running inside it would handle the event of not, and can't figure it out after sending the event either. So the opposite approach (let's see if emacs does something with that, and if not then gnome-terminal switches tab) can't work by design.

The only exception to this design is mouse events. An application needs to signal to the terminal in advance if it's interested in mouse events. If it is, gnome-terminal sends it the event, otherwise it handles it itself.

Edit: mouse events is not the only exception :) Another one that just occurred to me is that when the terminal is switched to the alternate screen (the one which doesn't have a scrollbar; as done by most fullscreen applications) the keys that effect the scrollbar (e.g. Shift+PageUp) are also sent to the app as escape sequences.

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .