Hi,

Recently I tackled the issue of editors and keybindings in tmux.  This
has been addressed on the mailing list a couple times before [0][1], and
has spawned a bunch of SO posts, etc.  It would be really nice if
solutions were in the FAQ.

Most of what I think should be added was already written by Chris
Johnsen: on here about emacs [1], and on SO about vim [3].

I think I found a simpler (and elispy) alternative solution for emacs
based on what I found on the emacs help mailing list [2].  I try to
explain all the details for the below snippet in its comments.

---
# For each new Emacs frame, a function is called to initialize
# term-specific things.  The function `terminal-init-screen' loads the
# xterm library just to figure out 88 or 256 colors; it does not map
# the xterm-specific keys.
#
# This is an `advice' to augment `terminal-init-screen', which one can
# add to `~/.emacs/init.el' to get xterm keys in Emacs & tmux, when
# `xterm-keys' is set to `on' in tmux.

(defadvice terminal-init-screen
  ;; The advice is named `tmux', and is run before
  ;; `terminal-init-screen' runs.
  (before tmux activate)
  ;; Docstring.  This describes the advice and is made available inside
  ;; emacs; e.g. when doing C-h f terminal-init-screen RET
  "Apply xterm keymap, allowing use of keys passed through tmux."
  ;; This is the elisp code that is run before `terminal-init-screen'.
  (if (getenv "TMUX")
    (let ((map (copy-keymap xterm-function-map)))
    (set-keymap-parent map (keymap-parent input-decode-map))
    (set-keymap-parent input-decode-map map))))
---

[0] http://thread.gmane.org/gmane.comp.terminal-emulators.tmux.user/2197
[1] http://thread.gmane.org/gmane.comp.terminal-emulators.tmux.user/4268
[2] https://groups.google.com/forum/#!topic/gnu.emacs.help/ZGu2MNkJGrI
[3] https://stackoverflow.com/questions/15445481

-- 
Mark Oteiza


------------------------------------------------------------------------------
Managing the Performance of Cloud-Based Applications
Take advantage of what the Cloud has to offer - Avoid Common Pitfalls.
Read the Whitepaper.
http://pubads.g.doubleclick.net/gampad/clk?id=121051231&iu=/4140/ostg.clktrk
_______________________________________________
tmux-users mailing list
tmux-users@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/tmux-users

Reply via email to