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

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

Re: How do I highlight word at point?


From: Xah
Subject: Re: How do I highlight word at point?
Date: Mon, 20 Oct 2008 11:43:55 -0700 (PDT)
User-agent: G2/1.0

On Oct 20, 5:31 am, Nikolaj Schumacher <m...@nschum.de> wrote:
> Xah<xah...@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))))

ummm... doesn't seems to work?

suppose i have

( "this that" [more ])

and cursor is on the word “that”.

I invoke this command twice, it selects the whole paren?

  Xah
∑ http://xahlee.org/

reply via email to

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