=== modified file 'lisp/mouse.el' --- lisp/mouse.el 2010-08-29 16:17:13 +0000 +++ lisp/mouse.el 2010-09-04 21:33:14 +0000 @@ -43,7 +43,11 @@ :group 'mouse) (defcustom mouse-drag-copy-region nil - "If non-nil, mouse drag copies region to kill-ring." + "If non-nil, copy to kill-ring upon mouse adjustments of the region. + +For consistency this affects both actual mouse drag operations and +`mouse-save-then-kill' (\\[mouse-save-then-kill]) operations that +change the region." :type 'boolean :version "24.1" :group 'mouse) @@ -1342,14 +1346,21 @@ If the region is inactive, activate it temporarily. Set mark at the original point, and move point to the position of CLICK. +If `mouse-drag-copy-region' is non-nil, also save the region +to the kill ring. If the region is already active, adjust it. Normally, do this by moving point or mark, whichever is closer, to CLICK. But if you have selected whole words or lines, move point or mark to the word or line boundary closest to CLICK instead. +If `mouse-drag-copy-region' is non-nil, also save the region +to the kill ring, replacing the previous kill corresponding +to the already active region. If this command is called a second consecutive time with the same -CLICK position, kill the region." +CLICK position, kill the region (or delete it +if `mouse-drag-copy-region' is non-nil - it will already +have been saved to the kill ring by the previous click.)" (interactive "e") (mouse-minibuffer-check click) (let* ((posn (event-start click)) @@ -1371,7 +1382,12 @@ ((and (eq last-command 'mouse-save-then-kill) (eq click-pt mouse-save-then-kill-posn) (eq window (selected-window))) - (kill-region (mark t) (point)) + (if mouse-drag-copy-region + ;; region already saved the previous click, + ;; don't make a duplicate entry, just delete + (delete-region (mark t) (point)) + (kill-region (mark t) (point))) + (setq deactivate-mark t) (setq mouse-selection-click-count 0) (setq mouse-save-then-kill-posn nil)) @@ -1394,6 +1410,9 @@ (goto-char (nth 1 range))) (setq deactivate-mark nil) (mouse-set-region-1) + (when mouse-drag-copy-region + ;; presumably region already copied to kill-ring once, so replace. + (kill-new (filter-buffer-substring (mark t) (point)) t)) ;; Arrange for a repeated mouse-3 to kill the region. (setq mouse-save-then-kill-posn click-pt))) @@ -1405,6 +1424,8 @@ (if before-scroll (goto-char before-scroll))) (exchange-point-and-mark) (mouse-set-region-1) + (when mouse-drag-copy-region + (kill-new (filter-buffer-substring (mark t) (point)))) (setq mouse-save-then-kill-posn click-pt)))))