summaryrefslogtreecommitdiff
path: root/lisp/mouse.el
diff options
context:
space:
mode:
authorRichard M. Stallman <rms@gnu.org>1993-06-13 04:18:43 +0000
committerRichard M. Stallman <rms@gnu.org>1993-06-13 04:18:43 +0000
commita484b4784a411e092c1fcac43b4dba571c8b91e7 (patch)
tree37d74cc5a705cd838ae58a4ed078eb76a90be6aa /lisp/mouse.el
parent5971091e5849dea304d30bfa14bae5801580a2b8 (diff)
downloademacs-a484b4784a411e092c1fcac43b4dba571c8b91e7.tar.gz
(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.
Diffstat (limited to 'lisp/mouse.el')
-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."
(interactive "@e")
(let ((start (event-start click)))
(select-window (posn-window start))
- (let ((new-height (1+ (cdr (posn-col-row (event-end click)))))
+ (let ((new-height (if (eq (posn-point start) 'vertical-scroll-bar)
+ (scroll-bar-scale (posn-col-row start)
+ (1- (window-height)))
+ (1+ (cdr (posn-col-row (event-end click))))))
(first-line window-min-height)
(last-line (- (window-height) window-min-height)))
(if (< last-line first-line)
@@ -159,6 +162,21 @@ This must be bound to a button-down mouse event."
;; Turn off the old mark when we set up an empty region.
(setq deactivate-mark t))))
+;; Subroutine: set the mark where CLICK happened,
+;; but don't do anything else.
+(defun mouse-set-mark-fast (click)
+ (let ((posn (event-start click)))
+ (select-window (posn-window posn))
+ (if (numberp (posn-point posn))
+ (push-mark (posn-point posn) t t))))
+
+;; Momentarily show where the mark is, if highlighting doesn't show it.
+(defun mouse-show-mark ()
+ (or transient-mark-mode
+ (save-excursion
+ (goto-char (mark t))
+ (sit-for 1))))
+
(defun mouse-set-mark (click)
"Set mark at the position clicked on with the mouse.
Display cursor at that position for a second.
@@ -192,8 +210,9 @@ Prefix arguments are interpreted as with \\[yank]."
"Copy the region between point and the mouse click in the kill ring.
This does not delete the region; it acts like \\[kill-ring-save]."
(interactive "e")
- (mouse-set-mark click)
- (kill-ring-save (point) (mark t)))
+ (mouse-set-mark-fast click)
+ (kill-ring-save (point) (mark t))
+ (mouse-show-mark))
;;; This function used to delete the text between point and the mouse
;;; 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.
Otherwise, it adds the text to the kill ring, like \\[kill-ring-save],
which prepares for a second click to delete the text."
(interactive "e")
- (let ((click-posn (posn-point (event-start click))))
- (if (and (eq last-command 'kill-region)
+ (let ((click-posn (posn-point (event-start click)))
+ ;; Don't let a subsequent kill command append to this one:
+ ;; prevent setting this-command to kill-region.
+ (this-command this-command))
+ (if (and (eq last-command 'mouse-save-then-kill)
mouse-save-then-kill-posn
(eq (car mouse-save-then-kill-posn) (car kill-ring))
(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."
(setq buffer-undo-list
(cons (cons (car kill-ring) (point)) buffer-undo-list))))
;; Otherwise, save this region.
- (mouse-set-mark click)
+ (mouse-set-mark-fast click)
(kill-ring-save (point) (mark t))
+ (mouse-show-mark)
(setq mouse-save-then-kill-posn
(list (car kill-ring) (point) click-posn)))))