[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: |
Mon, 20 Oct 2008 14:31:21 +0200 |
User-agent: |
Gnus/5.11 (Gnus v5.11) Emacs/22.3 (darwin) |
Xah <xahlee@gmail.com> wrote:
> is it possible to make it work with selecting a string?
Yes. It seems so, but the code gets very complicated if you try to do
the right thing in all places. For instance, inside strings, you might
prefer the text-mode syntax table for best results.
I've written a bit more of this and might turn it into a package once it's
more tested.
(defun semnav-up (arg)
(interactive "p")
(when (nth 3 (syntax-ppss))
(if (> arg 0)
(progn
(skip-syntax-forward "^\"")
(goto-char (1+ (point)))
(decf arg))
(skip-syntax-backward "^\"")
(goto-char (1- (point)))
(incf arg)))
(up-list arg))
(defun semnav-mark (arg &optional incremental)
"Mark the symbol surrounding point.
Subsequent calls mark higher levels of sexps."
(interactive (list (prefix-numeric-value current-prefix-arg)
(or (and transient-mark-mode mark-active)
(eq last-command this-command))))
(if incremental
(progn
(semnav-up (- arg))
(forward-sexp)
(mark-sexp -1))
(if (> arg 1)
(semnav-mark (1- arg) t)
(if (looking-at "\\=\\(\\s_\\|\\sw\\)*\\_>")
(goto-char (match-end 0))
(unless (memq (char-before) '(?\) ?\"))
(forward-sexp)))
(mark-sexp -1))))
> “Semantic”? is that a elisp package?
Yes. It is part of CEDET.
http://cedet.sourceforge.net/semantic.shtml
regards,
Nikolaj Schumacher
- Re: How do I highlight word at point?, (continued)
Re: How do I highlight word at point?, Xah, 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/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 <=
- 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