unofficial mirror of bug-gnu-emacs@gnu.org 
 help / color / mirror / code / Atom feed
From: Jorgen Schaefer <forcer@forcix.cx>
To: bug-gnu-emacs@gnu.org
Subject: Font-lock should ignore missing submatches
Date: Sun,  3 Feb 2008 20:30:56 +0000 (UTC)	[thread overview]
Message-ID: <20080203203056.0DDA72BFE5@sarg.kollektiv-hamburg.de> (raw)

Hello!
When using font-lock-mode to highlight complex expressions, the
font locking engine crashes when one of the subexpressions
specified was not matched.

Consider:

  (set (make-local-variable 'font-lock-keywords)
       '(("\\(?:\\(foo\\) *\\)?\\(bar\\)"
         (1 font-lock-comment-face)
         (2 font-lock-string-face))))

I.e. "possibly match the foo that is followed by whitespace, then
definitively match a bar."

This will (correctly) highlight these expressions:

  foobar
  foo bar
  etc.

But font-lock will error out if the first subexpression does not
match anything, even though the regular expression matches:

  oobar
  oo bar
  bar
  etc.

The code will give an appropriate error:

  Error during redisplay: (error No match 1 in highlight (1
  font-lock-comment-face))

Is there any chance to make font-lock just ignore unmatched
subexpressions?

Tested in:
- GNU Emacs 22.1.1
- GNU Emacs from CVS, approx. two weeks old

Sorry, no current CVS version here :-(

Regards,
        -- Jorgen




             reply	other threads:[~2008-02-03 20:30 UTC|newest]

Thread overview: 2+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2008-02-03 20:30 Jorgen Schaefer [this message]
2008-02-04  5:12 ` Font-lock should ignore missing submatches Chong Yidong

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=20080203203056.0DDA72BFE5@sarg.kollektiv-hamburg.de \
    --to=forcer@forcix.cx \
    --cc=bug-gnu-emacs@gnu.org \
    /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 public inbox

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

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).