* bug#60080: 28.2; Double-click selection cannot be customized
@ 2022-12-15 0:40 Sean Devlin
2022-12-15 7:33 ` Eli Zaretskii
0 siblings, 1 reply; 4+ messages in thread
From: Sean Devlin @ 2022-12-15 0:40 UTC (permalink / raw)
To: 60080
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))
^ permalink raw reply [flat|nested] 4+ messages in thread
* bug#60080: 28.2; Double-click selection cannot be customized
2022-12-15 0:40 bug#60080: 28.2; Double-click selection cannot be customized Sean Devlin
@ 2022-12-15 7:33 ` Eli Zaretskii
2022-12-15 19:19 ` Sean Devlin
0 siblings, 1 reply; 4+ messages in thread
From: Eli Zaretskii @ 2022-12-15 7:33 UTC (permalink / raw)
To: Sean Devlin; +Cc: 60080
> From: Sean Devlin <spd@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,
^ permalink raw reply related [flat|nested] 4+ messages in thread
* bug#60080: 28.2; Double-click selection cannot be customized
2022-12-15 7:33 ` Eli Zaretskii
@ 2022-12-15 19:19 ` Sean Devlin
2022-12-16 16:28 ` Eli Zaretskii
0 siblings, 1 reply; 4+ messages in thread
From: Sean Devlin @ 2022-12-15 19:19 UTC (permalink / raw)
To: Eli Zaretskii; +Cc: 60080
Hi Eli,
> On Dec 15, 2022, at 2:33 AM, Eli Zaretskii <eliz@gnu.org> wrote:
>
>> From: Sean Devlin <spd@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,
^ permalink raw reply [flat|nested] 4+ messages in thread
* bug#60080: 28.2; Double-click selection cannot be customized
2022-12-15 19:19 ` Sean Devlin
@ 2022-12-16 16:28 ` Eli Zaretskii
0 siblings, 0 replies; 4+ messages in thread
From: Eli Zaretskii @ 2022-12-16 16:28 UTC (permalink / raw)
To: Sean Devlin; +Cc: 60080-done
> From: Sean Devlin <spd@toadstyle.org>
> Date: Thu, 15 Dec 2022 14:19:16 -0500
> Cc: 60080@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.
^ permalink raw reply [flat|nested] 4+ messages in thread
end of thread, other threads:[~2022-12-16 16:28 UTC | newest]
Thread overview: 4+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2022-12-15 0:40 bug#60080: 28.2; Double-click selection cannot be customized Sean Devlin
2022-12-15 7:33 ` Eli Zaretskii
2022-12-15 19:19 ` Sean Devlin
2022-12-16 16:28 ` Eli Zaretskii
Code repositories for project(s) associated with this public inbox
https://git.savannah.gnu.org/cgit/emacs.git
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).