[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
Font-locking different "sections" in a file
From: |
wisnij |
Subject: |
Font-locking different "sections" in a file |
Date: |
27 Jun 2006 11:45:19 -0700 |
User-agent: |
G2/0.2 |
We have a file format at my company which is almost free-form ASCII
with some markup, but it can get hairy enough that I am obliged to
write an Emacs mode with font-locking to help with editing it. The
problem is, files are broken into sections kind of like this:
# some header information
import(foo)
import(bar)
TEXT
some paragraphs of &{marked-up text}
etc etc
DATA
# tab-separated data
...and so forth. Which is to say, the only delimiter between
different sections is the tokens "TEXT", "DATA", etc. on lines by
themselves.
Each section differs slightly some the others syntactically: certain
tokens are keywords in the header section but not elsewhere; one can
normally start a comment with #, except within the TEXT block where it
is just a normal character; and so forth. There can still be
structure within that block, though, so it doesn't feel like calling
it all a string or comment is really the right way to go.
I've looked through the manual but I didn't really see anything
helpful, apart from the admonition not to use font-lock-keywords for
multi-line constructs. Is there an accepted way to define syntactic
"block" within a file like this?
- Font-locking different "sections" in a file,
wisnij <=