aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorJim Blandy1992-10-07 20:46:31 +0000
committerJim Blandy1992-10-07 20:46:31 +0000
commitb5370f0363eb5d78d5c5f8f4622f3bd1baff99fa (patch)
treee08caf312bd6bee990bd002ca9621c7a63facd04
parent0d73ca8156c17b1174576108a99bed4fe1b46719 (diff)
downloademacs-b5370f0363eb5d78d5c5f8f4622f3bd1baff99fa.tar.gz
emacs-b5370f0363eb5d78d5c5f8f4622f3bd1baff99fa.zip
* mouse.el: Begin adapting this to the new event format.
(event-window, event-point, mouse-coords, mouse-timestamp): Removed. (event-start, event-end, posn-window, posn-point, posn-col-row, posn-timestamp): New accessors; these are defsubsts. (mouse-delete-window, mouse-delete-other-windows, mouse-split-window-vertically, mouse-set-point): Rewritten to use the new accessors. * mouse.el: Remove hack of binding down-mouse-1. * mouse.el (mouse-movement-p): Add docstring for this.
-rw-r--r--lisp/mouse.el77
1 files changed, 60 insertions, 17 deletions
diff --git a/lisp/mouse.el b/lisp/mouse.el
index c6aa6ca1d0a..0cc2aacc673 100644
--- a/lisp/mouse.el
+++ b/lisp/mouse.el
@@ -24,14 +24,55 @@
24 24
25;;; Utility functions. 25;;; Utility functions.
26 26
27(defun mouse-movement-p (event) 27(defsubst mouse-movement-p (object)
28 (and (consp event) 28 "Return non-nil if OBJECT is a mouse movement event."
29 (eq (car event) 'mouse-movement))) 29 (and (consp object)
30 30 (eq (car object) 'mouse-movement)))
31(defun event-window (event) (nth 1 event)) 31
32(defun event-point (event) (nth 2 event)) 32(defsubst event-start (event)
33(defun mouse-coords (event) (nth 3 event)) 33 "Return the starting position of EVENT.
34(defun mouse-timestamp (event) (nth 4 event)) 34If EVENT is a mouse press or a mouse click, this returns the location
35of the event.
36If EVENT is a drag, this returns the drag's starting position.
37The return value is of the form
38 (WINDOW BUFFER-POSITION (COL . ROW) TIMESTAMP)
39The `posn-' functions access elements of such lists."
40 (nth 1 event))
41
42(defsubst event-end (event)
43 "Return the ending location of EVENT. EVENT should be a drag event.
44The return value is of the form
45 (WINDOW BUFFER-POSITION (COL . ROW) TIMESTAMP)
46The `posn-' functions access elements of such lists."
47 (nth 2 event))
48
49(defsubst posn-window (position)
50 "Return the window in POSITION.
51POSITION should be a list of the form
52 (WINDOW BUFFER-POSITION (COL . ROW) TIMESTAMP)
53as returned by the `event-start' and `event-end' functions."
54 (nth 0 position))
55
56(defsubst posn-point (position)
57 "Return the buffer location in POSITION.
58POSITION should be a list of the form
59 (WINDOW BUFFER-POSITION (COL . ROW) TIMESTAMP)
60as returned by the `event-start' and `event-end' functions."
61 (nth 1 position))
62
63(defsubst posn-col-row (position)
64 "Return the row and column in POSITION.
65POSITION should be a list of the form
66 (WINDOW BUFFER-POSITION (COL . ROW) TIMESTAMP)
67as returned by the `event-start' and `event-end' functions."
68 (nth 2 position))
69
70(defsubst posn-timestamp (position)
71 "Return the timestamp of POSITION.
72POSITION should be a list of the form
73 (WINDOW BUFFER-POSITION (COL . ROW) TIMESTAMP)
74nas returned by the `event-start' and `event-end' functions."
75 (nth 3 position))
35 76
36;;; Indent track-mouse like progn. 77;;; Indent track-mouse like progn.
37(put 'track-mouse 'lisp-indent-function 0) 78(put 'track-mouse 'lisp-indent-function 0)
@@ -41,11 +82,11 @@
41 "Delete the window you click on. 82 "Delete the window you click on.
42This must be bound to a mouse click." 83This must be bound to a mouse click."
43 (interactive "e") 84 (interactive "e")
44 (delete-window (event-window click))) 85 (delete-window (posn-window (event-start click))))
45 86
46(defun mouse-delete-other-windows (click) 87(defun mouse-delete-other-windows ()
47 "Delete all window except the one you click on." 88 "Delete all window except the one you click on."
48 (interactive "@e") 89 (interactive "@")
49 (delete-other-windows)) 90 (delete-other-windows))
50 91
51(defun mouse-split-window-vertically (click) 92(defun mouse-split-window-vertically (click)
@@ -53,7 +94,9 @@ This must be bound to a mouse click."
53The window is split at the line clicked on. 94The window is split at the line clicked on.
54This command must be bound to a mouse click." 95This command must be bound to a mouse click."
55 (interactive "@e") 96 (interactive "@e")
56 (split-window-vertically (1+ (cdr (mouse-coords click))))) 97 (let ((start (event-start click)))
98 (select-window (posn-window start))
99 (split-window-vertically (1+ (cdr (posn-col-row click))))))
57 100
58(defun mouse-split-window-horizontally (click) 101(defun mouse-split-window-horizontally (click)
59 "Select Emacs window mouse is on, then split it horizontally in half. 102 "Select Emacs window mouse is on, then split it horizontally in half.
@@ -66,9 +109,10 @@ This command must be bound to a mouse click."
66 "Move point to the position clicked on with the mouse. 109 "Move point to the position clicked on with the mouse.
67This must be bound to a mouse click." 110This must be bound to a mouse click."
68 (interactive "e") 111 (interactive "e")
69 (select-window (event-window click)) 112 (let ((posn (event-start click)))
70 (if (numberp (event-point click)) 113 (select-window (posn-window posn))
71 (goto-char (event-point click)))) 114 (if (numberp (posn-point posn))
115 (goto-char (posn-point posn)))))
72 116
73(defun mouse-set-mark (click) 117(defun mouse-set-mark (click)
74 "Set mark at the position clicked on with the mouse. 118 "Set mark at the position clicked on with the mouse.
@@ -186,7 +230,7 @@ This does not delete the region; it acts like \\[kill-ring-save]."
186 (interactive "@e") 230 (interactive "@e")
187 (scroll-left (1+ (car (mouse-coords click))))) 231 (scroll-left (1+ (car (mouse-coords click)))))
188 232
189(defun mouse-scroll-right (ncolumns) 233(defun mouse-scroll-right (click)
190 (interactive "@e") 234 (interactive "@e")
191 (scroll-right (1+ (car (mouse-coords click))))) 235 (scroll-right (1+ (car (mouse-coords click)))))
192 236
@@ -538,7 +582,6 @@ This does not delete the region; it acts like \\[kill-ring-save]."
538;; are properly implemented. 582;; are properly implemented.
539(global-set-key [mouse-1] 'mouse-set-point) 583(global-set-key [mouse-1] 'mouse-set-point)
540 584
541(global-set-key [down-mouse-1] 'mouse-set-point)
542(global-set-key [drag-mouse-1] 'mouse-set-mark) 585(global-set-key [drag-mouse-1] 'mouse-set-mark)
543(global-set-key [mouse-2] 'mouse-yank-at-click) 586(global-set-key [mouse-2] 'mouse-yank-at-click)
544(global-set-key [mouse-3] 'mouse-save-then-kill) 587(global-set-key [mouse-3] 'mouse-save-then-kill)