From mboxrd@z Thu Jan 1 00:00:00 1970 Path: news.gmane.org!not-for-mail From: Hugo Heden Newsgroups: gmane.emacs.help Subject: Emacs (in terminal): keeping clipboard synchronized with the system global one? Date: Fri, 6 Mar 2009 13:33:52 +0100 Message-ID: <2bdf908c0903060433y7f99a928s4fb255ae4b48efaf@mail.gmail.com> NNTP-Posting-Host: lo.gmane.org Mime-Version: 1.0 Content-Type: text/plain; charset=ISO-8859-1 Content-Transfer-Encoding: 7bit X-Trace: ger.gmane.org 1236342878 22064 80.91.229.12 (6 Mar 2009 12:34:38 GMT) X-Complaints-To: usenet@ger.gmane.org NNTP-Posting-Date: Fri, 6 Mar 2009 12:34:38 +0000 (UTC) To: help-gnu-emacs@gnu.org Original-X-From: help-gnu-emacs-bounces+geh-help-gnu-emacs=m.gmane.org@gnu.org Fri Mar 06 13:35:54 2009 Return-path: Envelope-to: geh-help-gnu-emacs@m.gmane.org Original-Received: from lists.gnu.org ([199.232.76.165]) by lo.gmane.org with esmtp (Exim 4.50) id 1LfZHN-0000SY-Ol for geh-help-gnu-emacs@m.gmane.org; Fri, 06 Mar 2009 13:35:54 +0100 Original-Received: from localhost ([127.0.0.1]:42395 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.43) id 1LfZG2-00029d-Gr for geh-help-gnu-emacs@m.gmane.org; Fri, 06 Mar 2009 07:34:30 -0500 Original-Received: from mailman by lists.gnu.org with tmda-scanned (Exim 4.43) id 1LfZFV-000298-61 for help-gnu-emacs@gnu.org; Fri, 06 Mar 2009 07:33:57 -0500 Original-Received: from exim by lists.gnu.org with spam-scanned (Exim 4.43) id 1LfZFU-00028w-3K for help-gnu-emacs@gnu.org; Fri, 06 Mar 2009 07:33:56 -0500 Original-Received: from [199.232.76.173] (port=49781 helo=monty-python.gnu.org) by lists.gnu.org with esmtp (Exim 4.43) id 1LfZFT-00028t-UB for help-gnu-emacs@gnu.org; Fri, 06 Mar 2009 07:33:55 -0500 Original-Received: from fg-out-1718.google.com ([72.14.220.156]:61944) by monty-python.gnu.org with esmtp (Exim 4.60) (envelope-from ) id 1LfZFT-0002MP-9O for help-gnu-emacs@gnu.org; Fri, 06 Mar 2009 07:33:55 -0500 Original-Received: by fg-out-1718.google.com with SMTP id l27so529241fgb.30 for ; Fri, 06 Mar 2009 04:33:52 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=gamma; h=domainkey-signature:mime-version:received:date:message-id:subject :from:to:content-type:content-transfer-encoding; bh=FuoYzaTf/G6qTGwRm7nVaFugxuk2ju40ZOrJnzXMF7E=; b=lTdz215amC5dkW7BPSFZszuzyI24kBGpg5lHrhK07c79Xx0xXneSxcu3UTxACOljKg +cUOZW9UyvVAXMyBvL3NJJvTWjdE9YdWNjL3ObU/ngBrhTPmwc3DpEDReD9fyr22ZyfW Ew94Nxanp4J7ZywyzRmjdEnDhhB2d/6FxaLRQ= DomainKey-Signature: a=rsa-sha1; c=nofws; d=gmail.com; s=gamma; h=mime-version:date:message-id:subject:from:to:content-type :content-transfer-encoding; b=XHfJhKXhYg429ot+oSWzluNWvr9FVyUS42ZdyZPq4IrrywodSAR3LQutSdMIy3tAj+ 6ZupATwNfgJ4/c+dcXIwaJDK1wpHPfxxKZWOXY24JybFEJUQjZKLazhJhwDn5ebdCRH8 MRNuIRvX1D3t6dHCMay/kXDVWr1Dc4tUEI9pE= Original-Received: by 10.86.91.3 with SMTP id o3mr1819950fgb.17.1236342832082; Fri, 06 Mar 2009 04:33:52 -0800 (PST) X-detected-operating-system: by monty-python.gnu.org: GNU/Linux 2.6 (newer, 2) X-BeenThere: help-gnu-emacs@gnu.org X-Mailman-Version: 2.1.5 Precedence: list List-Id: Users list for the GNU Emacs text editor List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Original-Sender: help-gnu-emacs-bounces+geh-help-gnu-emacs=m.gmane.org@gnu.org Errors-To: help-gnu-emacs-bounces+geh-help-gnu-emacs=m.gmane.org@gnu.org Xref: news.gmane.org gmane.emacs.help:62672 Archived-At: Good day all, When running emacs in a terminal, I have problems synchronizing the emacs-clipboard with the system clipboard (or the "primary selection", it doesn't really matter) When using a regular x-window for emacs, the following works well: ;; emacs.d: (global-set-key "\C-w" 'clipboard-kill-region) (global-set-key "\M-w" 'clipboard-kill-ring-save) (global-set-key "\C-y" 'clipboard-yank) *But* this has no effect when running emacs within a *terminal*. Instead, one could use an external tool, "xsel"[1] for keeping the buffers synchronized. This works well[2]: ;; emacs.d: (defun copy-to-x-clipboard () (interactive) (with-current-buffer (current-buffer) (call-process-region (region-beginning) (region-end) "xsel" nil 0 nil "-p" "-i"))) (global-set-key "\M-w" 'copy-to-x-clipboard) Now, I would like to refine this so that M-w is bound to "copy-to-x-clipboard" whenever emacs is run within a terminal, and bound to 'clipboard-kill-ring-save when emacs is running within a normal x-window... or something like that. Any suggestions? How do you people resolve this? Best regards Hugo Heden -- I am using Ubuntu GNU/Linux 8.10 with $ emacs-snapshot --version GNU Emacs 23.0.60.1 [1] http://www.vergenet.net/~conrad/software/xsel/ [2] http://shreevatsa.wordpress.com/2006/10/22/emacs-copypaste-and-x/#comment-5806