33

When I am using emacs under GNU Screen, if I call C-x C-s screen hangs and does not respond to any keyboard input.

I can't reproduce this, but at least one time per day I have to kill my screen session and restart it.

How can I solve this?

Thanks

2
  • Which Unix? There are many differences in terminal device handling between Linux, BSD, Solaris, ... – user1686 Feb 28 '11 at 17:24
  • 1
    I am actually using Putty to ssh into a Ubuntu Server LTS instance. – simao Feb 28 '11 at 18:12
54

CtrlS is the "Pause transmission" (XOFF) flow control character. Usually it's handled by the tty driver, or in this case Screen. Its opposite is XON, or CtrlQ.

When you launch Emacs, it normally takes over most of the special characters (not just flow control, but also the usual CtrlC "Interrupt", for example).

  • Use C-a :flow off to disable flow-control for this Screen window.

    Confirm with C-a :info (look for -flow in the pop-up).

  • If it doesn't help, try stty -ixon or stty stop undef.

    (You can do it from a separate window using stty -f /dev/tty1 or stty </dev/tty1.)

On my system (Linux), Screen does notice when flow control is disabled for the tty. Your OS might have some limitations, though.

5
  • :flow off worked. thanks! any way I can make it permanent? – simao Feb 28 '11 at 18:17
  • 1
    @simao: See defflow in the manual page of screen. – user1686 Feb 28 '11 at 18:52
  • 3
    Elaborating on @simao and @grawity's comments - To permanently disable flow-control (I assume this is the desired result for most people), add the line defflow off to your ~/.screenrc file, or create one in your home directory if it does not already exist. This was sufficient to allow my emacs to function properly inside a screen window. This approach should be considered before rebinding any keys. – pscl Mar 9 '13 at 5:25
  • 2
    This resolved the problem for me, but I have yet to learn why "all of a sudden" screen was put into this mode.... perhaps there is some screen key stroke which enables flow control the I inadvertently typed...??? – malcook Feb 14 '14 at 5:17
  • 1
    We're talking about GNU screen and GNU Emacs, and they did not figure out a way to make both work seamlessly ?? ... – yves Baumes Jun 16 '14 at 12:21
4

I had the same problems with the locked screen and many more when using emacs under screen. For example, C-a in emacs, that brings you to the beginning of the line, gets intercepted by screen and it doesn't work.

SOLUTION:

Create a file .screenrc in you home directory with the following:

#Change escape character to C-u 
escape "^uu"                                                                    
#unbind ctrl+s from xoff in order to be able to search in emacs                 
bind s                                                                          
bind ^S                                                                         
#unbind ctrl+x from lockscreen in order to be able to save in emacs             
bind x                                                                          
bind ^X                                                                         

Then each time you open a new screen instead of using C-a you need to use C-u to enter a new screen command. The other two changes take care of a couple more things I needed to change in order to be able to use emacs under screen without problems.

1
  • C-u is an important key for emacs. I don't think it is a good idea, but the idea of changing .screenrc is the better alternative. – vfclists Aug 22 '17 at 16:18

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.