termux / termux-packages

A package build system for Termux.
https://termux.dev
Other
13.17k stars 3.02k forks source link

emacs doesn't recognize Alt as Meta #1922

Open notuntoward opened 6 years ago

notuntoward commented 6 years ago

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.

fornwall commented 6 years ago

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?

notuntoward commented 6 years ago

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.

nektoplasma commented 6 years ago

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.

jenalj commented 6 years ago

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.

notuntoward commented 6 years ago

@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.

jenalj commented 6 years ago

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.

miles-prower commented 5 years ago

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→Ctrl, 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.

meugr commented 5 years ago

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

jenalj commented 4 years ago

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.

stale[bot] commented 2 years ago

This issue/PR has been automatically marked as stale because it has not had recent activity. It will be closed if no further activity occurs. Thank you for your contributions.