alphapapa / ement.el

A Matrix client for GNU Emacs
GNU General Public License v3.0
488 stars 44 forks source link

Consider swapping the M-RET and S-<return> bindings #269

Open phil-s opened 6 months ago

phil-s commented 6 months ago

This would be a change for users (and take some adjusting to), but it looks like S-<return> isn't normally available in terminals – so should the standard bindings for M-RET (which is available in terminals) and S-<return> (which isn't) be swapped?

Being able to reply to messages is, after all, far more important than selecting between two alternatives for writing a new message (and I think even more so now that users can customize their preferred ement-room-compose-method).

I noticed this issue when updating the transient menu in https://github.com/phil-s/ement.el/commit/24197ba25099d478e6cc97298e8972554e6c2b2f and realising that the transient specified S-RET (vs S-<return> in the regular keymap), and then establishing that S-RET (which looks like it would be terminal-friendly) didn't seem to be a thing in practice.

alphapapa commented 6 months ago

Not to doubt you, but I'm curious, is it really not available in a terminal? When I press Shift+Return in a shell, both Bash and Fish distinguish it from simply pressing Return.

phil-s commented 6 months ago

It could well be me, or it might depend on the terminal. I know that some terminal emulators do/can support more or less every key sequence Emacs can use, but traditional ones are relatively limited.

Which terminal are you using?

(I'm using gnome-terminal on an Ubuntu system and, under emacs -nw, C-h k S-RET thinks I typed RET.)

phil-s commented 6 months ago

Running showkey -a also supports that result in my terminal: I get the same output typing both RET and S-RET. Somewhere I've seen an article on exactly how common terminals process modified keys, so if I can find that I can probably confirm this definitively.

alphapapa commented 6 months ago

Hm, interesting. showkey -a shows, for Return followed by Shift+Return:

$ showkey -a 

Press any keys - Ctrl-D will terminate this program

^M       13 0015 0x0d
^[OM     27 0033 0x1b
         79 0117 0x4f
         77 0115 0x4d
^D        4 0004 0x04

That's using Konsole from KDE/Plasma 5.

But emacs -q -nw on the same terminal, using C-h k, detects both Return and Shift+Return as RET.

phil-s commented 6 months ago

I suspect RET being ^M is actually the reason, as Ctrl-modified letters are case-insensitive. In your case you're seeing a different escape sequence being sent to disambiguate it (and I think you could probably get Emacs to interpret that), but I'm guessing that's a Konsole thing. (I'd try it myself, but I think Ubuntu wants to install all of KDE in order to provide konsole -- 85 packages seems a bit much).

alphapapa commented 6 months ago

Thanks. Well, I guess we should do this, then.

phil-s commented 6 months ago

I haven't implemented that swap, but I have changed the existing S-RET to S-<return> in #270.