Mercurial > emacs
comparison lisp/mouse.el @ 57749:08eb19d9ee4b
(mouse-show-mark): Do most processing the same
regardless of transient-mark-mode.
author | Richard M. Stallman <rms@gnu.org> |
---|---|
date | Wed, 27 Oct 2004 17:44:59 +0000 |
parents | f2e8ab894ad3 |
children | 8fe3a1b0606e |
comparison
equal
deleted
inserted
replaced
57748:a5bb249b0f3b | 57749:08eb19d9ee4b |
---|---|
1023 | 1023 |
1024 (defvar mouse-region-delete-keys '([delete] [deletechar]) | 1024 (defvar mouse-region-delete-keys '([delete] [deletechar]) |
1025 "List of keys which shall cause the mouse region to be deleted.") | 1025 "List of keys which shall cause the mouse region to be deleted.") |
1026 | 1026 |
1027 (defun mouse-show-mark () | 1027 (defun mouse-show-mark () |
1028 (if transient-mark-mode | 1028 (let ((inhibit-quit t) |
1029 (delete-overlay mouse-drag-overlay) | 1029 (echo-keystrokes 0) |
1030 (let ((inhibit-quit t) | 1030 event events key ignore |
1031 (echo-keystrokes 0) | 1031 (x-lost-selection-hooks (copy-sequence x-lost-selection-hooks))) |
1032 event events key ignore | 1032 (add-hook 'x-lost-selection-hooks |
1033 x-lost-selection-hooks) | 1033 (lambda (seltype) |
1034 (add-hook 'x-lost-selection-hooks | 1034 (if (eq seltype 'PRIMARY) |
1035 (lambda (seltype) | 1035 (progn (setq ignore t) |
1036 (if (eq seltype 'PRIMARY) | 1036 (throw 'mouse-show-mark t))))) |
1037 (progn (setq ignore t) | 1037 (if transient-mark-mode |
1038 (throw 'mouse-show-mark t))))) | 1038 (delete-overlay mouse-drag-overlay) |
1039 (move-overlay mouse-drag-overlay (point) (mark t)) | 1039 (move-overlay mouse-drag-overlay (point) (mark t))) |
1040 (catch 'mouse-show-mark | 1040 (catch 'mouse-show-mark |
1041 ;; In this loop, execute scroll bar and switch-frame events. | 1041 ;; In this loop, execute scroll bar and switch-frame events. |
1042 ;; Also ignore down-events that are undefined. | 1042 ;; Also ignore down-events that are undefined. |
1043 (while (progn (setq event (read-event)) | 1043 (while (progn (setq event (read-event)) |
1044 (setq events (append events (list event))) | 1044 (setq events (append events (list event))) |
1045 (setq key (apply 'vector events)) | 1045 (setq key (apply 'vector events)) |
1046 (or (and (consp event) | 1046 (or (and (consp event) |
1047 (eq (car event) 'switch-frame)) | 1047 (eq (car event) 'switch-frame)) |
1048 (and (consp event) | 1048 (and (consp event) |
1049 (eq (posn-point (event-end event)) | 1049 (eq (posn-point (event-end event)) |
1050 'vertical-scroll-bar)) | 1050 'vertical-scroll-bar)) |
1051 (and (memq 'down (event-modifiers event)) | 1051 (and (memq 'down (event-modifiers event)) |
1052 (not (key-binding key)) | 1052 (not (key-binding key)) |
1053 (not (mouse-undouble-last-event events)) | 1053 (not (mouse-undouble-last-event events)) |
1054 (not (member key mouse-region-delete-keys))))) | 1054 (not (member key mouse-region-delete-keys))))) |
1055 (and (consp event) | 1055 (and (consp event) |
1056 (or (eq (car event) 'switch-frame) | 1056 (or (eq (car event) 'switch-frame) |
1057 (eq (posn-point (event-end event)) | 1057 (eq (posn-point (event-end event)) |
1058 'vertical-scroll-bar)) | 1058 'vertical-scroll-bar)) |
1059 (let ((keys (vector 'vertical-scroll-bar event))) | 1059 (let ((keys (vector 'vertical-scroll-bar event))) |
1060 (and (key-binding keys) | 1060 (and (key-binding keys) |
1061 (progn | 1061 (progn |
1062 (call-interactively (key-binding keys) | 1062 (call-interactively (key-binding keys) |
1063 nil keys) | 1063 nil keys) |
1064 (setq events nil))))))) | 1064 (setq events nil))))))) |
1065 ;; If we lost the selection, just turn off the highlighting. | 1065 ;; If we lost the selection, just turn off the highlighting. |
1066 (if ignore | 1066 (if ignore |
1067 nil | 1067 nil |
1068 ;; For certain special keys, delete the region. | 1068 ;; For certain special keys, delete the region. |
1069 (if (member key mouse-region-delete-keys) | 1069 (if (member key mouse-region-delete-keys) |
1070 (delete-region (overlay-start mouse-drag-overlay) | 1070 (delete-region (overlay-start mouse-drag-overlay) |
1071 (overlay-end mouse-drag-overlay)) | 1071 (overlay-end mouse-drag-overlay)) |
1072 ;; Otherwise, unread the key so it gets executed normally. | 1072 ;; Otherwise, unread the key so it gets executed normally. |
1073 (setq unread-command-events | 1073 (setq unread-command-events |
1074 (nconc events unread-command-events)))) | 1074 (nconc events unread-command-events)))) |
1075 (setq quit-flag nil) | 1075 (setq quit-flag nil) |
1076 (unless transient-mark-mode | |
1076 (delete-overlay mouse-drag-overlay)))) | 1077 (delete-overlay mouse-drag-overlay)))) |
1077 | 1078 |
1078 (defun mouse-set-mark (click) | 1079 (defun mouse-set-mark (click) |
1079 "Set mark at the position clicked on with the mouse. | 1080 "Set mark at the position clicked on with the mouse. |
1080 Display cursor at that position for a second. | 1081 Display cursor at that position for a second. |