Termux-packages: emacs doesn't recognize Alt as Meta

Created on 10 Dec 2017  路  9Comments  路  Source: termux/termux-packages

On Windows and Linux, newer versions of emacs treat the Alt key as Meta, however this does not seem to be the case for the termux emacs package. How do I get this emacs to use Alt as Meta?

I've got a bluetooth keyboard (this one) with working Alt keys, and they do things you'd expect on a Samsung S7, Android 7.0. However, they are ignored inside of termux emacs. For example, I can't comment a line with M-;

In the old days, on linux, I could get around this by defining Alt as Meta with xmodmap or some other X thing. But since termux is a terminal, I don't see how to do it.

termux-app

Most helpful comment

Finally found a usable workaround to this by remapping left alt to escape in EKH. emacs interprets that as "meta" and now works as expected.

All 9 comments

Currently the right alt key (alt gr) is supposed to be used for composing characters, and the left alt key is supposed to be used as Meta (prepend Escape before the pressed character is sent to the terminal). Does that work for you, using the left alt key as Meta?

Thanks for that. I didn't know that right Alt was being mapped to AltGr. Yes, the left Alt key works as meta in emacs.

But this is still confusing. The left Alt key works only if I don't use the External Keyboard Helper app to swap caplock and control. (I made no change to the alt keys).

It's starting to look like there's a bug in EKH. Is there a way in Termux to display the key codes that it receives? I'd use it to see what EKH is doing to the Alt key.

Update: With EKH uninstalled, many of Termux's own hardware keyboard shortcuts still don't work. The R, M, U, +, and - keys behave as expected, but the others cause no action.

But this is still confusing. The left Alt key works only if I don't use the External Keyboard Helper app to swap caplock and control. (I made no change to the alt keys).

I thought I was the only one with this problem. I have been trying to get the setup you described (capslock = ctrl, both alts = meta) working with my Logitech K480 but ran into similar problems.

Some sort of fix would be greatly appreciated, as 10+ years of muscle memory make it kinda hard to use termux with the vanilla Android mappings.

Me too!

The only thing I found to work so far was rooting the phone and remapping caps lock to control at the system level. I'd like to avoid rooting.

@nektoplasma and @jenalj, well, misery loves company. Did you use the External Keyboard Helper app, or did you have this problem using only Termux? I'm sure which program is the cause.

I observed the "left alt not working" problem using the ekh app; Termux alone is fine. I don't use Termux's ctrl-alt shortcuts, so I don't know if those work.

Most probably it's an ekh bug, and I reported it to ekh's listed email address some months ago. Haven't heard back and frankly don't expect any support on closed source software costing a dollar or two.

I think at this point, EKH (and all of Apedroid's apps) can be classified as "Abandonware." EKH hasn't been updated since Jan 2016 according to the Play Store listing, and the developer isn't returning emails. I've tried all sorts of different settings in EKH to try to get the Alt key to work correctly after remapping Caps鈫扖trl, without success. Elsewhere on the interwebs, I've seen discussion of installing the XServer聽XSDL app and running emacs-x after changing the X Window key bindings for Caps and Ctrl.

@nektoplasma Have you solved your problem with k480? I have the same keyboard, I encountered the problem described when using Emacs

Finally found a usable workaround to this by remapping left alt to escape in EKH. emacs interprets that as "meta" and now works as expected.

Was this page helpful?
0 / 5 - 0 ratings

Related issues

newmania picture newmania  路  3Comments

roycebank picture roycebank  路  3Comments

adit picture adit  路  3Comments

tigran123 picture tigran123  路  3Comments

bbtdev picture bbtdev  路  3Comments