diff options
| author | David De La Harpe Golden | 2010-09-05 23:40:57 +0100 |
|---|---|---|
| committer | David De La Harpe Golden | 2010-09-05 23:40:57 +0100 |
| commit | 93d68d4f021e938f6ee16c1cfd7e581681741f1d (patch) | |
| tree | 8d9c3b2be76576ab77020709ecad3886f59f97cf | |
| parent | 8d76af4ad04f4dd45cb89acef46091c68b7548da (diff) | |
| download | emacs-93d68d4f021e938f6ee16c1cfd7e581681741f1d.tar.gz emacs-93d68d4f021e938f6ee16c1cfd7e581681741f1d.zip | |
Respect mouse-drag-copy-region upon mouse-3 region adjustment.
* mouse.el (mouse-save-then-kill): Save region to kill-ring when
mouse-drag-copy-region is non-nil (Bug#6956).
| -rw-r--r-- | lisp/ChangeLog | 5 | ||||
| -rw-r--r-- | lisp/mouse.el | 23 |
2 files changed, 25 insertions, 3 deletions
diff --git a/lisp/ChangeLog b/lisp/ChangeLog index 81061db8759..63ea25d86f4 100644 --- a/lisp/ChangeLog +++ b/lisp/ChangeLog | |||
| @@ -1,3 +1,8 @@ | |||
| 1 | 2010-09-05 David De La Harpe Golden <david@harpegolden.net> | ||
| 2 | |||
| 3 | * mouse.el (mouse-save-then-kill): Save region to kill-ring | ||
| 4 | when mouse-drag-copy-region is non-nil (Bug#6956). | ||
| 5 | |||
| 1 | 2010-09-05 Chong Yidong <cyd@stupidchicken.com> | 6 | 2010-09-05 Chong Yidong <cyd@stupidchicken.com> |
| 2 | 7 | ||
| 3 | * dired.el (dired-ls-sorting-switches, dired-sort-by-name-regexp): | 8 | * dired.el (dired-ls-sorting-switches, dired-sort-by-name-regexp): |
diff --git a/lisp/mouse.el b/lisp/mouse.el index 01f96e1ef86..02ce48787e7 100644 --- a/lisp/mouse.el +++ b/lisp/mouse.el | |||
| @@ -43,7 +43,10 @@ | |||
| 43 | :group 'mouse) | 43 | :group 'mouse) |
| 44 | 44 | ||
| 45 | (defcustom mouse-drag-copy-region nil | 45 | (defcustom mouse-drag-copy-region nil |
| 46 | "If non-nil, mouse drag copies region to kill-ring." | 46 | "If non-nil, copy to kill-ring upon mouse adjustments of the region. |
| 47 | |||
| 48 | This affects `mouse-save-then-kill' (\\[mouse-save-then-kill]) in | ||
| 49 | addition to mouse drags." | ||
| 47 | :type 'boolean | 50 | :type 'boolean |
| 48 | :version "24.1" | 51 | :version "24.1" |
| 49 | :group 'mouse) | 52 | :group 'mouse) |
| @@ -1348,8 +1351,13 @@ moving point or mark, whichever is closer, to CLICK. But if you | |||
| 1348 | have selected whole words or lines, move point or mark to the | 1351 | have selected whole words or lines, move point or mark to the |
| 1349 | word or line boundary closest to CLICK instead. | 1352 | word or line boundary closest to CLICK instead. |
| 1350 | 1353 | ||
| 1354 | If `mouse-drag-copy-region' is non-nil, this command also saves the | ||
| 1355 | new region to the kill ring (replacing the previous kill if the | ||
| 1356 | previous region was just saved to the kill ring). | ||
| 1357 | |||
| 1351 | If this command is called a second consecutive time with the same | 1358 | If this command is called a second consecutive time with the same |
| 1352 | CLICK position, kill the region." | 1359 | CLICK position, kill the region (or delete it |
| 1360 | if `mouse-drag-copy-region' is non-nil)" | ||
| 1353 | (interactive "e") | 1361 | (interactive "e") |
| 1354 | (mouse-minibuffer-check click) | 1362 | (mouse-minibuffer-check click) |
| 1355 | (let* ((posn (event-start click)) | 1363 | (let* ((posn (event-start click)) |
| @@ -1371,7 +1379,11 @@ CLICK position, kill the region." | |||
| 1371 | ((and (eq last-command 'mouse-save-then-kill) | 1379 | ((and (eq last-command 'mouse-save-then-kill) |
| 1372 | (eq click-pt mouse-save-then-kill-posn) | 1380 | (eq click-pt mouse-save-then-kill-posn) |
| 1373 | (eq window (selected-window))) | 1381 | (eq window (selected-window))) |
| 1374 | (kill-region (mark t) (point)) | 1382 | (if mouse-drag-copy-region |
| 1383 | ;; Region already saved in the previous click; | ||
| 1384 | ;; don't make a duplicate entry, just delete. | ||
| 1385 | (delete-region (mark t) (point)) | ||
| 1386 | (kill-region (mark t) (point))) | ||
| 1375 | (setq mouse-selection-click-count 0) | 1387 | (setq mouse-selection-click-count 0) |
| 1376 | (setq mouse-save-then-kill-posn nil)) | 1388 | (setq mouse-save-then-kill-posn nil)) |
| 1377 | 1389 | ||
| @@ -1394,6 +1406,9 @@ CLICK position, kill the region." | |||
| 1394 | (goto-char (nth 1 range))) | 1406 | (goto-char (nth 1 range))) |
| 1395 | (setq deactivate-mark nil) | 1407 | (setq deactivate-mark nil) |
| 1396 | (mouse-set-region-1) | 1408 | (mouse-set-region-1) |
| 1409 | (when mouse-drag-copy-region | ||
| 1410 | ;; Region already copied to kill-ring once, so replace. | ||
| 1411 | (kill-new (filter-buffer-substring (mark t) (point)) t)) | ||
| 1397 | ;; Arrange for a repeated mouse-3 to kill the region. | 1412 | ;; Arrange for a repeated mouse-3 to kill the region. |
| 1398 | (setq mouse-save-then-kill-posn click-pt))) | 1413 | (setq mouse-save-then-kill-posn click-pt))) |
| 1399 | 1414 | ||
| @@ -1405,6 +1420,8 @@ CLICK position, kill the region." | |||
| 1405 | (if before-scroll (goto-char before-scroll))) | 1420 | (if before-scroll (goto-char before-scroll))) |
| 1406 | (exchange-point-and-mark) | 1421 | (exchange-point-and-mark) |
| 1407 | (mouse-set-region-1) | 1422 | (mouse-set-region-1) |
| 1423 | (when mouse-drag-copy-region | ||
| 1424 | (kill-new (filter-buffer-substring (mark t) (point)))) | ||
| 1408 | (setq mouse-save-then-kill-posn click-pt))))) | 1425 | (setq mouse-save-then-kill-posn click-pt))))) |
| 1409 | 1426 | ||
| 1410 | 1427 | ||