On Tue, Jun 23, 2026 at 17:08 +0200, Vincent Lefevre wrote:
I also emailed Thomas Dickey to check with him about this. He
confirmed that meta() is not reset. It's apparently a rarely set
mode, and so he also advised to turn it back off before exiting.
As I've said in the ticket, I'm wondering why Mutt changes the setting
in the first place. The terminal settings should be a user decision.
Yes, why does Mutt do that?
Some background, for other people who might not know about this: Emacs,
and many Emacs-like command-line editors, including in some Unix
shells, has long used a modifier key Meta, analogous to the modifier
keys Shift and Control, that changes a typed character to something
related but different. (It's standard practice to assign that meaning
Meta to the keys labeled Alt, probably because most keyboards have Alt
keys but not Meta keys.)
When Emacs runs as an X client, that works fine, because it hears about
all key presses and releases. On a terminal, not so much. Terminals and
their emulators traditionally used ASCII. Typing Shift-A or Control-A
generated, within the terminal, the ASCII character 'A' or control-A.
But of course, ASCII does not include any meta-characters.
So Emacs includes a workaround for terminals: instead of typing Meta-A,
you can type an Escape character followed by an A, and Emacs interprets
that to mean the same as Meta-A. That's clunky and slow to type,
though, not nearly as good.
So a long time ago somebody, probably xterm, added a hack mode: since
7-bit ASCII characters are stored in 8-bit bytes, using the Meta key
sets the normally unused high bit. Presto, meta-characters. (Of course,
Emacs has to know how to interpret those bytes.)
That doesn't work with other character sets, like Latin-1, or Unicode
encoded as UTF-8, which both use all 8 bits of each byte.
So somebody, probably xterm again, added another hack mode, where
typing Meta-A generates and sends the two characters Escape A. With
that, you can type Emacs commands fast in all those character sets.
I guess the ncurses function meta() puts a terminal emulator in the
hack mode where the Meta key sets the high bit of the byte? And certain
parts of Mutt know how to interpret those bytes, like the little
editors that accept a line of text at the bottom of the window? I just
tested, and saw Mutt's "limit" editor understand both Meta-f and Escape
f to mean forward-word.
The high-bit Meta hack is becoming outdated, as the world moves toward
Unicode. Terminal emulators generally can generate and send Unicode
these days (as UTF-8).
I suppose Mutt could stop setting the high-bit meta mode in terminal
emulators, and leave it up to the user. Mutt could look at the locale,
which includes the character set, and interpret the high bit as Meta
only when the character set is ASCII. Or just drop high-bit Meta
entirely as outdated, and get lots of complaints.
Have I guessed right about how Mutt uses this stuff? Does Mutt accept
Unicode (UTF-8) from terminal emulators?