diff options
| author | Stephen Berman | 2016-07-08 17:36:55 +0200 |
|---|---|---|
| committer | Stephen Berman | 2016-07-08 17:36:55 +0200 |
| commit | d0c0b71d889ff223d2e5073b733f4047d541343b (patch) | |
| tree | 30536c1fa00c205a6f462e628c99e313601ee4d2 | |
| parent | 381c6bbfb3eaa69ece0fce8dd92ccd3a1ef2729f (diff) | |
| download | emacs-d0c0b71d889ff223d2e5073b733f4047d541343b.tar.gz emacs-d0c0b71d889ff223d2e5073b733f4047d541343b.zip | |
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)
| -rw-r--r-- | doc/emacs/frames.texi | 16 | ||||
| -rw-r--r-- | etc/NEWS | 7 | ||||
| -rw-r--r-- | lisp/mouse.el | 19 |
3 files changed, 37 insertions, 5 deletions
diff --git a/doc/emacs/frames.texi b/doc/emacs/frames.texi index 7e6006262ce..03172b62cf5 100644 --- a/doc/emacs/frames.texi +++ b/doc/emacs/frames.texi | |||
| @@ -97,7 +97,8 @@ ring; on a second click, kill it (@code{mouse-save-then-kill}). | |||
| 97 | invoked by clicking with the left mouse button, @kbd{mouse-1}, in the | 97 | invoked by clicking with the left mouse button, @kbd{mouse-1}, in the |
| 98 | text area of a window. This moves point to the position where you | 98 | text area of a window. This moves point to the position where you |
| 99 | clicked. If that window was not the selected window, it becomes the | 99 | clicked. If that window was not the selected window, it becomes the |
| 100 | selected window. | 100 | selected window. You can also activate a region by double-clicking |
| 101 | mouse-1 (@pxref{Word and Line Mouse}). | ||
| 101 | 102 | ||
| 102 | @vindex x-mouse-click-focus-ignore-position | 103 | @vindex x-mouse-click-focus-ignore-position |
| 103 | Normally, if the frame you clicked in was not the selected frame, it | 104 | Normally, if the frame you clicked in was not the selected frame, it |
| @@ -215,7 +216,7 @@ also copied to the kill ring. | |||
| 215 | 216 | ||
| 216 | @table @kbd | 217 | @table @kbd |
| 217 | @item Double-mouse-1 | 218 | @item Double-mouse-1 |
| 218 | Select the text around the word which you click on. | 219 | Select the text around the word or character which you click on. |
| 219 | 220 | ||
| 220 | Double-clicking on a character with symbol syntax (such as | 221 | Double-clicking on a character with symbol syntax (such as |
| 221 | underscore, in C mode) selects the symbol surrounding that character. | 222 | underscore, in C mode) selects the symbol surrounding that character. |
| @@ -226,6 +227,17 @@ ends. Double-clicking on a character with string-delimiter syntax | |||
| 226 | constant (Emacs uses heuristics to figure out whether that character | 227 | constant (Emacs uses heuristics to figure out whether that character |
| 227 | is the beginning or the end of it). | 228 | is the beginning or the end of it). |
| 228 | 229 | ||
| 230 | Double-clicking on the beginning of a parenthetical grouping or | ||
| 231 | beginning string-delimiter moves point to the end of the region, | ||
| 232 | scrolling the buffer display forward if necessary to show the new | ||
| 233 | location of point. Double-clicking on the end of a parenthetical | ||
| 234 | grouping or end string-delimiter keeps point at the end of the region | ||
| 235 | by default, so the beginning of the region will not be visible if it | ||
| 236 | is above the top of the window; setting the user option | ||
| 237 | @code{mouse-select-region-move-to-beginning} to non-nil changes this | ||
| 238 | to move point to the beginning of the region, scrolling the display | ||
| 239 | backward if necessary. | ||
| 240 | |||
| 229 | @item Double-Drag-mouse-1 | 241 | @item Double-Drag-mouse-1 |
| 230 | Select the text you drag across, in the form of whole words. | 242 | Select the text you drag across, in the form of whole words. |
| 231 | 243 | ||
| @@ -56,6 +56,13 @@ affected by this, as SGI stopped supporting IRIX in December 2013. | |||
| 56 | 56 | ||
| 57 | * Changes in Emacs 25.2 | 57 | * Changes in Emacs 25.2 |
| 58 | 58 | ||
| 59 | +++ | ||
| 60 | ** The new user option 'mouse-select-region-move-to-beginning' | ||
| 61 | controls the position of point when double-clicking mouse-1 on the end | ||
| 62 | of a parenthetical grouping or string-delimiter: the default value nil | ||
| 63 | keeps point at the end of the region, setting it to non-nil moves | ||
| 64 | point to the beginning of the region. | ||
| 65 | |||
| 59 | --- | 66 | --- |
| 60 | ** 'find-library-name' will now fall back on looking at 'load-history' | 67 | ** 'find-library-name' will now fall back on looking at 'load-history' |
| 61 | to try to locate libraries that have been loaded with an explicit path | 68 | to try to locate libraries that have been loaded with an explicit path |
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'." | |||
| 538 | (interactive "e") | 538 | (interactive "e") |
| 539 | (mouse-drag-line start-event 'vertical)) | 539 | (mouse-drag-line start-event 'vertical)) |
| 540 | 540 | ||
| 541 | (defcustom mouse-select-region-move-to-beginning nil | ||
| 542 | "Effect of selecting a region extending backward from double click. | ||
| 543 | Nil means keep point at the position clicked (region end); | ||
| 544 | non-nil means move point to beginning of region." | ||
| 545 | :version "25.2" | ||
| 546 | :type '(choice (const :tag "Don't move point" nil) | ||
| 547 | (const :tag "Move point to beginning of region" t))) | ||
| 548 | |||
| 541 | (defun mouse-set-point (event &optional promote-to-region) | 549 | (defun mouse-set-point (event &optional promote-to-region) |
| 542 | "Move point to the position clicked on with the mouse. | 550 | "Move point to the position clicked on with the mouse. |
| 543 | This should be bound to a mouse click event type. | 551 | This should be bound to a mouse click event type. |
| 544 | If PROMOTE-TO-REGION is non-nil and event is a multiple-click, | 552 | If PROMOTE-TO-REGION is non-nil and event is a multiple-click, select |
| 545 | select the corresponding element around point." | 553 | the corresponding element around point, with the resulting position of |
| 554 | point determined by `mouse-select-region-move-to-beginning'." | ||
| 546 | (interactive "e\np") | 555 | (interactive "e\np") |
| 547 | (mouse-minibuffer-check event) | 556 | (mouse-minibuffer-check event) |
| 548 | (if (and promote-to-region (> (event-click-count event) 1)) | 557 | (if (and promote-to-region (> (event-click-count event) 1)) |
| 549 | (mouse-set-region event) | 558 | (progn |
| 559 | (mouse-set-region event) | ||
| 560 | (when mouse-select-region-move-to-beginning | ||
| 561 | (when (> (posn-point (event-start event)) (region-beginning)) | ||
| 562 | (exchange-point-and-mark)))) | ||
| 550 | ;; Use event-end in case called from mouse-drag-region. | 563 | ;; Use event-end in case called from mouse-drag-region. |
| 551 | ;; If EVENT is a click, event-end and event-start give same value. | 564 | ;; If EVENT is a click, event-end and event-start give same value. |
| 552 | (posn-set-point (event-end event)))) | 565 | (posn-set-point (event-end event)))) |