Commit f9d71b42 authored by Chong Yidong's avatar Chong Yidong
Browse files

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.
parent 8f2eaa8a
...@@ -173,6 +173,20 @@ should use delete-char with a negative argument instead. ...@@ -173,6 +173,20 @@ should use delete-char with a negative argument instead.
*** The option `mouse-region-delete-keys' has been deleted. *** 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 * Changes in Specialized Modes and Packages in Emacs 24.1
......
2010-07-14 Chong Yidong <cyd@stupidchicken.com>
* 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 <thierry.volpiatto@gmail.com> 2010-07-13 Thierry Volpiatto <thierry.volpiatto@gmail.com>
   
Allow C-w when setting a bookmark in a Gnus Article buffer (Bug#5975). Allow C-w when setting a bookmark in a Gnus Article buffer (Bug#5975).
......
...@@ -526,17 +526,6 @@ ...@@ -526,17 +526,6 @@
"Make CUT, PASTE and COPY (keys and menu bar items) use the clipboard. "Make CUT, PASTE and COPY (keys and menu bar items) use the clipboard.
Do the same for the keys of the same name." Do the same for the keys of the same name."
(interactive) (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 ;; These are Sun server keysyms for the Cut, Copy and Paste keys
;; (also for XFree86 on Sun keyboard): ;; (also for XFree86 on Sun keyboard):
(define-key global-map [f20] 'clipboard-kill-region) (define-key global-map [f20] 'clipboard-kill-region)
......
...@@ -41,7 +41,7 @@ ...@@ -41,7 +41,7 @@
:type 'boolean :type 'boolean
:group 'mouse) :group 'mouse)
(defcustom mouse-drag-copy-region t (defcustom mouse-drag-copy-region nil
"If non-nil, mouse drag copies region to kill-ring." "If non-nil, mouse drag copies region to kill-ring."
:type 'boolean :type 'boolean
:version "22.1" :version "22.1"
...@@ -2443,7 +2443,7 @@ choose a font." ...@@ -2443,7 +2443,7 @@ choose a font."
(global-set-key [left-fringe mouse-1] 'mouse-set-point) (global-set-key [left-fringe mouse-1] 'mouse-set-point)
(global-set-key [right-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". ;; 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 [right-fringe mouse-2] 'mouse-yank-at-click)
(global-set-key [left-fringe mouse-2] 'mouse-yank-at-click) (global-set-key [left-fringe mouse-2] 'mouse-yank-at-click)
......
...@@ -3666,7 +3666,7 @@ a mistake; see the documentation of `set-mark'." ...@@ -3666,7 +3666,7 @@ a mistake; see the documentation of `set-mark'."
(marker-position (mark-marker)) (marker-position (mark-marker))
(signal 'mark-inactive nil))) (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." "If non-nil, an active region automatically becomes the window selection."
:type 'boolean :type 'boolean
:group 'killing :group 'killing
...@@ -3687,6 +3687,7 @@ This function also runs `deactivate-mark-hook'." ...@@ -3687,6 +3687,7 @@ This function also runs `deactivate-mark-hook'."
mark-active mark-active
(display-selections-p) (display-selections-p)
(x-selection-owner-p 'PRIMARY) (x-selection-owner-p 'PRIMARY)
(not (eq (region-beginning) (region-end)))
(x-set-selection 'PRIMARY (buffer-substring-no-properties (x-set-selection 'PRIMARY (buffer-substring-no-properties
(region-beginning) (region-end)))) (region-beginning) (region-end))))
(if (and (null force) (if (and (null force)
...@@ -3819,6 +3820,8 @@ Display `Mark set' unless the optional second arg NOMSG is non-nil." ...@@ -3819,6 +3820,8 @@ Display `Mark set' unless the optional second arg NOMSG is non-nil."
(push-mark nil nomsg t) (push-mark nil nomsg t)
(setq mark-active t) (setq mark-active t)
(run-hooks 'activate-mark-hook) (run-hooks 'activate-mark-hook)
(and select-active-regions (display-selections-p)
(x-set-selection 'PRIMARY (current-buffer)))
(unless nomsg (unless nomsg
(message "Mark activated"))))) (message "Mark activated")))))
......
...@@ -1219,13 +1219,9 @@ This is the actual text stored in the X cut buffer.") ...@@ -1219,13 +1219,9 @@ This is the actual text stored in the X cut buffer.")
"Max number of characters to put in the cut buffer. "Max number of characters to put in the cut buffer.
It is said that overlarge strings are slow to put into 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. "Non-nil means cutting and pasting uses the clipboard.
This is in addition to, but in preference to, the primary selection. 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.\)"
:type 'boolean :type 'boolean
:group 'killing) :group 'killing)
...@@ -1560,12 +1556,12 @@ The value nil is the same as this list: ...@@ -1560,12 +1556,12 @@ The value nil is the same as this list:
;; Enable CLIPBOARD copy/paste through menu bar commands. ;; Enable CLIPBOARD copy/paste through menu bar commands.
(menu-bar-enable-clipboard) (menu-bar-enable-clipboard)
;; Override Paste so it looks at CLIPBOARD first. ;; ;; Override Paste so it looks at CLIPBOARD first.
(define-key menu-bar-edit-menu [paste] ;; (define-key menu-bar-edit-menu [paste]
(append '(menu-item "Paste" x-clipboard-yank ;; (append '(menu-item "Paste" x-clipboard-yank
:enable (not buffer-read-only) ;; :enable (not buffer-read-only)
:help "Paste (yank) text most recently cut/copied") ;; :help "Paste (yank) text most recently cut/copied")
nil)) ;; nil))
(setq x-initialized t)) (setq x-initialized t))
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment