help-gnu-emacs
[Top][All Lists]
Advanced

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

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


From: Xah Lee
Subject: Re: change "word" definition (syntax table) for double-click?
Date: Sat, 29 Nov 2008 18:13:21 -0800 (PST)
User-agent: G2/1.0


ead-gnu-em...@ixian.com wrote:
> Hello,
>
> How can I have a double-click on for instance the middle "o" in
> "http://www.foo.com/"; highlight the entirety of "http://www.foo.com/";
> rather than merely the word "foo"?
>
> I'm using this version of Emacs:
>     GNU Emacs 22.2.1 (i486-pc-linux-gnu, X toolkit, Xaw3d scroll bars)
>     of 2008-11-09 on raven, modified by Debian
>
> and I've looked at this web page:
>     Hacking the syntax table
>     http://www.emacswiki.org/emacs/EmacsSyntaxTable#toc3

syntax table is not much fitting here. You can do it like this:

(defun select-url ()
  "Mark the url under cursor."
  (interactive)
;  (require 'thingatpt)
  (let (bds)
      (setq bds (bounds-of-thing-at-point 'url))
      (set-mark (car bds))
      (goto-char (cdr bds))
      )
  )

am not sure how to bind it to double clicking though.

if you want to bind it mid button, you can:

(global-set-key (kbd "<mouse-2>") 'select-url)

the above code assumes you have transient-mark-mode on.

  Xah
∑ http://xahlee.org/

reply via email to

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