=== modified file 'lisp/mouse.el' --- lisp/mouse.el 2010-07-17 20:21:51 +0000 +++ lisp/mouse.el 2010-07-25 16:27:46 +0000 @@ -47,6 +47,16 @@ :version "24.1" :group 'mouse) +(defcustom mouse-yank-selection-only t + "If non-nil, mouse yank inserts the current selection only. + +If nil, then the text that is inserted is the same as that which +a keyboard `yank' would insert, which itself varies according to +`x-select-enable-primary' and `x-select-enable-clipboard'" + :type 'boolean + :version "24.1" + :group 'mouse) + (defcustom mouse-1-click-follows-link 450 "Non-nil means that clicking Mouse-1 on a link follows the link. @@ -1247,25 +1257,30 @@ (max (point) click-posn))))) (defun mouse-yank-at-click (click arg) - "Insert the last stretch of killed text at the position clicked on. + "Insert the last stretch of killed text at the position clicked on. Also move point to one end of the text thus inserted (normally the end), and set mark at the beginning. Prefix arguments are interpreted as with \\[yank]. +If `mouse-yank-selection-only' is non-nil, delegate click to +`mouse-yank-primary' (arg ignored in that case). If `mouse-yank-at-point' is non-nil, insert at point regardless of where you click. If `select-active-regions' is non-nil, the mark is deactivated before inserting the text." (interactive "e\nP") ;; Give temporary modes such as isearch a chance to turn off. - (run-hooks 'mouse-leave-buffer-hook) - (when select-active-regions - ;; Without this, confusing things happen upon e.g. inserting into - ;; the middle of an active region. - (deactivate-mark)) - (or mouse-yank-at-point (mouse-set-point click)) - (setq this-command 'yank) - (setq mouse-selection-click-count 0) - (yank arg)) + (if mouse-yank-selection-only + (mouse-yank-primary click) + (progn + (run-hooks 'mouse-leave-buffer-hook) + (when select-active-regions + ;; Without this, confusing things happen upon e.g. inserting into + ;; the middle of an active region. + (deactivate-mark)) + (or mouse-yank-at-point (mouse-set-point click)) + (setq this-command 'yank) + (setq mouse-selection-click-count 0) + (yank arg)))) (defun mouse-yank-primary (click) "Insert the primary selection at the position clicked on. @@ -2441,7 +2456,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-primary) +(global-set-key [mouse-2] 'mouse-yank-at-click) ;; 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)