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: Re: Emacs (in terminal): keeping clipboard synchronized with the system global one? Date: Sun, 8 Mar 2009 11:05:28 +0100 Message-ID: <2bdf908c0903080305j13ec4cadga3fecae786082cc5@mail.gmail.com> References: <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: quoted-printable X-Trace: ger.gmane.org 1236506779 9096 80.91.229.12 (8 Mar 2009 10:06:19 GMT) X-Complaints-To: usenet@ger.gmane.org NNTP-Posting-Date: Sun, 8 Mar 2009 10:06:19 +0000 (UTC) To: help-gnu-emacs@gnu.org Original-X-From: help-gnu-emacs-bounces+geh-help-gnu-emacs=m.gmane.org@gnu.org Sun Mar 08 11:07:36 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 1LgFuw-0003G4-Hp for geh-help-gnu-emacs@m.gmane.org; Sun, 08 Mar 2009 11:07:34 +0100 Original-Received: from localhost ([127.0.0.1]:59343 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.43) id 1LgFta-0003W8-Tl for geh-help-gnu-emacs@m.gmane.org; Sun, 08 Mar 2009 06:06:10 -0400 Original-Received: from mailman by lists.gnu.org with tmda-scanned (Exim 4.43) id 1LgFt0-0003UD-RI for help-gnu-emacs@gnu.org; Sun, 08 Mar 2009 06:05:34 -0400 Original-Received: from exim by lists.gnu.org with spam-scanned (Exim 4.43) id 1LgFsx-0003PY-Kd for help-gnu-emacs@gnu.org; Sun, 08 Mar 2009 06:05:33 -0400 Original-Received: from [199.232.76.173] (port=54137 helo=monty-python.gnu.org) by lists.gnu.org with esmtp (Exim 4.43) id 1LgFsx-0003PA-En for help-gnu-emacs@gnu.org; Sun, 08 Mar 2009 06:05:31 -0400 Original-Received: from mail-fx0-f172.google.com ([209.85.220.172]:50928) by monty-python.gnu.org with esmtp (Exim 4.60) (envelope-from ) id 1LgFsw-00059i-Pm for help-gnu-emacs@gnu.org; Sun, 08 Mar 2009 06:05:31 -0400 Original-Received: by fxm20 with SMTP id 20so815511fxm.42 for ; Sun, 08 Mar 2009 03:05:28 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=gamma; h=domainkey-signature:mime-version:received:in-reply-to:references :date:message-id:subject:from:to:content-type :content-transfer-encoding; bh=kHBVkyW/SBuhQpNYMHCJkLEHTXuqgdr69Fr+mDntNw0=; b=bNcfCycocggXlwRdUN6/KMnXA4y5AjokUU6yA4oPJFbjeOqqPTOpTQjOCBbt0mXl0/ F6M7SfiOZp/8JmTjhfjufL/uSyDfb/BWMCuYyhINVUXENFmH42QGScDN2vzGFzoxjVj7 61LcPdY0msRes9KHJ9hqPU36toVwwyOTiauo4= DomainKey-Signature: a=rsa-sha1; c=nofws; d=gmail.com; s=gamma; h=mime-version:in-reply-to:references:date:message-id:subject:from:to :content-type:content-transfer-encoding; b=nY35wnt8T/QkBEmbqJUVq8rpfxi6dflQ9Slpt/8ShYu4+SBvkb+jsScbTUUrcqiRIj dSqAbPNJj9kTEKDmkDEA8I5a5SY351w191WmGQtkp6j5at2TEsmB5IuSe2RhiC1scYS6 gfj1lxpSBw1qKSlMV9Sm+o5MOJBLMMgQATvF4= Original-Received: by 10.86.92.7 with SMTP id p7mr3144760fgb.74.1236506728916; Sun, 08 Mar 2009 03:05:28 -0700 (PDT) In-Reply-To: <2bdf908c0903060433y7f99a928s4fb255ae4b48efaf@mail.gmail.com> 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:62753 Archived-At: On Fri, Mar 6, 2009 at 1:33 PM, Hugo Heden wrote: > 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: > =A0 (global-set-key "\C-w" 'clipboard-kill-region) > =A0 (global-set-key "\M-w" 'clipboard-kill-ring-save) > =A0 (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. I've fiddled with this a bit, and the following works well --- (global-set-key "\C-w" 'clipboard-kill-region) (global-set-key "\M-w" 'clipboard-kill-ring-save) (global-set-key "\C-y" 'clipboard-yank) (unless window-system (defun copy-region-to-xsel() ;;(with-current-buffer (current-buffer) (call-process-region (region-beginning) (region-end) "xsel" nil 0 nil "-p" "-i")) ;; ) (defun ext-kill-ring-save() (interactive) (copy-region-to-xsel) (kill-ring-save (region-beginning) (region-end))) (defun ext-kill-region() (interactive) (copy-region-to-xsel) (kill-region (region-beginning) (region-end))) (global-set-key "\M-w" 'ext-kill-ring-save) (global-set-key "\C-w" 'ext-kill-region)) --- although I would prefer to have the three first lines within an "if-then-clause" and the rest within an else clause, but I have not figured out how to do this, I get "Invalid function: (global-set-key ^W (quote clipboard-kill-region))" (if window-system ( (global-set-key "\C-w" 'clipboard-kill-region) (global-set-key "\M-w" 'clipboard-kill-ring-save) (global-set-key "\C-y" 'clipboard-yank) ) ( ... ) ) Sorry to be responding to myself, I just thought the above might be valuable for future reference. Thank for all the help! Best regards Hugo Heden