On Tue, 13 Aug 2024 at 17:41, Vincent Lefevre <vinc...@vinc17.net> wrote:
> On 2024-08-13 16:28:42 +0100, Reuben Thomas wrote: > > I'm not quite sure I understand you here: are you saying that it's > > documented somewhere that one should use the "\e" form? > > I'm saying that since the documentation says that the Meta key > may generate an Escape character (which is actually the case in > general), you should use the \e form as a consequence. > OK, I'm not sure I follow why this should be necessary (e.g. it isn't with Emacs), but I think I can now follow why it happens! convert-meta (On) > If set to On, readline will convert characters with the eighth > bit set to an ASCII key sequence by stripping the eighth bit and > prefixing it with an escape character (in effect, using escape as > the meta prefix). The default is On, but readline will set it to > Off if the locale contains eight-bit characters. This variable > is dependent on the LC_CTYPE locale category, and may change if > the locale is changed. > This is also confusing. I read this and thought "OK, so convert-meta should be On in my UTF-8 locale, because UTF-8 doesn't have 8-bit characters", but it is off, so I guess UTF-8 counts as having 8-bit characters? > enable-meta-key (On) > When set to On, readline will try to enable any meta modifier key > the terminal claims to support when it is called. On many termiā > nals, the meta key is used to send eight-bit characters. > > (Note: This is wrong, nowadays, the Meta key generates an Escape > character.) > I guess that warrants an upstream bug report; I'm happy to file it. m. Fixed a bug that caused "\M-x" style key bindings to not obey the > setting > of the `convert-meta' variable. > Aha! Many thanks for your detailed explanation. I guess the question in 2024 is, can we have our cake and eat it? I think it would be nice if things worked as one might reasonably expect (i.e. "\M-" prefixes work as in Emacs) in UTF-8 locales. I can see that it might be complicated to make them work also in old terminals. But the convert-meta distinction would seem to be otiose in wide-character environments. I'm happy to take this to the readline mailing list if that seems appropriate; in any case, I guess this Debian bug can be closed, because in fact it's a deliberate change to readline 5.1. -- https://rrt.sc3d.org