GNU bug report logs - #60080
28.2; Double-click selection cannot be customized

Previous Next

Package: emacs;

Reported by: Sean Devlin <spd <at> toadstyle.org>

Date: Thu, 15 Dec 2022 00:41:02 UTC

Severity: normal

Found in version 28.2

Done: Eli Zaretskii <eliz <at> gnu.org>

Bug is archived. No further changes may be made.

To add a comment to this bug, you must first unarchive it, by sending
a message to control AT debbugs.gnu.org, with unarchive 60080 in the body.
You can then email your comments to 60080 AT debbugs.gnu.org in the normal way.

Toggle the display of automated, internal messages from the tracker.

View this report as an mbox folder, status mbox, maintainer mbox


Report forwarded to bug-gnu-emacs <at> gnu.org:
bug#60080; Package emacs. (Thu, 15 Dec 2022 00:41:02 GMT) Full text and rfc822 format available.

Acknowledgement sent to Sean Devlin <spd <at> toadstyle.org>:
New bug report received and forwarded. Copy sent to bug-gnu-emacs <at> gnu.org. (Thu, 15 Dec 2022 00:41:02 GMT) Full text and rfc822 format available.

Message #5 received at submit <at> debbugs.gnu.org (full text, mbox):

From: Sean Devlin <spd <at> toadstyle.org>
To: bug-gnu-emacs <at> gnu.org
Subject: 28.2; Double-click selection cannot be customized
Date: Wed, 14 Dec 2022 19:40:22 -0500
Hi folks,

In GUI Emacs, you can double-click to select some region of text. The
rules for double-click selection are documented in (info "(emacs) Word
and Line Mouse"). Here are the relevant bits:

  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.

I'd like to customize Emacs such that when I double-click on a word,
the entire enclosing symbol is selected. In other words, it should
behave more like the latter case of double-clicking on a character with
symbol syntax.

Here is a recipe to show what I am talking about:

1. Open GUI Emacs with -Q flag.
2. In the scratch buffer, type "this-is-a-symbol".
3. With the mouse, double-click on "this".
4. Observe that only "this" is selected in the active region.
5. C-g to deactive the region.
6. Double-click on the "-" following "this".
7. Observe that the entire symbol "this-is-a-symbol" is selected.

I want to select the full symbol "this-is-a-symbol" in both cases.

Note that this is the default behavior in some other editors that I am
aware of.

I understand that I can get the behavior I want by double-clicking the
"-", but "-" is a small target, and selecting the entire symbol is by
far the more common use case for me.

In the short term, I have a workaround where I advise the
mouse-skip-word function.

Thanks!

In GNU Emacs 28.2
System Description:  macOS 13

Configured using:
'configure --with-ns '--enable-locallisppath=/Library/Application
Support/Emacs/${version}/site-lisp:/Library/Application
Support/Emacs/site-lisp' --with-modules'

Configured features:
ACL GMP GNUTLS JSON LIBXML2 MODULES NOTIFY KQUEUE NS PDUMPER THREADS
TOOLKIT_SCROLL_BARS ZLIB

Important settings:
  value of $LANG: en_US.UTF-8
  locale-coding-system: utf-8-unix

Major mode: Lisp Interaction

Minor modes in effect:
  tooltip-mode: t
  global-eldoc-mode: t
  eldoc-mode: t
  show-paren-mode: t
  electric-indent-mode: t
  mouse-wheel-mode: t
  tool-bar-mode: t
  menu-bar-mode: t
  file-name-shadow-mode: t
  global-font-lock-mode: t
  font-lock-mode: t
  blink-cursor-mode: t
  auto-composition-mode: t
  auto-encryption-mode: t
  auto-compression-mode: t
  line-number-mode: t
  indent-tabs-mode: t
  transient-mark-mode: t

Load-path shadows:
None found.

Features:
(shadow sort mail-extr emacsbug message rmc puny dired dired-loaddefs
rfc822 mml mml-sec epa derived epg rfc6068 epg-config gnus-util rmail
rmail-loaddefs auth-source cl-seq eieio eieio-core cl-macs
eieio-loaddefs password-cache json map text-property-search seq byte-opt
gv bytecomp byte-compile cconv mm-decode mm-bodies mm-encode mail-parse
rfc2231 mailabbrev gmm-utils mailheader sendmail rfc2047 rfc2045
ietf-drums mm-util mail-prsvr mail-utils time-date subr-x cl-loaddefs
cl-lib iso-transl tooltip eldoc paren electric uniquify ediff-hook
vc-hooks lisp-float-type elisp-mode mwheel term/ns-win ns-win
ucs-normalize mule-util term/common-win tool-bar dnd fontset image
regexp-opt fringe tabulated-list replace newcomment text-mode lisp-mode
prog-mode register page tab-bar menu-bar rfn-eshadow isearch easymenu
timer select scroll-bar mouse jit-lock font-lock syntax font-core
term/tty-colors frame minibuffer cl-generic cham georgian utf-8-lang
misc-lang vietnamese tibetan thai tai-viet lao korean japanese eucjp-ms
cp51932 hebrew greek romanian slovak czech european ethiopic indian
cyrillic chinese composite emoji-zwj charscript charprop case-table
epa-hook jka-cmpr-hook help simple abbrev obarray cl-preloaded nadvice
button loaddefs faces cus-face macroexp files window text-properties
overlay sha1 md5 base64 format env code-pages mule custom widget
hashtable-print-readable backquote threads kqueue cocoa ns multi-tty
make-network-process emacs)

Memory information:
((conses 16 49949 6483)
(symbols 48 6552 1)
(strings 32 18286 1523)
(string-bytes 1 606914)
(vectors 16 12898)
(vector-slots 8 184857 11573)
(floats 8 21 51)
(intervals 56 198 0)
(buffers 992 10))




Information forwarded to bug-gnu-emacs <at> gnu.org:
bug#60080; Package emacs. (Thu, 15 Dec 2022 07:34:01 GMT) Full text and rfc822 format available.

Message #8 received at 60080 <at> debbugs.gnu.org (full text, mbox):

From: Eli Zaretskii <eliz <at> gnu.org>
To: Sean Devlin <spd <at> toadstyle.org>
Cc: 60080 <at> debbugs.gnu.org
Subject: Re: bug#60080: 28.2; Double-click selection cannot be customized
Date: Thu, 15 Dec 2022 09:33:18 +0200
> From: Sean Devlin <spd <at> toadstyle.org>
> Date: Wed, 14 Dec 2022 19:40:22 -0500
> 
> I'd like to customize Emacs such that when I double-click on a word,
> the entire enclosing symbol is selected. In other words, it should
> behave more like the latter case of double-clicking on a character with
> symbol syntax.

Does the patch below do what you want?

If it does, we could provide this as an optional behavior, conditioned
by some new user option.

diff --git a/lisp/mouse.el b/lisp/mouse.el
index f72ab4f..ced7a92 100644
--- a/lisp/mouse.el
+++ b/lisp/mouse.el
@@ -1803,7 +1803,11 @@ mouse-skip-word
 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")
+    (cond ((bounds-of-thing-at-point 'symbol)
+           (goto-char (if (< dir 0)
+                          (car (bounds-of-thing-at-point 'symbol))
+                        (cdr (bounds-of-thing-at-point 'symbol)))))
+          ((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,




Information forwarded to bug-gnu-emacs <at> gnu.org:
bug#60080; Package emacs. (Thu, 15 Dec 2022 19:20:02 GMT) Full text and rfc822 format available.

Message #11 received at 60080 <at> debbugs.gnu.org (full text, mbox):

From: Sean Devlin <spd <at> toadstyle.org>
To: Eli Zaretskii <eliz <at> gnu.org>
Cc: 60080 <at> debbugs.gnu.org
Subject: Re: bug#60080: 28.2; Double-click selection cannot be customized
Date: Thu, 15 Dec 2022 14:19:16 -0500
Hi Eli,

> On Dec 15, 2022, at 2:33 AM, Eli Zaretskii <eliz <at> gnu.org> wrote:
> 
>> From: Sean Devlin <spd <at> toadstyle.org>
>> Date: Wed, 14 Dec 2022 19:40:22 -0500
>> 
>> I'd like to customize Emacs such that when I double-click on a word,
>> the entire enclosing symbol is selected. In other words, it should
>> behave more like the latter case of double-clicking on a character with
>> symbol syntax.
> 
> Does the patch below do what you want?
> 
> If it does, we could provide this as an optional behavior, conditioned
> by some new user option.

Yes, this seems to do the trick.

I agree that a user option would make sense.

Thanks for looking at this so quickly!

> 
> diff --git a/lisp/mouse.el b/lisp/mouse.el
> index f72ab4f..ced7a92 100644
> --- a/lisp/mouse.el
> +++ b/lisp/mouse.el
> @@ -1803,7 +1803,11 @@ mouse-skip-word
> 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")
> +    (cond ((bounds-of-thing-at-point 'symbol)
> +           (goto-char (if (< dir 0)
> +                          (car (bounds-of-thing-at-point 'symbol))
> +                        (cdr (bounds-of-thing-at-point 'symbol)))))
> +          ((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 sent to Eli Zaretskii <eliz <at> gnu.org>:
You have taken responsibility. (Fri, 16 Dec 2022 16:30:02 GMT) Full text and rfc822 format available.

Notification sent to Sean Devlin <spd <at> toadstyle.org>:
bug acknowledged by developer. (Fri, 16 Dec 2022 16:30:02 GMT) Full text and rfc822 format available.

Message #16 received at 60080-done <at> debbugs.gnu.org (full text, mbox):

From: Eli Zaretskii <eliz <at> gnu.org>
To: Sean Devlin <spd <at> toadstyle.org>
Cc: 60080-done <at> debbugs.gnu.org
Subject: Re: bug#60080: 28.2; Double-click selection cannot be customized
Date: Fri, 16 Dec 2022 18:28:47 +0200
> From: Sean Devlin <spd <at> toadstyle.org>
> Date: Thu, 15 Dec 2022 14:19:16 -0500
> Cc: 60080 <at> debbugs.gnu.org
> 
> >> I'd like to customize Emacs such that when I double-click on a word,
> >> the entire enclosing symbol is selected. In other words, it should
> >> behave more like the latter case of double-clicking on a character with
> >> symbol syntax.
> > 
> > Does the patch below do what you want?
> > 
> > If it does, we could provide this as an optional behavior, conditioned
> > by some new user option.
> 
> Yes, this seems to do the trick.
> 
> I agree that a user option would make sense.

Thanks, so I installed the change with the new option on the master
branch, and I'm therefore closing this bug.




bug archived. Request was from Debbugs Internal Request <help-debbugs <at> gnu.org> to internal_control <at> debbugs.gnu.org. (Sat, 14 Jan 2023 12:24:10 GMT) Full text and rfc822 format available.

This bug report was last modified 2 years and 153 days ago.

Previous Next


GNU bug tracking system
Copyright (C) 1999 Darren O. Benham, 1997,2003 nCipher Corporation Ltd, 1994-97 Ian Jackson.