comparison lisp/mouse.el @ 15321:1aeaf1224f0b

(mouse-show-mark): Use temporary highlighting if possible instead of a pause. (mouse-drag-region): Use mouse-show-mark to do temp highlighting. (mouse-save-then-kill): Call mouse-show-mark for a new selection if we have a window system.
author Richard M. Stallman <rms@gnu.org>
date Mon, 03 Jun 1996 17:21:03 +0000
parents a00021443533
children fc94c6fcee69
comparison
equal deleted inserted replaced
15320:b76f57d4320b 15321:1aeaf1224f0b
576 (overlay-end mouse-drag-overlay))) 576 (overlay-end mouse-drag-overlay)))
577 (let (last-command this-command) 577 (let (last-command this-command)
578 (push-mark (overlay-start mouse-drag-overlay) t t) 578 (push-mark (overlay-start mouse-drag-overlay) t t)
579 (goto-char (overlay-end mouse-drag-overlay)) 579 (goto-char (overlay-end mouse-drag-overlay))
580 (copy-region-as-kill (point) (mark t)) 580 (copy-region-as-kill (point) (mark t))
581 (let ((inhibit-quit t)) 581 (mouse-show-mark)
582 (setq unread-command-events 582 (mouse-set-region-1))
583 (cons (read-event) unread-command-events))
584 (setq quit-flag nil))
585 (mouse-set-region-1)
586 (delete-overlay mouse-drag-overlay))
587 (goto-char (overlay-end mouse-drag-overlay)) 583 (goto-char (overlay-end mouse-drag-overlay))
588 (setq this-command 'mouse-set-point) 584 (setq this-command 'mouse-set-point)
589 (delete-overlay mouse-drag-overlay)))) 585 (delete-overlay mouse-drag-overlay))))
590 (delete-overlay mouse-drag-overlay))))) 586 (delete-overlay mouse-drag-overlay)))))
591 587
671 (push-mark (posn-point posn) t t)))) 667 (push-mark (posn-point posn) t t))))
672 668
673 ;; Momentarily show where the mark is, if highlighting doesn't show it. 669 ;; Momentarily show where the mark is, if highlighting doesn't show it.
674 (defun mouse-show-mark () 670 (defun mouse-show-mark ()
675 (or transient-mark-mode 671 (or transient-mark-mode
676 (save-excursion 672 (if window-system
677 (goto-char (mark t)) 673 (let ((inhibit-quit t)
678 (sit-for 1)))) 674 (echo-keystrokes 0)
675 event events)
676 (move-overlay mouse-drag-overlay (point) (mark t))
677 (while (progn (setq event (read-event))
678 (setq events (append events (list event)))
679 (and (memq 'down (event-modifiers event))
680 (not (key-binding (apply 'vector events))))))
681 (setq unread-command-events
682 (nconc events unread-command-events))
683 (setq quit-flag nil)
684 (delete-overlay mouse-drag-overlay))
685 (save-excursion
686 (goto-char (mark t))
687 (sit-for 1)))))
679 688
680 (defun mouse-set-mark (click) 689 (defun mouse-set-mark (click)
681 "Set mark at the position clicked on with the mouse. 690 "Set mark at the position clicked on with the mouse.
682 Display cursor at that position for a second. 691 Display cursor at that position for a second.
683 This must be bound to a mouse click." 692 This must be bound to a mouse click."
831 ;; mouse-save-then-kill, delete the text from the buffer. 840 ;; mouse-save-then-kill, delete the text from the buffer.
832 (progn 841 (progn
833 (mouse-save-then-kill-delete-region (point) (mark)) 842 (mouse-save-then-kill-delete-region (point) (mark))
834 ;; After we kill, another click counts as "the first time". 843 ;; After we kill, another click counts as "the first time".
835 (setq mouse-save-then-kill-posn nil)) 844 (setq mouse-save-then-kill-posn nil))
845 ;; This is not a repetition.
846 ;; We are adjusting an old selection or creating a new one.
836 (if (or (and (eq last-command 'mouse-save-then-kill) 847 (if (or (and (eq last-command 'mouse-save-then-kill)
837 mouse-save-then-kill-posn) 848 mouse-save-then-kill-posn)
838 (and mark-active transient-mark-mode) 849 (and mark-active transient-mark-mode)
839 (and (memq last-command 850 (and (memq last-command
840 '(mouse-drag-region mouse-set-region)) 851 '(mouse-drag-region mouse-set-region))
857 ;; Set the mark where point is, then move where clicked. 868 ;; Set the mark where point is, then move where clicked.
858 (mouse-set-mark-fast click) 869 (mouse-set-mark-fast click)
859 (if before-scroll 870 (if before-scroll
860 (goto-char before-scroll)) 871 (goto-char before-scroll))
861 (exchange-point-and-mark) 872 (exchange-point-and-mark)
862 (kill-new (buffer-substring (point) (mark t)))) 873 (kill-new (buffer-substring (point) (mark t)))
874 (if window-system
875 (mouse-show-mark)))
863 (mouse-set-region-1) 876 (mouse-set-region-1)
864 (setq mouse-save-then-kill-posn 877 (setq mouse-save-then-kill-posn
865 (list (car kill-ring) (point) click-posn))))))) 878 (list (car kill-ring) (point) click-posn)))))))
866 879
867 (global-set-key [M-mouse-1] 'mouse-start-secondary) 880 (global-set-key [M-mouse-1] 'mouse-start-secondary)