Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Trouble using this when using emacs bindings and running emacs from within tmux #55

Open
apolishch opened this issue Oct 7, 2016 · 1 comment

Comments

@apolishch
Copy link

I am attempting to run both emacs and tmux and am having a real hard time getting copy/paste (kill/yank) to work right:

the relevant sections of my tmux config:

set-option -g mouse on
set-option -g default-command "reattach-to-user-namespace -l bash"
setw -g mode-keys emacs
bind-key -n -t emacs-copy M-w copy-pipe "reattach-to-user-namespace pbcopy"
bind-key -n C-y run "xclip -o | tmux load-buffer - ; tmux paste-buffer"

And of my emacs config:

(setq x-select-enable-clipboard t x-select-enable-primary t)

This has the following effects:

  1. I can copy and paste in my tmux with emacs buttons (M-w, C-y)

  2. Whenever I attempt to select a region in my emacs (with C-Space for example), it also selects my line number from linum-mode

  3. I can copy things that I select with my mouse inside emacs into my system clipboard AND the kill ring( e.g. selecting text with my mouse and hitting M-w causes me to be able to past in my browser/other applications with Command+V (I'm on a Mac) AND in emacs/tmux with C-y)

  4. Selecting a region (with problem 2 baked in to boot) with C-Space and using either C-w or M-w, or just killing with C-k does not result in pastable result, either in the kill ring, or on the system clipboard.

Is there any way to fix problems 2/4 without getting rid of desirable properties 1/3?

Thanks so much!

@ChrisJohnsen
Copy link
Owner

For your 2), it sounds like you are making a tmux copy-mode selection; copy-mode will select anything that is on the screen, which includes the line numbers drawn by linum-mode in Emacs. I am not sure why C-Space would start tmux copy-mode though (unless you have a non-prefix tmux binding for C-Space).

For your 4), if you are in tmux copy-mode (as your point 2 indicates), then your C-w, M-w, and C-k would be processed by your emacs-copy bindings in tmux, not Emacs; the selection would go to a new tmux buffer, not the Emacs kill ring or the system pasteboard (except for M-w, since you rebound that to use pbcopy?). With the default bindings you can paste a tmux buffer with Prefix ].

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants