emacs-diffs
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

[Emacs-diffs] master d0c0b71: Allow selecting region with mouse to move


From: Stephen Berman
Subject: [Emacs-diffs] master d0c0b71: Allow selecting region with mouse to move point to beginning
Date: Fri, 8 Jul 2016 15:37:02 +0000 (UTC)

branch: master
commit d0c0b71d889ff223d2e5073b733f4047d541343b
Author: Stephen Berman <address@hidden>
Commit: Stephen Berman <address@hidden>

    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)
---
 doc/emacs/frames.texi |   16 ++++++++++++++--
 etc/NEWS              |    7 +++++++
 lisp/mouse.el         |   19 ++++++++++++++++---
 3 files changed, 37 insertions(+), 5 deletions(-)

diff --git a/doc/emacs/frames.texi b/doc/emacs/frames.texi
index 7e60062..03172b6 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}).
 invoked by clicking with the left mouse button, @kbd{mouse-1}, in the
 text area of a window.  This moves point to the position where you
 clicked.  If that window was not the selected window, it becomes the
-selected window.
+selected window.  You can also activate a region by double-clicking
+mouse-1 (@pxref{Word and Line Mouse}).
 
 @vindex x-mouse-click-focus-ignore-position
   Normally, if the frame you clicked in was not the selected frame, it
@@ -215,7 +216,7 @@ also copied to the kill ring.
 
 @table @kbd
 @item Double-mouse-1
-Select the text around the word which you click on.
+Select the text around the word or character which you click on.
 
 Double-clicking on a character with symbol syntax (such as
 underscore, in C mode) selects the symbol surrounding that character.
@@ -226,6 +227,17 @@ ends.  Double-clicking on a character with 
string-delimiter syntax
 constant (Emacs uses heuristics to figure out whether that character
 is the beginning or the end of it).
 
+Double-clicking on the beginning of a parenthetical grouping or
+beginning string-delimiter moves point to the end of the region,
+scrolling the buffer display forward if necessary to show the new
+location of point.  Double-clicking on the end of a parenthetical
+grouping or end string-delimiter keeps point at the end of the region
+by default, so the beginning of the region will not be visible if it
+is above the top of the window; setting the user option
address@hidden to non-nil changes this
+to move point to the beginning of the region, scrolling the display
+backward if necessary.
+
 @item Double-Drag-mouse-1
 Select the text you drag across, in the form of whole words.
 
diff --git a/etc/NEWS b/etc/NEWS
index 54b62f0..5472dd8 100644
--- a/etc/NEWS
+++ b/etc/NEWS
@@ -56,6 +56,13 @@ affected by this, as SGI stopped supporting IRIX in December 
2013.
 
 * Changes in Emacs 25.2
 
++++
+** The new user option 'mouse-select-region-move-to-beginning'
+controls the position of point when double-clicking mouse-1 on the end
+of a parenthetical grouping or string-delimiter: the default value nil
+keeps point at the end of the region, setting it to non-nil moves
+point to the beginning of the region.
+
 ---
 ** 'find-library-name' will now fall back on looking at 'load-history'
 to try to locate libraries that have been loaded with an explicit path
diff --git a/lisp/mouse.el b/lisp/mouse.el
index 53d5a22..135e1f5 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))))



reply via email to

[Prev in Thread] Current Thread [Next in Thread]