changeset 6699:59e74bc34228

(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.
author Richard M. Stallman <rms@gnu.org>
date Wed, 06 Apr 1994 04:54:35 +0000
parents b107e54218fe
children db2292ce4894
files lisp/menu-bar.el
diffstat 1 files changed, 37 insertions(+), 0 deletions(-) [+]
line wrap: on
line diff
--- a/lisp/menu-bar.el	Wed Apr 06 04:51:37 1994 +0000
+++ b/lisp/menu-bar.el	Wed Apr 06 04:54:35 1994 +0000
@@ -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))