unofficial mirror of emacs-devel@gnu.org 
 help / color / mirror / code / Atom feed
* Change behaviour of Copy/Cut/Paste from the menu bar.
@ 2004-01-20 15:11 Jan D.
  2004-01-20 16:10 ` Jason Rumney
  2004-01-21  9:21 ` Richard Stallman
  0 siblings, 2 replies; 5+ messages in thread
From: Jan D. @ 2004-01-20 15:11 UTC (permalink / raw)


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

^ permalink raw reply	[flat|nested] 5+ messages in thread

end of thread, other threads:[~2004-01-21  9:30 UTC | newest]

Thread overview: 5+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2004-01-20 15:11 Change behaviour of Copy/Cut/Paste from the menu bar Jan D.
2004-01-20 16:10 ` Jason Rumney
2004-01-20 22:32   ` Jan D.
2004-01-21  9:21 ` Richard Stallman
2004-01-21  9:30   ` Jan D.

Code repositories for project(s) associated with this public inbox

	https://git.savannah.gnu.org/cgit/emacs.git

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).