emacs-diffs
[Top][All Lists]
Advanced

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

master 12424cf31d: New option for selecting symbols by double-clicking


From: Eli Zaretskii
Subject: master 12424cf31d: New option for selecting symbols by double-clicking
Date: Fri, 16 Dec 2022 11:27:37 -0500 (EST)

branch: master
commit 12424cf31daec921e3b4a4029d99787d0e506f09
Author: Eli Zaretskii <eliz@gnu.org>
Commit: Eli Zaretskii <eliz@gnu.org>

    New option for selecting symbols by double-clicking
    
    * lisp/mouse.el (mouse-1-double-click-prefer-symbols): New user
    option.
    (mouse-skip-word): If 'mouse-1-double-click-prefer-symbols' is
    non-nil, skip over the entire symbol at point.  (Bug#60080)
---
 lisp/mouse.el | 20 ++++++++++++++++++--
 1 file changed, 18 insertions(+), 2 deletions(-)

diff --git a/lisp/mouse.el b/lisp/mouse.el
index f72ab4fc64..095d30a285 100644
--- a/lisp/mouse.el
+++ b/lisp/mouse.el
@@ -105,6 +105,15 @@ point at the click position."
   :type 'boolean
   :version "22.1")
 
+(defcustom mouse-1-double-click-prefer-symbols nil
+  "If non-nil, double-clicking Mouse-1 attempts to select the symbol at click.
+
+If nil, the default, double-clicking Mouse-1 on a word-constituent
+character will select only the word at click location, which could
+select fewer characters than the symbol at click."
+  :type 'boolean
+  :version "30.1")
+
 (defcustom mouse-drag-and-drop-region-scroll-margin nil
   "If non-nil, the scroll margin inside a window when dragging text.
 If the mouse moves this many lines close to the top or bottom of
@@ -1800,10 +1809,17 @@ The region will be defined with mark and point."
 ;; Commands to handle xterm-style multiple clicks.
 (defun mouse-skip-word (dir)
   "Skip over word, over whitespace, or over identical punctuation.
+If `mouse-1-double-click-prefer-symbols' is non-nil, skip over symbol.
 If DIR is positive skip forward; if negative, skip backward."
   (let* ((char (following-char))
-        (syntax (char-to-string (char-syntax char))))
-    (cond ((string= syntax "w")
+        (syntax (char-to-string (char-syntax char)))
+         sym)
+    (cond ((and mouse-1-double-click-prefer-symbols
+                (setq sym (bounds-of-thing-at-point 'symbol)))
+           (goto-char (if (< dir 0)
+                          (car sym)
+                        (cdr sym))))
+          ((string= syntax "w")
           ;; Here, we can't use skip-syntax-forward/backward because
           ;; they don't pay attention to word-separating-categories,
           ;; and thus they will skip over a true word boundary.  So,



reply via email to

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