How do you set up a pure emacs layered tty stack with 256 colors and mouse support?

500 Views Asked by At

I use this layered tty stack to reach emacs on GNU/Linux:

Mac OS X > iTerm2 $ ssh head-node --> 
$ screen $ ssh compute-node --> 
$ screen $ emacs -nw

Notes:

  • Mac OS X = Version 10.8.2

  • iTerm2 = iterm2.com Build 1.0.0.20130319, terminal type = xterm-256color.

  • screen = GNU Screen, built from git clone git://git.savannah.gnu.org/screen.git with --enable-colors25, run with .screenrc "term xterm-256color"

  • emacs = Emacs 24.3 built from 24.3 source.

This actually works great, but there are user interface behaviors that I want to modify.

I figure this might be easier if I switch to ...

A pure emacs layered tty stack with 256 colors and mouse support:

Mac OS X > emacs M-x term $ ssh head-node -->
$ [emacs --daemon] emacsclient -nw M-x term $ ssh compute-node -->
$ [emacs --daemon] emacsclient -nw       

Which raises these questions ...

  1. What is the best choice for emacs terminal emulation in this situation?

  2. How do I set up TERM and TERMINFO to get 256 colors?

  3. How do I capture/restore window layout in the emacs daemons?

  4. How do I keep track of session context? By this I mean hostname and sub-sessions?

  5. How do I make the mouse work top-to-bottom?

The mouse actually works fine with iTerm2 and this in ~./emacs:

;; Enable iTerm2 mouse support
;; > Preferences > Profiles > Default > Terminal > Enable xterm mouse reporting > check
(unless window-system
  (require 'mouse)
  (xterm-mouse-mode t)
  (global-set-key [mouse-4] '(lambda ()
                              (interactive)
                              (scroll-down 1)))
  (global-set-key [mouse-5] '(lambda ()
                              (interactive)
                              (scroll-up 1)))
  (defun track-mouse (e))
  (setq mouse-sel-mode t)
)

This leads to a sub-question...

1a. Is there an emacs terminal emulation that produces/forwards xterm mouse events?

Notes:

  • posed as a group because answers must work together.

  • tty solutions are required due to bandwidth and personal preference.

  • emacs tramp is not sufficient, given various other requirements.

0

There are 0 best solutions below