The June 18 version of LexMetapost allows parsing partial words as Metapost
commands. For instance, while the word "for" is marked once as fold
beginning at which the current fold level is increased by 1, "endfor" is
marked twice, first as a whole word "endfor", which is recognized as fold
ending, at which the current fold level is to be reduced, second as a
partial word "for", at which the current fold level is increased by 1 again.
Thus in order to fold "for ... endfor" structure correctly, the current fold
level at "endfor" must be reduced by 2. ;Though this machanism works most of
the times, in some cases one might encounter some words containing either
"for" or "end" as a part, and then it is difficult to get the fold level
marching correctly.
Now I have coded a new version of the folding lexer. In the new version
ParseMetapostWord is only executed in one of the following 4 cases: 1) at
file beginning (mostly for parsing "beginfig"); 2) after \r or \n; 3)after
an empty char ' '; 4) after '(' or '$' (mostly for "btex ... etex"
structure). Moreover, all built-in folding marks like beginfig ... endfig,
btex ... etex are now moved to keywordlists in order that users can take
full control of the folding. I attach the new Lexer code as an attachment.
User defined folding points are defined in
keywords4.$(file.patterns.metapost) [fold beginning] and
keywords5.$(file.patterns.metapost) [fold ending] respectively. These
keywordlists are not used for other purposes, so this would not course any
interferences with other styling codes. For testing the attached code, the
following lines need to be put in the properties file, preferably in
metapost.properties:
## -------- begin ----------------------------
## Metapost fold points
## keywords4 = fold beginning; keywords5 = fold ending.
keywords4.$(file.patterns.metapost)=beginfig for verbatimtex def begingroup
if btex forsuffixes \
vardef primarydef
keywords5.$(file.patterns.metapost)=etex fi endfig endgroup end endfor endif
enddef
## -------- end -----------------------------
http://www.nabble.com/file/p11533387/LexMetapost.cxx LexMetapost.cxx
--
View this message in context:
http://www.nabble.com/Metapost-folding-tf3937956.html#a11533387
Sent from the Scintilla - Dev mailing list archive at Nabble.com.
_______________________________________________
Scintilla-interest mailing list
[email protected]
http://mailman.lyra.org/mailman/listinfo/scintilla-interest