Hi

Thanks.

I tried to make your FAQ text clearer but I don't understand what the
FAQ entry is telling me to do.

Should I copy screen.el into load path and edit it? Or tmux.el? Or both?
It seems like just tmux.el is enough if xterm-keys is on?

So what should I do with tmux.el? Put it in load path and then require
'tmux? Or something else?

So maybe this text:

--- >8 ---
* How do I make ctrl and shift arrow keys work in emacs?

The terminal-init-screen function in term/screen.el is called for new
frames, but it doesn't configure any function keys.

If the tmux xterm-keys option is on, it is enough to define the same
keys as xterm - use the examples/tmux.el file to do this.

Alternatively, the screen.el file can be copied to the load path and
customized.
--- 8< ---

And a note in tmux.el saying what I should do with it.


On Fri, Feb 14, 2014 at 08:35:16PM -0500, Mark Oteiza wrote:
> Nicholas Marriott <nicholas.marri...@gmail.com> writes:
> 
> > Thanks
> >
> > Where did tmux.el come from? Did you write it?
> >
> > Can you add either a public domain declaration (look at vim-keys.conf)
> > or the ISC license text to the top of the two new files?
> >
> > I think you have probably added enough to tmux.vim at least to be able
> > to do this, although it'd probably be polite to also add something like:
> >
> > "Based on an example give by Chris Johnsen at 
> > https://stackoverflow.com/a/15471820";
> >
> > I don't think the Google Groups link in tmux.el is terribly helpful, if
> > there is any more explanatory text then just write it in the file
> > instead.
> >
> >
> >
> 
> I wrote tmux.el, it's the Groups thread that gave me the clue.  I tried
> rewriting the useful bits from there into the file, as well as applying
> the other things you suggested.
> 
> On another note, the plugins that Suraj pointed out look nice.  In
> particular, Fixkeys seems to cover a lot.
> 

> diff --git a/FAQ b/FAQ
> index da72d43..7c0e2b6 100644
> --- a/FAQ
> +++ b/FAQ
> @@ -238,6 +238,24 @@ would be welcome.
>  
>  vim users may also want to set the "ttyfast" option inside tmux.
>  
> +* How do I make Ctrl-arrow and Shift-arrow keys work in emacs?
> +
> +For each new emacs frame, a function is called to initialize term-specific
> +things. In tmux, where TERM is a "screen" derivative, this function is
> +"terminal-init-screen". It loads the xterm library to use its functionality 
> to
> +figure out whether to use 88 or 256 colors; it does not map the 
> xterm-specific
> +keys.
> +
> +The code in the library "term/xterm.el.gz" that maps xterm keys is
> +
> +  (let ((map (copy-keymap xterm-function-map)))
> +    (set-keymap-parent map (keymap-parent input-decode-map))
> +    (set-keymap-parent input-decode-map map)))
> +
> +You can copy "term/screen.el" to your local load path to to include desired
> +mappings from "xterm-function-map", thus overriding the native screen 
> library.
> +You can also advise the function "terminal-init-screen" -- see 
> examples/tmux.el.
> +
>  * Why doesn't elinks set the window title inside tmux?
>  
>  There isn't a way to detect if a terminal supports setting the window title, 
> so
> diff --git a/examples/tmux.el b/examples/tmux.el
> new file mode 100644
> index 0000000..cb27663
> --- /dev/null
> +++ b/examples/tmux.el
> @@ -0,0 +1,41 @@
> +;; Author:   Mark Oteiza
> +;; License:  Public domain
> +
> +;; When using emacs in tmux, in order to make use of xterm(1)-style
> +;; keys like shifted arrow keys (e.g. for using windmove), one might
> +;; assign input codes in `init.el' like
> +;;
> +;;   (define-key input-decode-map "\e[1;2A" [S-up])
> +;;
> +;; and so on.  This will work in a standalone emacs (i.e. emacs -nw),
> +;; but is insufficient for spawning emacsclients from emacs --daemon,
> +;; because this only affects the terminal selected when `init.el' is
> +;; loaded.  Every terminal gets its own `input-decode-map' (i.e. it is
> +;; "terminal local"), so the define-key needs to be run every time a new
> +;; frame is loaded in a tmux pane.
> +;;
> +;; For each new frame, emacs runs a function `terminal-init-foo' where
> +;; `foo' depends on the "TERM" environment variable (see the `faces'
> +;; library).  For xterm-like terminals, the `input-decode-map'
> +;; includes all the xterm keys; for screen-likes, these are excluded.
> +;;
> +;; The following elisp is an advice that copies xterm keys into the
> +;; screen `input-decode-map' by adding the logic to the function
> +;; `terminal-init-screen'.  An advice is a way to edit builtin
> +;; functions.  See (info "(Elisp) Advising Functions").
> +;;
> +;; This can be added 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; for example 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))))

> diff --git a/examples/xterm-keys.vim b/examples/xterm-keys.vim
> new file mode 100644
> index 0000000..336c371
> --- /dev/null
> +++ b/examples/xterm-keys.vim
> @@ -0,0 +1,51 @@
> +" tmux.vim - Set xterm input codes passed by tmux
> +" Author:        Mark Oteiza
> +" License:       Public domain
> +" Description:   Simple plugin that assigns some xterm(1)-style keys to 
> escape
> +" sequences passed by tmux when "xterm-keys" is set to "on".  Inspired by an
> +" example given by Chris Johnsen at:
> +"     https://stackoverflow.com/a/15471820
> +"
> +" Documentation: help:xterm-modifier-keys man:tmux(1)
> +
> +if exists("g:loaded_tmux") || &cp
> +  finish
> +endif
> +let g:loaded_tmux = 1
> +
> +function! s:SetXtermCapabilities()
> +  set ttymouse=sgr
> +
> +  execute "set <xUp>=\e[1;*A"
> +  execute "set <xDown>=\e[1;*B"
> +  execute "set <xRight>=\e[1;*C"
> +  execute "set <xLeft>=\e[1;*D"
> +
> +  execute "set <xHome>=\e[1;*H"
> +  execute "set <xEnd>=\e[1;*F"
> +
> +  execute "set <Insert>=\e[2;*~"
> +  execute "set <Delete>=\e[3;*~"
> +  execute "set <PageUp>=\e[5;*~"
> +  execute "set <PageDown>=\e[6;*~"
> +
> +  execute "set <xF1>=\e[1;*P"
> +  execute "set <xF2>=\e[1;*Q"
> +  execute "set <xF3>=\e[1;*R"
> +  execute "set <xF4>=\e[1;*S"
> +
> +  execute "set <F5>=\e[15;*~"
> +  execute "set <F6>=\e[17;*~"
> +  execute "set <F7>=\e[18;*~"
> +  execute "set <F8>=\e[19;*~"
> +  execute "set <F9>=\e[20;*~"
> +  execute "set <F10>=\e[21;*~"
> +  execute "set <F11>=\e[23;*~"
> +  execute "set <F12>=\e[24;*~"
> +
> +  execute "set t_kP=^[[5;*~"
> +  execute "set t_kN=^[[6;*~"
> +endfunction
> +
> +if exists('$TMUX')
> +  call s:SetXtermCapabilities()
> +endif

> ------------------------------------------------------------------------------
> Android apps run on BlackBerry 10
> Introducing the new BlackBerry 10.2.1 Runtime for Android apps.
> Now with support for Jelly Bean, Bluetooth, Mapview and more.
> Get your Android app in front of a whole new audience.  Start now.
> http://pubads.g.doubleclick.net/gampad/clk?id=121054471&iu=/4140/ostg.clktrk

> _______________________________________________
> tmux-users mailing list
> tmux-users@lists.sourceforge.net
> https://lists.sourceforge.net/lists/listinfo/tmux-users


------------------------------------------------------------------------------
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=121054471&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