I am using emacs 23.3 on Ubuntu 12.04 LTS. I am having problems trying to copy text from another application (most of the time, Firefox) to emacs. Sometimes it works and sometimes it doesn't. Any way to fix this?
Thanks
I am using emacs 23.3 on Ubuntu 12.04 LTS. I am having problems trying to copy text from another application (most of the time, Firefox) to emacs. Sometimes it works and sometimes it doesn't. Any way to fix this?
Thanks
I have that in my configuration :
(setq select-enable-primary nil)
(setq select-enable-clipboard t)
on my side it works for gnome-shell (I didn't try with unity)
This should use the system clipboard:
(defun copy-from-ubuntu (text &optional push)
(interactive)
(if (display-graphic-p)
(progn
(message "Yanked region to x-clipboard!")
(call-interactively 'clipboard-kill-ring-save)
)
(if (region-active-p)
(progn
(shell-command-on-region (region-beginning) (region-end) "xsel -i -b")
(message "Yanked region to clipboard!")
(deactivate-mark))
(message "No region active; can't yank to clipboard!")))
)
(defun paste-to-ubuntu ()
(interactive)
(if (display-graphic-p)
(progn
(clipboard-yank)
(message "graphics active")
)
(insert (shell-command-to-string "xsel -o -b"))
)
)
And then finally add:
(setq interprogram-cut-function 'copy-from-ubuntu)
(setq interprogram-paste-function 'paste-to-ubuntu)
You will also need to install xsel
$ sudo apt-get install xsel
C-c
copies andC-v
pastes, but in Emacs it'sM-w
andC-y
respectively. – Apr 21 '17 at 22:28