unofficial mirror of help-gnu-emacs@gnu.org
 help / color / mirror / Atom feed
From: Þorne <ego111@gmail.com>
Subject: Re: regexp problem
Date: 12 Aug 2006 04:02:32 -0700	[thread overview]
Message-ID: <1155380552.029014.309450@i3g2000cwc.googlegroups.com> (raw)
In-Reply-To: 87lkpu460l.fsf@thalassa.informatimago.com


Pascal Bourguignon wrote:
> "Þorne" <ego111@gmail.com> writes:
>
> > Pascal Bourguignon wrote:
> >> You can match groups:
> >>
> >> a\(b\)c
> >>
> >> so the match number 0 is the whole regexp: abc
> >> but the match number 1 is only b
> >
> > Sorry to be dense, but do you mean something like this:
> >
> > (search-forward-regexp "a\\(b\\)c\\0")
>
>
> (when (search-forward-regexp "a\\(b\\)c")
>   (let ((all    (match-string 0))
>         (only-b (match-string 1)))
>     (goto-char (match-end 0))
>     (insert (format "\nall = %s\nonly-b = %s\n" all only-b))))
>
>
>
> > because i can't get anything like it to work.  I don't really follow
> > the documentation for the \<digit> construct in regexps at all...
> >
> > In fact the code above finds a string that looks like `abc0' instead of
> > just `b'.
> >
> > Specifically i am trying to make a regexp for define-generic-mode to
> > colorize the string`*' but only if it is in a string that looks like
> > `(*)'.  But not colorize the surrounding parens.
>
> Read with utmost attention the help about the variable font-lock-keywords.
>
>  (MATCHER . SUBEXP)
>
>  ("fu\\(bar\\)" . 1)	substring "bar" within all occurrences of "fubar" in
>                        	the value of `font-lock-keyword-face'.

Ah!  Thank you!  Got it finally.

(Turned out specifically what i needed for doing it (with
font-lock-type-face in my case) was:

(define-generic-mode 'foo
nil nil

(list
blah-blah
  '("(\\(\\*\\))" 1 font-lock-type-face))

blah-blah))

Thanks again!

      reply	other threads:[~2006-08-12 11:02 UTC|newest]

Thread overview: 5+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2006-08-12  3:33 regexp problem Þorne
2006-08-12  3:56 ` Pascal Bourguignon
2006-08-12  9:46   ` Þorne
2006-08-12 10:12     ` Pascal Bourguignon
2006-08-12 11:02       ` Þorne [this message]

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

  List information: https://www.gnu.org/software/emacs/

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=1155380552.029014.309450@i3g2000cwc.googlegroups.com \
    --to=ego111@gmail.com \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).