Trouble using this when using emacs bindings and running emacs from within tmux
apolishch opened this issue · 1 comments
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:
-
I can copy and paste in my tmux with emacs buttons (
M-w
,C-y
) -
Whenever I attempt to select a region in my emacs (with
C-Space
for example), it also selects my line number fromlinum-mode
-
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 withCommand+V
(I'm on a Mac) AND in emacs/tmux withC-y
) -
Selecting a region (with problem 2 baked in to boot) with
C-Space
and using eitherC-w
orM-w
, or just killing withC-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!
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 ].