From f9cf0be27289620ea98cbd61c1d80a07b04d1de8 Mon Sep 17 00:00:00 2001 From: "Richard M. Stallman" Date: Wed, 6 Apr 1994 04:54:35 +0000 Subject: [PATCH] (clipboard-yank, clipboard-kill-ring-save) (clipboard-kill-region): New functions. Give them menu-enable properties and bind the PASTE, COPY and CUT keys. (menu-bar-enable-clipboard): New function. --- lisp/menu-bar.el | 37 +++++++++++++++++++++++++++++++++++++ 1 file changed, 37 insertions(+) diff --git a/lisp/menu-bar.el b/lisp/menu-bar.el index ea6221ca710..8b51ba65119 100644 --- a/lisp/menu-bar.el +++ b/lisp/menu-bar.el @@ -89,6 +89,43 @@ (autoload 'ispell-menu-map "ispell" nil t 'keymap) +;; These are alternative definitions for the cut, paste and copy +;; menu items. Use them if your system expects these to use the clipboard + +(define-key global-map [cut] 'clipboard-kill-region) +(define-key global-map [copy] 'clipboard-kill-ring-save) +(define-key global-map [paste] 'clipboard-yank) + +(put 'clipboard-kill-region 'menu-enable 'mark-active) +(put 'clipboard-kill-ring-save 'menu-enable 'mark-active) +(put 'clipboard-yank 'menu-enable + '(or (x-selection-exists-p) (x-selection-exists-p 'CLIPBOARD))) + +(defun clipboard-yank () + "Reinsert the last stretch of killed text, or the clipboard contents." + (interactive) + (let ((x-select-enable-clipboard t)) + (yank))) + +(defun clipboard-kill-ring-save (beg end) + "Copy region to kill ring, and save in the X clipboard." + (interactive "r") + (let ((x-select-enable-clipboard t)) + (kill-ring-save beg end))) + +(defun clipboard-kill-region (beg end) + "Kill the region, and save it in the X clipboard." + (interactive "r") + (let ((x-select-enable-clipboard t)) + (kill-region beg end))) + +(defun menu-bar-enable-clipboard () + "Make the menu bar CUT, PASTE and COPY items use the clipboard." + (interactive) + (define-key menu-bar-edit-menu [paste] '("Paste" . clipboard-yank)) + (define-key menu-bar-edit-menu [copy] '("Copy" . clipboard-kill-ring-save)) + (define-key menu-bar-edit-menu [cut] '("Cut" . clipboard-kill-region))) + (define-key menu-bar-help-menu [emacs-tutorial] '("Emacs Tutorial" . help-with-tutorial)) (define-key menu-bar-help-menu [man] '("Man..." . manual-entry)) -- 2.39.5