Commit 33d79bad authored by Richard M. Stallman's avatar Richard M. Stallman
Browse files

(mouse-show-mark): Detect loss of selection

while we are showing it highlighted.
parent a8abaf83
...@@ -743,22 +743,32 @@ If DIR is positive skip forward; if negative, skip backward." ...@@ -743,22 +743,32 @@ If DIR is positive skip forward; if negative, skip backward."
(if window-system (if window-system
(let ((inhibit-quit t) (let ((inhibit-quit t)
(echo-keystrokes 0) (echo-keystrokes 0)
event events key) event events key ignore
x-lost-selection-hooks)
(add-hook 'x-lost-selection-hooks
'(lambda (seltype)
(if (eq seltype 'PRIMARY)
(progn (setq ignore t)
(throw 'mouse-show-mark t)))))
(move-overlay mouse-drag-overlay (point) (mark t)) (move-overlay mouse-drag-overlay (point) (mark t))
(while (progn (setq event (read-event)) (catch 'mouse-show-mark
(setq events (append events (list event))) (while (progn (setq event (read-event))
(setq key (apply 'vector events)) (setq events (append events (list event)))
(and (memq 'down (event-modifiers event)) (setq key (apply 'vector events))
(not (key-binding key)) (and (memq 'down (event-modifiers event))
(not (member key mouse-region-delete-keys)) (not (key-binding key))
(not (mouse-undouble-last-event events))))) (not (member key mouse-region-delete-keys))
;; For certain special keys, delete the region. (not (mouse-undouble-last-event events))))))
(if (member key mouse-region-delete-keys) ;; If we lost the selection, just turn off the highlighting.
(delete-region (overlay-start mouse-drag-overlay) (if ignore
(overlay-end mouse-drag-overlay)) nil
;; Otherwise, unread the key so it gets executed normally. ;; For certain special keys, delete the region.
(setq unread-command-events (if (member key mouse-region-delete-keys)
(nconc events unread-command-events))) (delete-region (overlay-start mouse-drag-overlay)
(overlay-end mouse-drag-overlay))
;; Otherwise, unread the key so it gets executed normally.
(setq unread-command-events
(nconc events unread-command-events))))
(setq quit-flag nil) (setq quit-flag nil)
(delete-overlay mouse-drag-overlay)) (delete-overlay mouse-drag-overlay))
(save-excursion (save-excursion
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment