From mboxrd@z Thu Jan 1 00:00:00 1970 Path: news.gmane.org!not-for-mail From: Xah Lee Newsgroups: gmane.emacs.help Subject: Re: change "word" definition (syntax table) for double-click? Date: Sun, 30 Nov 2008 21:57:55 -0800 (PST) Organization: http://groups.google.com Message-ID: <3108c215-e417-420a-9043-1e839f705407@y1g2000pra.googlegroups.com> References: <4b1a4393-25d7-4554-9e2d-b965504e7f0e@a29g2000pra.googlegroups.com> NNTP-Posting-Host: lo.gmane.org Mime-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: quoted-printable X-Trace: ger.gmane.org 1228146617 2058 80.91.229.12 (1 Dec 2008 15:50:17 GMT) X-Complaints-To: usenet@ger.gmane.org NNTP-Posting-Date: Mon, 1 Dec 2008 15:50:17 +0000 (UTC) To: help-gnu-emacs@gnu.org Original-X-From: help-gnu-emacs-bounces+geh-help-gnu-emacs=m.gmane.org@gnu.org Mon Dec 01 16:51:20 2008 Return-path: Envelope-to: geh-help-gnu-emacs@m.gmane.org Original-Received: from lists.gnu.org ([199.232.76.165]) by lo.gmane.org with esmtp (Exim 4.50) id 1L7B3N-0002Rp-S5 for geh-help-gnu-emacs@m.gmane.org; Mon, 01 Dec 2008 16:51:18 +0100 Original-Received: from localhost ([127.0.0.1]:41061 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.43) id 1L7B2D-0004dc-BH for geh-help-gnu-emacs@m.gmane.org; Mon, 01 Dec 2008 10:50:05 -0500 Original-Path: news.stanford.edu!newsfeed.stanford.edu!postnews.google.com!y1g2000pra.googlegroups.com!not-for-mail Original-Newsgroups: gnu.emacs.help,comp.emacs Original-Lines: 95 Original-NNTP-Posting-Host: 24.6.185.159 Original-X-Trace: posting.google.com 1228111075 31924 127.0.0.1 (1 Dec 2008 05:57:55 GMT) Original-X-Complaints-To: groups-abuse@google.com Original-NNTP-Posting-Date: Mon, 1 Dec 2008 05:57:55 +0000 (UTC) Complaints-To: groups-abuse@google.com Injection-Info: y1g2000pra.googlegroups.com; posting-host=24.6.185.159; posting-account=bRPKjQoAAACxZsR8_VPXCX27T2YcsyMA User-Agent: G2/1.0 X-HTTP-UserAgent: Mozilla/5.0 (Macintosh; U; PPC Mac OS X 10_4_11; en) AppleWebKit/525.27.1 (KHTML, like Gecko) Version/3.2.1 Safari/525.27.1, gzip(gfe), gzip(gfe) Original-Xref: news.stanford.edu gnu.emacs.help:164949 comp.emacs:97413 X-Mailman-Approved-At: Mon, 01 Dec 2008 10:44:41 -0500 X-BeenThere: help-gnu-emacs@gnu.org X-Mailman-Version: 2.1.5 Precedence: list List-Id: Users list for the GNU Emacs text editor List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Original-Sender: help-gnu-emacs-bounces+geh-help-gnu-emacs=m.gmane.org@gnu.org Errors-To: help-gnu-emacs-bounces+geh-help-gnu-emacs=m.gmane.org@gnu.org Xref: news.gmane.org gmane.emacs.help:60286 Archived-At: On Nov 30, 9:08 pm, ead-gnu-em...@ixian.com wrote: > Xah, > > ] 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"? > > Thanks for your reply. I appreciate it. Unfortunately, I see that I > sent > you (and everyone else) down the wrong path with my poor wording. Let > me > try again. > > The double-clicking-on-a-URL was just one sample application. What I > want is for double-clicking with the mouse to highlight, as a word, > all > contiguous non-whitespace characters. > > 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. > > In short, I want the same double-clicking control inside emacs that > character classes give me inside xterm and cutchars give me inside > rxvt. > > xterm(1) > CHARACTER CLASSES > Clicking the left pointer button twice in rapid > succession (double-clicking) causes all characters of > the same class (e.g., letters, white space, punctuation) > to be selected as a ``word''. Since different people > have different preferences for what should be selected > (for example, should filenames be selected as a whole or > only the separate subnames), the default mapping can be > overridden through the use of the charClass (class > CharClass) resource. > > rxvt(1) > cutchars: string > The characters used as delimiters for double-click word > selection (whitespace delimiting is added automatically > if resource is given). > > Thank you for any pointers, > Eric That's easy. here's a sample code: (defun get-english-word-boundary () "Return the boundary of the current word. The return value is of the form: (cons pos1 pos2). A =E2=80=9Cword=E2=80=9D is a sequence of letters and hyphen. " (save-excursion (let (p1 p2) (progn (skip-chars-backward "-A-Za-z") (setq p1 (point)) (skip-chars-forward "-A-Za-z") (setq p2 (point))) (cons p1 p2) )) ) (defun select-word () "Mark the url under cursor." (interactive) ; (require 'thingatpt) (let (bds) (setq bds (get-english-word-boundary)) (set-mark (car bds)) (goto-char (cdr bds)) ) ) you can add chars to the skip-chars-backward and skip-chars-forward so that it'll skip to what you consider word boundary. If you want everything except whitspace, you can use like: (skip-chars-backward "^\n\t") unless you are writing a mode, syntax table is probably not a good choice here. Xah =E2=88=91 http://xahlee.org/ =E2=98=84