I'm sshing to an ubuntu server:

cat /etc/lsb-release 

I run screen, and then emacs.

$ screen --version
Screen version 4.05.00 (GNU) 10-Dec-16
$ emacs --version
GNU Emacs 25.1.1

My screen has the following configuration:

#defflow on # will force screen to process ^S/^Q
deflogin on
#autodetach off

# turn visual bell on
vbell on
vbell_msg "   Wuff  ----  Wuff!!  "

# define a bigger scrollback, default is 100 lines
defscrollback 1024

# Remove some stupid / dangerous key bindings
bind ^k
#bind L
bind ^\
# Make them better
bind \\ quit
bind K kill
bind I login on
bind O login off
bind } history

# An example of a "screen scraper" which will launch urlview on the current
# screen window
#bind ^B eval "hardcopy_append off" "hardcopy -h $HOME/.screen-urlview" "screen urlview $HOME/.screen-urlview"

# The vt100 description does not mention "dl". *sigh*
termcapinfo vt100 dl=5\E[M

# turn sending of screen messages to hardstatus off
hardstatus off
# Set the hardstatus prop on gui terms to set the titlebar/icon title
termcapinfo xterm*|rxvt*|kterm*|Eterm* hs:ts=\E]0;:fs=\007:ds=\E]0;\007
# use this for the hard status string
hardstatus string "%h%? users: %u%?"

# set these terminals up to be 'optimal' instead of vt100
termcapinfo xterm*|linux*|rxvt*|Eterm* OP

# Change the xterm initialization string from is2=\E[!p\E[?3;4l\E[4l\E>
# (This fixes the "Aborted because of window size change" konsole symptoms found
#  in bug #134198)
termcapinfo xterm 'is=\E[r\E[m\E[2J\E[H\E[?7h\E[?1;4;6l'

# Enable non-blocking mode to better cope with flaky ssh connections.
defnonblock 5

When I run emacs -nw outside screen, I can use Shift+arrow keys to select text. But inside screen, when I hit Shift+down, I see: M-[ 1 ; 2 b is undefined. Even with Ctrl+space, which does say Mark activated, I can't use Ctrl+n to select a region. These all work fine outside screen.

I have these related environment variables inside the screen:

TERMCAP=SC|screen.xterm-256color|VT 100/ANSI X3.64 virtual terminal:\

Also, inside the *scratch*, when I hit Ctrl+q arrow-key, I see: ^@, independent of which arrow key I press.

Any idea how to diagnose/fix the problem?


Read man emacs25:

          -nw, --no-window-system
                  Tell Emacs not to create a graphical frame.  If you  use
                  this switch when invoking Emacs from an xterm(1) window,
                  display is done in that window.

And, in screen start emacs with emacs --no-window-system

  • Not sure if -nw has anything to do with it. I am already running all my emacs sessions with -nw, that's my default, which I forgot to mention. – adrin Aug 2 '17 at 14:20
  • Then, emacs is beleving your TERM environment variable, and sending terminal ESCape sequences for that terminal. – waltinator Aug 2 '17 at 14:50
  • Try starting your emacs with env TERM=vt100 emacs -nw and see if that helps. – waltinator Aug 4 '17 at 3:44
  • Now Ctrl+space then arrow keys selects. But shirt, ctrl, or alt + arrow keys don't. Also, ctrl+q then arrow keys in *scratch* still return the same result. – adrin Aug 4 '17 at 7:58

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.