# HG changeset patch # User Chong Yidong # Date 1279130619 14400 # Node ID c9970d4bfd626b12f2de53eaaacb6a101ae3810d # Parent 4e6b8160da4b79fb67968e5cd4837fa8da275f1c Change clipboard/primary selection to X application standards. * lisp/menu-bar.el (menu-bar-enable-clipboard): Don't overwrite Cut/Copy/Paste menu bar items. * lisp/mouse.el: Bind mouse-2 to mouse-yank-primary. (mouse-drag-copy-region): Default to nil. * lisp/simple.el (select-active-regions): Default to t. (push-mark-command): Don't overwrite primary with empty string. * lisp/term/x-win.el (x-select-enable-clipboard): Default to t. (x-initialize-window-system): Don't overwrite Paste menu item. diff -r 4e6b8160da4b -r c9970d4bfd62 etc/NEWS --- a/etc/NEWS Wed Jul 14 12:41:40 2010 -0400 +++ b/etc/NEWS Wed Jul 14 14:03:39 2010 -0400 @@ -173,6 +173,20 @@ *** The option `mouse-region-delete-keys' has been deleted. +** Selection changes. + +The way Emacs interacts with the clipboard and primary selection, by +default, is now similar to other X applications. In particular, kill +and yank use the clipboard, in addition to the primary selection. + +*** `select-active-regions' now defaults to t. + +*** `x-select-enable-clipboard' now defaults to t. + +*** `mouse-drag-copy-region' now defaults to nil. + +*** `mouse-2' is now bound to `mouse-yank-primary'. + * Changes in Specialized Modes and Packages in Emacs 24.1 diff -r 4e6b8160da4b -r c9970d4bfd62 lisp/ChangeLog --- a/lisp/ChangeLog Wed Jul 14 12:41:40 2010 -0400 +++ b/lisp/ChangeLog Wed Jul 14 14:03:39 2010 -0400 @@ -1,3 +1,17 @@ +2010-07-14 Chong Yidong + + * term/x-win.el (x-select-enable-clipboard): Default to t. + (x-initialize-window-system): Don't overwrite Paste menu item. + + * simple.el (select-active-regions): Default to t. + (push-mark-command): Don't overwrite primary with empty string. + + * mouse.el: Bind mouse-2 to mouse-yank-primary. + (mouse-drag-copy-region): Default to nil. + + * menu-bar.el (menu-bar-enable-clipboard): Don't overwrite + Cut/Copy/Paste menu bar items. + 2010-07-13 Thierry Volpiatto Allow C-w when setting a bookmark in a Gnus Article buffer (Bug#5975). diff -r 4e6b8160da4b -r c9970d4bfd62 lisp/menu-bar.el --- a/lisp/menu-bar.el Wed Jul 14 12:41:40 2010 -0400 +++ b/lisp/menu-bar.el Wed Jul 14 14:03:39 2010 -0400 @@ -526,17 +526,6 @@ "Make CUT, PASTE and COPY (keys and menu bar items) use the clipboard. Do the same for the keys of the same name." (interactive) - ;; We can't use constant list structure here because it becomes pure, - ;; and because it gets modified with cache data. - (define-key menu-bar-edit-menu [paste] - (cons "Paste" (cons "Paste text from clipboard" 'clipboard-yank))) - (define-key menu-bar-edit-menu [copy] - (cons "Copy" (cons "Copy text in region to the clipboard" - 'clipboard-kill-ring-save))) - (define-key menu-bar-edit-menu [cut] - (cons "Cut" (cons "Delete text in region and copy it to the clipboard" - 'clipboard-kill-region))) - ;; These are Sun server keysyms for the Cut, Copy and Paste keys ;; (also for XFree86 on Sun keyboard): (define-key global-map [f20] 'clipboard-kill-region) diff -r 4e6b8160da4b -r c9970d4bfd62 lisp/mouse.el --- a/lisp/mouse.el Wed Jul 14 12:41:40 2010 -0400 +++ b/lisp/mouse.el Wed Jul 14 14:03:39 2010 -0400 @@ -41,7 +41,7 @@ :type 'boolean :group 'mouse) -(defcustom mouse-drag-copy-region t +(defcustom mouse-drag-copy-region nil "If non-nil, mouse drag copies region to kill-ring." :type 'boolean :version "22.1" @@ -2443,7 +2443,7 @@ (global-set-key [left-fringe mouse-1] 'mouse-set-point) (global-set-key [right-fringe mouse-1] 'mouse-set-point) -(global-set-key [mouse-2] 'mouse-yank-at-click) +(global-set-key [mouse-2] 'mouse-yank-primary) ;; Allow yanking also when the corresponding cursor is "in the fringe". (global-set-key [right-fringe mouse-2] 'mouse-yank-at-click) (global-set-key [left-fringe mouse-2] 'mouse-yank-at-click) diff -r 4e6b8160da4b -r c9970d4bfd62 lisp/simple.el --- a/lisp/simple.el Wed Jul 14 12:41:40 2010 -0400 +++ b/lisp/simple.el Wed Jul 14 14:03:39 2010 -0400 @@ -3666,7 +3666,7 @@ (marker-position (mark-marker)) (signal 'mark-inactive nil))) -(defcustom select-active-regions nil +(defcustom select-active-regions t "If non-nil, an active region automatically becomes the window selection." :type 'boolean :group 'killing @@ -3687,6 +3687,7 @@ mark-active (display-selections-p) (x-selection-owner-p 'PRIMARY) + (not (eq (region-beginning) (region-end))) (x-set-selection 'PRIMARY (buffer-substring-no-properties (region-beginning) (region-end)))) (if (and (null force) @@ -3819,6 +3820,8 @@ (push-mark nil nomsg t) (setq mark-active t) (run-hooks 'activate-mark-hook) + (and select-active-regions (display-selections-p) + (x-set-selection 'PRIMARY (current-buffer))) (unless nomsg (message "Mark activated"))))) diff -r 4e6b8160da4b -r c9970d4bfd62 lisp/term/x-win.el --- a/lisp/term/x-win.el Wed Jul 14 12:41:40 2010 -0400 +++ b/lisp/term/x-win.el Wed Jul 14 14:03:39 2010 -0400 @@ -1219,13 +1219,9 @@ "Max number of characters to put in the cut buffer. It is said that overlarge strings are slow to put into the cut buffer.") -(defcustom x-select-enable-clipboard nil +(defcustom x-select-enable-clipboard t "Non-nil means cutting and pasting uses the clipboard. -This is in addition to, but in preference to, the primary selection. - -On MS-Windows, this is non-nil by default, since Windows does not -support other types of selections. \(The primary selection that is -set by Emacs is not accessible to other programs on Windows.\)" +This is in addition to, but in preference to, the primary selection." :type 'boolean :group 'killing) @@ -1560,12 +1556,12 @@ ;; Enable CLIPBOARD copy/paste through menu bar commands. (menu-bar-enable-clipboard) - ;; Override Paste so it looks at CLIPBOARD first. - (define-key menu-bar-edit-menu [paste] - (append '(menu-item "Paste" x-clipboard-yank - :enable (not buffer-read-only) - :help "Paste (yank) text most recently cut/copied") - nil)) + ;; ;; Override Paste so it looks at CLIPBOARD first. + ;; (define-key menu-bar-edit-menu [paste] + ;; (append '(menu-item "Paste" x-clipboard-yank + ;; :enable (not buffer-read-only) + ;; :help "Paste (yank) text most recently cut/copied") + ;; nil)) (setq x-initialized t))