all messages for Emacs-related lists mirrored at yhetil.org
 help / color / mirror / code / Atom feed
From: Kevin Rodgers <ihs_4664@yahoo.com>
Subject: Re: regexp match failure
Date: Wed, 22 Nov 2006 09:59:25 -0700	[thread overview]
Message-ID: <ek1vms$dib$1@sea.gmane.org> (raw)
In-Reply-To: <1164206793.546304.289140@m7g2000cwm.googlegroups.com>

sandro.dentella wrote:
 >   I can't understand wht's wrong with the following regexp:
 >
 > (define-derived-mode mutt-mode text-mode "Mutt"
 >   (make-face 'mutt-variable-face)
 >   (font-lock-add-keywords
 >    nil
 >    '(
 >     ("^\\(Date\\|Status:\\)" 1 font-lock-keyword-face)

Don't you mean "^\\(Date\\|Status\\):", with either SUBEXP = 1 as-is to
leave the colon unfontified or 0 to fontify it?

 >     ("^\\(\\S+:\\)" 1 font-lock-keyword-face)
 >   ))
 >   (font-lock-mode 1)
 > )
 >
 > The first ine works, it colors Date: and Status:, the second line
 > should in my opinion be just a generalized version of the first line
 > but it does not work.

`\S' is not a valid regexp, it needs a following syntax code.  And since
you apparently want to match characters which *are* letters rather than
those which are *not*, `\s' is the appropriate construct with the `w'
code: "^\\sw+:"

Again, don't be afraid to use 0 as the font-lock-keywords SUBEXP and
avoid `\(...\)' groupings when they're not necessary.

 > BTW, i'd have written:
 >
 >   "^[-\\S]+:"
 >
 > but it doens't work eather. Can anybody explain me what I'm missing?

Inside of the `[...]' construct, backslash constructs are not special
(RTFM).  But in Emacs 22 you can do this: "^[[:alnum:]]+:"

-- 
Kevin

  reply	other threads:[~2006-11-22 16:59 UTC|newest]

Thread overview: 3+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2006-11-22 14:46 regexp match failure sandro.dentella
2006-11-22 16:59 ` Kevin Rodgers [this message]
     [not found] ` <mailman.999.1164214909.2155.help-gnu-emacs@gnu.org>
2006-11-22 18:50   ` sandro.dentella

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

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

  git send-email \
    --in-reply-to='ek1vms$dib$1@sea.gmane.org' \
    --to=ihs_4664@yahoo.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.
Code repositories for project(s) associated with this external index

	https://git.savannah.gnu.org/cgit/emacs.git
	https://git.savannah.gnu.org/cgit/emacs/org-mode.git

This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.