=== modified file 'lisp/mouse.el' --- lisp/mouse.el 2011-06-01 15:34:41 +0000 +++ lisp/mouse.el 2011-07-01 04:54:25 +0000 @@ -50,6 +50,16 @@ :version "24.1" :group 'mouse) + +(defcustom mouse-yank-from-kill-ring nil + "If non-nil, `mouse-yank-at-click' yanks the last killed text. + +If nil, only the most recently selected text is inserted." + :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. @@ -1240,7 +1250,21 @@ (kill-region (min (point) click-posn) (max (point) click-posn))))) + (defun mouse-yank-at-click (click arg) + "Insert the most recently selected text at the position clicked on. + +If `mouse-yank-from-kill-ring` is non-nil, instead insert the last +stretch of killed text at the position clicked on. + +If `mouse-yank-at-point' is non-nil, insert at point +regardless of where you click." + (interactive "e\nP") + (if mouse-yank-from-kill-ring + (mouse-yank-last-kill click arg) + (mouse-yank-primary click))) + +(defun mouse-yank-last-kill (click arg) "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. @@ -2096,7 +2120,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)