]> code.delx.au - gnu-emacs/blobdiff - lisp/mouse.el
Merged in changes from CVS trunk.
[gnu-emacs] / lisp / mouse.el
index 9b80ccc0cf5062b51a0e5449cb09f6d4d11b3465..b73967b99dccf2abef8956c348da81dcfd9534e4 100644 (file)
@@ -1,6 +1,6 @@
 ;;; mouse.el --- window system-independent mouse support
 
-;; Copyright (C) 1993, 1994, 1995, 1999, 2000, 2001
+;; Copyright (C) 1993, 94, 95, 1999, 2000, 01, 2004
 ;;   Free Software Foundation, Inc.
 
 ;; Maintainer: FSF
   "*If non-nil, mouse yank commands yank at point instead of at click."
   :type 'boolean
   :group 'mouse)
+
+(defcustom mouse-drag-copy-region t
+  "*If non-nil, mouse drag copies region to kill-ring."
+  :type 'boolean
+  :group 'mouse)
+
 \f
 ;; Provide a mode-specific menu on a mouse button.
 
@@ -577,12 +583,7 @@ This should be bound to a mouse click event type."
   (mouse-minibuffer-check event)
   ;; Use event-end in case called from mouse-drag-region.
   ;; If EVENT is a click, event-end and event-start give same value.
-  (let ((posn (event-end event)))
-    (if (not (windowp (posn-window posn)))
-       (error "Cursor not in text area of window"))
-    (select-window (posn-window posn))
-    (if (numberp (posn-point posn))
-       (goto-char (posn-point posn)))))
+  (posn-set-point (event-end event)))
 
 (defvar mouse-last-region-beg nil)
 (defvar mouse-last-region-end nil)
@@ -617,11 +618,15 @@ This should be bound to a mouse drag event."
     ;; Don't set this-command to kill-region, so that a following
     ;; C-w will not double the text in the kill ring.
     ;; Ignore last-command so we don't append to a preceding kill.
-    (let (this-command last-command deactivate-mark)
-      (copy-region-as-kill (mark) (point)))
+    (when mouse-drag-copy-region
+      (let (this-command last-command deactivate-mark)
+       (copy-region-as-kill (mark) (point))))
     (mouse-set-region-1)))
 
 (defun mouse-set-region-1 ()
+  ;; Set transient-mark-mode for a little while.
+  (if (memq transient-mark-mode '(nil identity))
+      (setq transient-mark-mode 'only))
   (setq mouse-last-region-beg (region-beginning))
   (setq mouse-last-region-end (region-end))
   (setq mouse-last-region-tick (buffer-modified-tick)))
@@ -832,8 +837,9 @@ If the click is in the echo area, display the `*Messages*' buffer."
                  (push-mark region-commencement t t)
                  (goto-char region-termination)
                  ;; Don't let copy-region-as-kill set deactivate-mark.
-                 (let (deactivate-mark)
-                   (copy-region-as-kill (point) (mark t)))
+                 (when mouse-drag-copy-region
+                   (let (deactivate-mark)
+                     (copy-region-as-kill (point) (mark t))))
                  (let ((buffer (current-buffer)))
                    (mouse-show-mark)
                    ;; mouse-show-mark can call read-event,