Subject: Re: bug#18996: 24.4; Pressing Alt-g shows Esc g- when running emacs inside terminal and in GUI mode it shows M-g

From: Eli Zaretskii <[email-masked]>
Date: Tue, 08 Mar 2016 19:10:51 +0200

> From: Marcin Borkowski <[email-masked]>
> Cc: [email-masked], [email-masked]
> Date: Tue, 08 Mar 2016 17:47:48 +0100
> 
> >> > Further, when I press Alt-x, it shows up as M-x in both the
> >> > scenarios. So it doesn't look like Emacs cannot differentiate between
> >> > the two when running inside the terminal without a GUI.
> >> 
> >> This is not true: M-x is bound (by default) to
> >> `execute-extended-command', which calls `read-extended-command', which
> >> has at one point the literal string "M-x ", which is fed (via
> >> a `concat', which shows prefix arguments, if any) directly to
> >> `completing-read'.
> >> 
> >> > I vaguely remember seeing M-g in the terminal on pressing Alt-g some
> >> > time back, maybe in an older emacs version. But not sure.
> >> 
> >> No idea, though I doubt.
> >> 
> >> All in all, I'll assign this a "wishlist" level - I agree with the OP
> >> that it would be nice to have this solved
> >
> > To have what solved?
> >
> > If you type "C-h l" after M-x, what do you see?
> 
> AFAIU, OP wants to see "M-g-" and not "ESC g-" after pressing M-g in an
> Emacs session in a terminal.

My point was that you will see "ESC g" in the "C-h l" output.  Which
means Emacs _doesn't_ know how to differentiate between ESC-x and M-x,
on the level that shows the prefix key prompts, such as M-g-.  What
happens here is that the command bound to "ESC x" deliberately
displays "M-x " in the echo area.  IOW, "M-x" is _not_ the key echo,
it's a message displayed by a command.

In sum, Emacs doesn't have a way to distinguish between M-c and ESC c,
for any character c, on a TTY.  We can only do that on a GUI frame.