screen-users
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: emacs compatibility - changing a default binding?


From: Axel Beckert
Subject: Re: emacs compatibility - changing a default binding?
Date: Wed, 24 Apr 2013 14:47:17 +0200
User-agent: Mutt/1.5.20 (2009-06-14)

Hi,

[Warning: Long post! TL;DR: Ctrl + ASCII character below 0x3F
generally don't seem to work as default binding. The post also
contains a bunch of working suggestions, partially from what similar
programs use, including where they clash with Emacs or shell
keybindings. :-]

On Tue, Apr 23, 2013 at 03:43:09PM +0100, Joe Corneli wrote:
> And yet, the default binding conflicts with the default binding C-a
> for `move-beginning-of-line' in Emacs, which presumably affects many
> users.  Rather than have lots of different workarounds
> (http://emacswiki.org/emacs/GnuScreen#toc1), might it make sense to
> change the default binding?

Per user, yes, but not generally. Screen's C-a is hardwired in too many
people's finger muscles.

Oh, and I'm a happy Screen and Emacs user and still use C-a. I don't
mind pressing C-a a to get to the beginning of the line if my Emacs
runs inside Screen. (Yes, occassionally I have a leading "a" in
non-screen Emacsen. ;-)

> (One of the users on the Emacs Wiki page suggests C-; but notes no
> luck with experiments trying to bind it.)

I thought I got it once working like this (with screen 4.0.3) once:

  escape '^;;'

But I can't reproduce it anymore and it now always argues "Two
characters are required with -e option, not '^;;'." The same happens
for any character below ASCII 0x3F (which is "?"): None of the special
characters +, -, *, ", #, %, &, !, ', (, ), ., / or , work with
Control as Screen default binding. Neither do digits.

It seems as if Screen doesn't make a difference between C-; and ;,
too. Because if I say

  escape ;;

both, C-; and ; seem to have the same behaviour.

I suspect this is the case because the classic "control" sequences are
basically typed as Control key plus the character at ASCII Byte
value | 0x40 (i.e. bitwised or'ed with 64; adding works in that case,
too), so 0x0A (line feed) is C-j (try to press C-j in Emacs and see
what it does), because J is 0x4A. So I suspect the only characters
which can be used with control in text mode are those above 0x40, i.e.
@, (captial) A-Z and [, \, ], ^, _, `, etc.

The only exception I found so far was the question mark (0x3F). While

  escape ^>>

(">" = 0x3E) does throw the common error message as mentioned above,
the command

  escape ^??

doesn't and seems to work. Strange. I'm confused.


Anyway, about choosing a usable default binding itself:

Keynav, a keyboard-based way to move the X cursor uses C-;, too. (But
that's X and hence something completely different. ;-) And I haven't
noticed that I triggered keynav accidentially, so this keybinding
doesn't seem to be used by any Emacs feature I used and hence would
make indeed an promising default binding. But then on the other hand,
I have keyboards where I only have a left Ctrl key, so I'd have to
type C-; with two hands (at least on US keyboard layouts), which would
likely bother me.

C-', C-., C-, and C-. would fall in the same catgory, but don't work
either for the same reasons -- same error message. Additionally, C-/ is
already bound to undo in Emacs (works even in text mode, why?), but
since undo in Emacs has multiple keybindings, at least C-_ and C-x u
come to my mind, this should be an issue.


But let's go to _working_ solutions for the default binding:

C-o is also an suggestion on http://emacswiki.org/emacs/GnuScreen#toc1
It's bound to open-line in Emacs, but I never use that. Nevertheless,
it would also a two-handed command on some laptops.

Ratpoison, an X window manager which is modeled after Screen uses C-t
-- which is "transpose-chars" (i.e. switch the two characters around
the text cursor) in Emacs. I don't mind pressing C-t t there. (Also
suggested on http://emacswiki.org/emacs/GnuScreen#toc1)

Tmux, a Screen work-alike, uses C-b -- which is backward-char in
Emacs. (I would mind to have to press any key twice to just go one
character left.)

Byobu, a wrapper and configuration system for Screen and Tmux uses
function keys (F1 to F12) for managing windows and tries to not use a
prefix-based scheme where possible.

Mosh, a remote shell with some of Screen's capabilities uses C-^, but
is only needed seldomly there (in comparison to Screen) and it would
bother me to have to press Shift in addition to Ctrl. And I would
likely type the "6" key with my right hand, i.e. another two-handed
keystroke.

A friend of mine used backtick ("`", without modifier). Not sure how
he passed a backtick to the program inside Screen then. I'd rather
propose C-`, but that's unpleasant to type on some laptop keyboards
where the ` key is more to the left than the Ctrl key.

Another friend of mine, who uses nested Screen sessions, uses C-a on
the outer screen and C-z on the inner screen. C-z is needed in most
shells to suspend a program, so you'll have at least a collision
there. (That's the only situation where I would change Screen's
default binding. Always having to calculate and count how many C-a you
have to type in a row to reach which nesting level of Screen is
tedious and error-prone.


So my conclusion on that topic is:

There are many ways to do it and it depends a lot on the programs you
acutally use inside the Screen session.

Having to type C-a a to go to the beginning of the line in emacs or
the shell isn't that bad. :-)

You very likely won't find a better keybinding which suits everyone,
mostly due to _no_ keybinding is perfect and C-a is too well-known.

HTH.

                Kind regards, Axel
-- 
/~\  Plain Text Ribbon Campaign                   | Axel Beckert
\ /  Say No to HTML in E-Mail and News            | address@hidden  (Mail)
 X   See http://www.asciiribbon.org/              | address@hidden (Mail+Jabber)
/ \  I love long mails: http://email.is-not-s.ms/ | http://noone.org/abe/ (Web)



reply via email to

[Prev in Thread] Current Thread [Next in Thread]