jed-users mailing list

[2005 Date Index] [2005 Thread Index] [Other years]
[Thread Prev] [Thread Next]      [Date Prev] [Date Next]

Regexp support for folding


Hi,

Another small hack I did this weekend was adding regexp support to
folding.sl.

as you may remember, mark info is something like 
"<start>\r<end_of_start>\r<end>\r<end_of_end>"

After patching it, regular expression based markers can be defined using 
an empty <start> and <end> (a condition not allowed for string based
markers). 
In <end_of_start> and <end_of_end> must be a string with a context flag 
(first character) followed by the regular expression.
The first character is used to test the context (using parse_to_point()), 
and must be one of:
  - '%': This is a valid marker if context is on a comment.
  - '"': as above for string
  - '#': as above normal code.
  - ' ': Don't test.

For example, you can try this for SLang mode (and almost the same for C).

mode_set_mode_info ("SLang", "fold_info", "\r\r#{[ \t]*$\r#^[ \t]*}");

It will start a fold for every '{' in normal code at the end of line
(skipping whitespaces).
the end of fold are '}' at beginning of line (again skipping whitespaces).

Hope this is useful!
							Dino


Attachment: folding-regexp.diff
Description: Binary data


[2005 date index] [2005 thread index]
[Thread Prev] [Thread Next]      [Date Prev] [Date Next]