aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorRichard M. Stallman1993-06-13 04:18:43 +0000
committerRichard M. Stallman1993-06-13 04:18:43 +0000
commit3f26b32a5f27c5036940e7f0b2d0536dcc9f4567 (patch)
tree38952d3770020946e2d4f8c6be523878e996cbbd
parentf7ab4e3d35b16325e4cbf021808fcf41d572065d (diff)
downloademacs-3f26b32a5f27c5036940e7f0b2d0536dcc9f4567.tar.gz
emacs-3f26b32a5f27c5036940e7f0b2d0536dcc9f4567.zip
(mouse-set-mark-fast): New function.
(mouse-show-mark): New function. (mouse-kill-ring-save, mouse-save-then-kill): Use them. (mouse-save-then-kill): Don't let kill-region alter this-command. Check last-command accordingly. (mouse-split-window-vertically): Handle scroll bar events.
-rw-r--r--lisp/mouse.el35
1 files changed, 29 insertions, 6 deletions
diff --git a/lisp/mouse.el b/lisp/mouse.el
index 5f2a0e9a694..0bf5ae0c230 100644
--- a/lisp/mouse.el
+++ b/lisp/mouse.el
@@ -65,7 +65,10 @@ This command must be bound to a mouse click."
65 (interactive "@e") 65 (interactive "@e")
66 (let ((start (event-start click))) 66 (let ((start (event-start click)))
67 (select-window (posn-window start)) 67 (select-window (posn-window start))
68 (let ((new-height (1+ (cdr (posn-col-row (event-end click))))) 68 (let ((new-height (if (eq (posn-point start) 'vertical-scroll-bar)
69 (scroll-bar-scale (posn-col-row start)
70 (1- (window-height)))
71 (1+ (cdr (posn-col-row (event-end click))))))
69 (first-line window-min-height) 72 (first-line window-min-height)
70 (last-line (- (window-height) window-min-height))) 73 (last-line (- (window-height) window-min-height)))
71 (if (< last-line first-line) 74 (if (< last-line first-line)
@@ -159,6 +162,21 @@ This must be bound to a button-down mouse event."
159 ;; Turn off the old mark when we set up an empty region. 162 ;; Turn off the old mark when we set up an empty region.
160 (setq deactivate-mark t)))) 163 (setq deactivate-mark t))))
161 164
165;; Subroutine: set the mark where CLICK happened,
166;; but don't do anything else.
167(defun mouse-set-mark-fast (click)
168 (let ((posn (event-start click)))
169 (select-window (posn-window posn))
170 (if (numberp (posn-point posn))
171 (push-mark (posn-point posn) t t))))
172
173;; Momentarily show where the mark is, if highlighting doesn't show it.
174(defun mouse-show-mark ()
175 (or transient-mark-mode
176 (save-excursion
177 (goto-char (mark t))
178 (sit-for 1))))
179
162(defun mouse-set-mark (click) 180(defun mouse-set-mark (click)
163 "Set mark at the position clicked on with the mouse. 181 "Set mark at the position clicked on with the mouse.
164Display cursor at that position for a second. 182Display cursor at that position for a second.
@@ -192,8 +210,9 @@ Prefix arguments are interpreted as with \\[yank]."
192 "Copy the region between point and the mouse click in the kill ring. 210 "Copy the region between point and the mouse click in the kill ring.
193This does not delete the region; it acts like \\[kill-ring-save]." 211This does not delete the region; it acts like \\[kill-ring-save]."
194 (interactive "e") 212 (interactive "e")
195 (mouse-set-mark click) 213 (mouse-set-mark-fast click)
196 (kill-ring-save (point) (mark t))) 214 (kill-ring-save (point) (mark t))
215 (mouse-show-mark))
197 216
198;;; This function used to delete the text between point and the mouse 217;;; This function used to delete the text between point and the mouse
199;;; whenever it was equal to the front of the kill ring, but some 218;;; whenever it was equal to the front of the kill ring, but some
@@ -210,8 +229,11 @@ at the front of the kill ring, this deletes the text.
210Otherwise, it adds the text to the kill ring, like \\[kill-ring-save], 229Otherwise, it adds the text to the kill ring, like \\[kill-ring-save],
211which prepares for a second click to delete the text." 230which prepares for a second click to delete the text."
212 (interactive "e") 231 (interactive "e")
213 (let ((click-posn (posn-point (event-start click)))) 232 (let ((click-posn (posn-point (event-start click)))
214 (if (and (eq last-command 'kill-region) 233 ;; Don't let a subsequent kill command append to this one:
234 ;; prevent setting this-command to kill-region.
235 (this-command this-command))
236 (if (and (eq last-command 'mouse-save-then-kill)
215 mouse-save-then-kill-posn 237 mouse-save-then-kill-posn
216 (eq (car mouse-save-then-kill-posn) (car kill-ring)) 238 (eq (car mouse-save-then-kill-posn) (car kill-ring))
217 (equal (cdr mouse-save-then-kill-posn) (list (point) click-posn))) 239 (equal (cdr mouse-save-then-kill-posn) (list (point) click-posn)))
@@ -225,8 +247,9 @@ which prepares for a second click to delete the text."
225 (setq buffer-undo-list 247 (setq buffer-undo-list
226 (cons (cons (car kill-ring) (point)) buffer-undo-list)))) 248 (cons (cons (car kill-ring) (point)) buffer-undo-list))))
227 ;; Otherwise, save this region. 249 ;; Otherwise, save this region.
228 (mouse-set-mark click) 250 (mouse-set-mark-fast click)
229 (kill-ring-save (point) (mark t)) 251 (kill-ring-save (point) (mark t))
252 (mouse-show-mark)
230 (setq mouse-save-then-kill-posn 253 (setq mouse-save-then-kill-posn
231 (list (car kill-ring) (point) click-posn))))) 254 (list (car kill-ring) (point) click-posn)))))
232 255