[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
master e02ebe9137: Allow appending to the kill ring with mouse selection
From: |
Lars Ingebrigtsen |
Subject: |
master e02ebe9137: Allow appending to the kill ring with mouse selections |
Date: |
Sun, 19 Jun 2022 19:00:12 -0400 (EDT) |
branch: master
commit e02ebe91379459efc9c5fc7bb9de38fcf0e59cd7
Author: Lars Ingebrigtsen <larsi@gnus.org>
Commit: Lars Ingebrigtsen <larsi@gnus.org>
Allow appending to the kill ring with mouse selections
* lisp/bindings.el (ignore-preserving-kill-region): New function.
(global-map): Use it.
* lisp/mouse.el (mouse-set-region, mouse-drag-region)
(mouse-drag-track): Allow appending to kill ring with mouse
selections (bug#32747).
---
lisp/bindings.el | 10 +++++++++-
lisp/mouse.el | 7 +++++--
2 files changed, 14 insertions(+), 3 deletions(-)
diff --git a/lisp/bindings.el b/lisp/bindings.el
index ed1325e326..c67a104b4c 100644
--- a/lisp/bindings.el
+++ b/lisp/bindings.el
@@ -1339,7 +1339,15 @@ if `inhibit-field-text-motion' is non-nil."
;; can use S-tab instead to access that binding.
(define-key function-key-map [S-tab] [backtab])
-(define-key global-map [mouse-movement] 'ignore)
+(defun ignore-preserving-kill-region (&rest _)
+ "Like `ignore', but don't overwrite `last-event' if it's `kill-region'."
+ (declare (completion ignore))
+ (interactive)
+ (when (eq last-command 'kill-region)
+ (setq this-command 'kill-region))
+ nil)
+
+(define-key global-map [mouse-movement] #'ignore-preserving-kill-region)
(define-key global-map "\C-t" 'transpose-chars)
(define-key esc-map "t" 'transpose-words)
diff --git a/lisp/mouse.el b/lisp/mouse.el
index 14cb20c234..82c8a14693 100644
--- a/lisp/mouse.el
+++ b/lisp/mouse.el
@@ -1439,7 +1439,8 @@ command alters the kill ring or not."
;; Don't set this-command to `kill-region', so a following
;; C-w won't double the text in the kill ring. Ignore
;; `last-command' so we don't append to a preceding kill.
- (let (this-command last-command deactivate-mark)
+ (let ((last-command last-command)
+ this-command deactivate-mark)
(copy-region-as-kill beg end)))
(if (numberp beg) (goto-char beg))
;; On a text terminal, bounce the cursor.
@@ -1542,6 +1543,7 @@ is dragged over to."
(mouse-drag-and-drop-region start-event)
;; Give temporary modes such as isearch a chance to turn off.
(run-hooks 'mouse-leave-buffer-hook)
+ (ignore-preserving-kill-region)
(mouse-drag-track start-event)))
;; Inhibit the region-confinement when undoing mouse-drag-region
@@ -1751,7 +1753,8 @@ The region will be defined with mark and point."
nil start-point))
((>= mouse-row bottom)
(mouse-scroll-subr start-window (1+ (- mouse-row
bottom))
- nil start-point))))))))
+ nil start-point))))))
+ (ignore-preserving-kill-region)))
map)
t (lambda ()
(funcall cleanup)
[Prev in Thread] |
Current Thread |
[Next in Thread] |
- master e02ebe9137: Allow appending to the kill ring with mouse selections,
Lars Ingebrigtsen <=