diff options
author | Stephen Berman <stephen.berman@gmx.net> | 2016-07-08 17:36:55 +0200 |
---|---|---|
committer | Stephen Berman <stephen.berman@gmx.net> | 2016-07-08 17:36:55 +0200 |
commit | d0c0b71d889ff223d2e5073b733f4047d541343b (patch) | |
tree | 30536c1fa00c205a6f462e628c99e313601ee4d2 /lisp/mouse.el | |
parent | 381c6bbfb3eaa69ece0fce8dd92ccd3a1ef2729f (diff) | |
download | emacs-d0c0b71d889ff223d2e5073b733f4047d541343b.tar.gz |
Allow selecting region with mouse to move point to beginning
* etc/NEWS: Mention new user option
`mouse-select-region-move-to-beginning'.
* doc/emacs/frames.texi (Mouse Commands): Add cross-reference
to the following.
(Word and Line Mouse): Describe how double-clicking mouse-1 to
activate region and `mouse-select-region-move-to-beginning'
affect point.
* lisp/mouse.el (mouse-select-region-move-to-beginning): New defcustom.
(mouse-set-point): Use it. (Bug#23478)
Diffstat (limited to 'lisp/mouse.el')
-rw-r--r-- | lisp/mouse.el | 19 |
1 files changed, 16 insertions, 3 deletions
diff --git a/lisp/mouse.el b/lisp/mouse.el index 53d5a22167e..135e1f5d71f 100644 --- a/lisp/mouse.el +++ b/lisp/mouse.el @@ -538,15 +538,28 @@ must be one of the symbols `header', `mode', or `vertical'." (interactive "e") (mouse-drag-line start-event 'vertical)) +(defcustom mouse-select-region-move-to-beginning nil + "Effect of selecting a region extending backward from double click. +Nil means keep point at the position clicked (region end); +non-nil means move point to beginning of region." + :version "25.2" + :type '(choice (const :tag "Don't move point" nil) + (const :tag "Move point to beginning of region" t))) + (defun mouse-set-point (event &optional promote-to-region) "Move point to the position clicked on with the mouse. This should be bound to a mouse click event type. -If PROMOTE-TO-REGION is non-nil and event is a multiple-click, -select the corresponding element around point." +If PROMOTE-TO-REGION is non-nil and event is a multiple-click, select +the corresponding element around point, with the resulting position of +point determined by `mouse-select-region-move-to-beginning'." (interactive "e\np") (mouse-minibuffer-check event) (if (and promote-to-region (> (event-click-count event) 1)) - (mouse-set-region event) + (progn + (mouse-set-region event) + (when mouse-select-region-move-to-beginning + (when (> (posn-point (event-start event)) (region-beginning)) + (exchange-point-and-mark)))) ;; Use event-end in case called from mouse-drag-region. ;; If EVENT is a click, event-end and event-start give same value. (posn-set-point (event-end event)))) |