Drew Adams | 1 Dec 19:29
Favicon

RE: change "word" definition (syntax table) for double-click?

> What I want is for double-clicking with the mouse to highlight,
> as a word, all contiguous non-whitespace characters.

By "highlight", I think you mean "select", as in setting the active region to
that text.

> Some sample applications I want this for are:
> o   Double-clicking in the middle of URLs.
> o   Double-clicking in the middle of RFC822-compliant email addresses.
> o   Double-clicking in the middle of passwords and other strings
>     having non-alphanumeric characters.

Easy solution: `M-x goto-address'. That will put links on URLs and email
addresses, which you can then click (single-click) with mouse-2 (and mouse-1, if
`mouse-1-click-follows-link' is non-nil). See the Emacs manual, node
Hyperlinking, and its subnodes.

If you don't like that for some reason, and you really want to change
double-clicking mouse-2 so that it selects such things, then read on.

Emacs already does that too, at least for many URLs etc. and at least in some
modes, such as Emacs-Lisp mode. That is, provided you double-click (with
mouse-2) on a symbol-constituent character, such as :/.?=@. If you instead
double-click a word-constituent character, then just that word is selected.

For example, in Emacs-Lisp mode, if you double-click the URL
http://www.emacswiki.org/emacs/SiteMap at the : or a / or a ., then the whole
URL is selected. And in the email address help-gnu-emacs <at> gnu.org, if you
double-click a - or the @ or the ., then the whole address is selected.

(Continue reading)

Drew Adams | 1 Dec 19:39
Favicon

RE: change "word" definition (syntax table) for double-click?

I wrote:

> Easy solution: `M-x goto-address'. That will put links on 
> URLs and email addresses, which you can then click (single-click) with 
> mouse-2 (and mouse-1, if `mouse-1-click-follows-link' is non-nil).
> See the Emacs manual, node Hyperlinking, and its subnodes.

BTW, I see that Emacs 23 has improved this by providing minor mode
`goto-address-mode'. Repeat it to turn off the highlighting, mouse sensitivity,
C-c RET, etc.

Unfortunately, the Emacs 23 Emacs manual is not yet up-to-date on this - it
doesn't mention `goto-address-mode', which leaves you knowing no way to turn it
off. I'll file a doc bug for that.

Drew Adams | 1 Dec 19:52
Favicon

RE: change "word" definition (syntax table) for double-click?

> See the Emacs manual, node Hyperlinking, and its subnodes.

I should also have mentioned that FFAP is an alternative to using
`goto-address(-mode)'. Load library ffap, then evaluate (ffap-bindings). 

Then you can use `S-mouse-3' to follow URLs and email addresses. The differences
from `goto-address(-mode)' are that there is no highlighting and mouse-2 keeps
its normal behavior.


Gmane