From mboxrd@z Thu Jan 1 00:00:00 1970 Path: main.gmane.org!not-for-mail From: "Jan D." Newsgroups: gmane.emacs.devel Subject: Change behaviour of Copy/Cut/Paste from the menu bar. Date: Tue, 20 Jan 2004 16:11:19 +0100 (CET) Sender: emacs-devel-bounces+emacs-devel=quimby.gnus.org@gnu.org Message-ID: <200401201604.i0KG4i7L001202@stubby.bodenonline.com> NNTP-Posting-Host: deer.gmane.org Mime-Version: 1.0 Content-Type: text/plain; charset=US-ASCII Content-Transfer-Encoding: 7bit X-Trace: sea.gmane.org 1074611640 30080 80.91.224.253 (20 Jan 2004 15:14:00 GMT) X-Complaints-To: usenet@sea.gmane.org NNTP-Posting-Date: Tue, 20 Jan 2004 15:14:00 +0000 (UTC) Original-X-From: emacs-devel-bounces+emacs-devel=quimby.gnus.org@gnu.org Tue Jan 20 16:13:51 2004 Return-path: Original-Received: from quimby.gnus.org ([80.91.224.244]) by deer.gmane.org with esmtp (Exim 3.35 #1 (Debian)) id 1AixZf-0007OU-00 for ; Tue, 20 Jan 2004 16:13:51 +0100 Original-Received: from monty-python.gnu.org ([199.232.76.173]) by quimby.gnus.org with esmtp (Exim 3.35 #1 (Debian)) id 1AixZf-0004fd-00 for ; Tue, 20 Jan 2004 16:13:51 +0100 Original-Received: from localhost ([127.0.0.1] helo=monty-python.gnu.org) by monty-python.gnu.org with esmtp (Exim 4.24) id 1AixZM-0002Dy-Hw for emacs-devel@quimby.gnus.org; Tue, 20 Jan 2004 10:13:32 -0500 Original-Received: from list by monty-python.gnu.org with tmda-scanned (Exim 4.24) id 1AixYq-0002D3-4q for emacs-devel@gnu.org; Tue, 20 Jan 2004 10:13:00 -0500 Original-Received: from mail by monty-python.gnu.org with spam-scanned (Exim 4.24) id 1AixYJ-00025g-9K for emacs-devel@gnu.org; Tue, 20 Jan 2004 10:12:58 -0500 Original-Received: from [213.115.192.53] (helo=mail2.norrnet.net) by monty-python.gnu.org with esmtp (Exim 4.24) id 1AixYI-00025W-LY for emacs-devel@gnu.org; Tue, 20 Jan 2004 10:12:26 -0500 Original-Received: from stubby.bodenonline.com (stubby.bodenonline.com [193.201.16.94]) by mail2.norrnet.net (BorderWare MXtreme Mail Firewall) with ESMTP id 0E06325D75 for ; Tue, 20 Jan 2004 16:09:21 +0100 (CET) Original-Received: from accessno42.bodenonline.com (accessno42.bodenonline.com [193.201.16.44]) by stubby.bodenonline.com (8.12.1/8.12.1) with ESMTP id i0KG4i7L001202 for ; Tue, 20 Jan 2004 17:04:45 +0100 Original-To: emacs-devel@gnu.org X-BeenThere: emacs-devel@gnu.org X-Mailman-Version: 2.1.2 Precedence: list List-Id: Emacs development discussions. List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: emacs-devel-bounces+emacs-devel=quimby.gnus.org@gnu.org Xref: main.gmane.org gmane.emacs.devel:19339 X-Report-Spam: http://spam.gmane.org/gmane.emacs.devel:19339 Hello As has been pointed out, Emacs does not "behave" w.r.t. the CLIPBOARD and other newer X applications. Basically, the guideline in http://freedesktop.org/Standards/clipboards-spec/clipboards.txt says: When selecting with the mouse -> Save to PRIMARY (Emacs does that). When using keys/menus (which in Emacs case would be just menus): Copy -> Save to CLIPBOARD Cut -> Save to CLIPBOARD Paste -> Paste from CLIPBOARD Now, if menu-bar-enable-clipboard is called we are almost there, except for the Paste thing. Emacs always pastes from the kill ring, even if there is a CLIPBOARD selection. So I suggest that we modify lisp/term/x-term.el as below. My question is if this is OK, and how does the other ports (W32, Mac) handle Paste from the menu? Is it always from the clipboard, or from the kill-ring? Thanks, Jan D. Index: lisp/term/x-win.el *** lisp/term/x-win.el.~1.166.~ 2003-09-01 17:45:36.000000000 +0200 --- lisp/term/x-win.el 2004-01-20 16:05:17.000000000 +0100 *************** *** 2385,2396 **** ;; generated from FONT. (create-fontset-from-ascii-font font resolved-name "startup")))) - ;; Sun expects the menu bar cut and paste commands to use the clipboard. - ;; This has ,? to match both on Sunos and on Solaris. - (if (string-match "Sun Microsystems,? Inc\\." - (x-server-vendor)) - (menu-bar-enable-clipboard)) - ;; Apply a geometry resource to the initial frame. Put it at the end ;; of the alist, so that anything specified on the command line takes ;; precedence. --- 2385,2390 ---- *************** *** 2456,2460 **** --- 2450,2470 ---- ;; Turn on support for mouse wheels. (mouse-wheel-mode 1) + ;; Enable CLIPBOARD copy/paste through menu bar commands. + (menu-bar-enable-clipboard) + + ;; Override Paste so it looks at CLIPBOARD first. + (defun x-clipboard-yank () + "Insert the clipboard contents, or the last stretch of killed text." + (interactive) + (let ((clipboard-text (x-get-selection 'CLIPBOARD)) + (x-select-enable-clipboard t)) + (if (and clipboard-text (> (length clipboard-text) 0)) + (kill-new clipboard-text)) + (yank))) + + (define-key menu-bar-edit-menu [paste] + (cons "Paste" (cons "Paste text from clipboard" 'x-clipboard-yank))) + ;;; arch-tag: f1501302-db8b-4d95-88e3-116697d89f78 ;;; x-win.el ends here