[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
Re: How do I highlight word at point?
From: |
Nikolaj Schumacher |
Subject: |
Re: How do I highlight word at point? |
Date: |
Sun, 19 Oct 2008 19:00:58 +0200 |
User-agent: |
Gnus/5.11 (Gnus v5.11) Emacs/22.3 (darwin) |
Xah <xahlee@gmail.com> wrote:
> (defun select-word ()
> "Select a word under cursor.
> “word” here is considered any alphenumeric sequence with “_” or “-”."
> (interactive)
> (let (b1 b2)
> (skip-chars-backward "-_A-Za-z0-9")
> (setq b1 (point))
> (skip-chars-forward "-_A-Za-z0-9")
> (setq b2 (point))
> (set-mark b1)
> )
> )
Why not use syntactic tables to determine what a word is? That way it
would work for non-English languages and use less code.
(defun mark-current-word ()
"Place the region around the word at point."
(interactive)
(forward-word 1)
(mark-word -1))
I think I'll also use this (replacing M-@). But it should still be able
to grow the region... Let's see:
(defun mark-current-word (arg &optional incremental)
"Place the region around the word at point.
ARG determines how many following words to include. When INCREMENTAL is
non-nil, extend the existing region."
(interactive (list (prefix-numeric-value current-prefix-arg)
(or (and transient-mark-mode mark-active)
(eq last-command this-command))))
(and incremental
(> (* (signum arg) (- (mark) (point))) 0)
(exchange-point-and-mark))
(forward-word arg)
(unless incremental
(mark-word (- arg))))
(global-set-key "\M-@" 'mark-current-word)
(improvements welcome)
regards,
Nikolaj Schumacher
Re: How do I highlight word at point?, Francis Moreau, 2008/10/29
Re: How do I highlight word at point?, Scott Frazer, 2008/10/30
Re: How do I highlight word at point?, Xah, 2008/10/19
- Re: How do I highlight word at point?,
Nikolaj Schumacher <=
- Message not available
- Re: How do I highlight word at point?, Xah, 2008/10/19
- RE: How do I highlight word at point?, Drew Adams, 2008/10/19
- Re: How do I highlight word at point?, Nikolaj Schumacher, 2008/10/19
- Message not available
- Re: How do I highlight word at point?, Xah, 2008/10/20
- Re: How do I highlight word at point?, Nikolaj Schumacher, 2008/10/20
- Message not available
- Re: How do I highlight word at point?, Xah, 2008/10/20
- Re: How do I highlight word at point?, Nikolaj Schumacher, 2008/10/21
RE: How do I highlight word at point?, Drew Adams, 2008/10/19
Re: How do I highlight word at point?, htbest2000, 2008/10/21