View Issue Details

IDProjectCategoryView StatusLast Update
0013974LazarusIDEpublic2009-06-13 18:14
ReporterAlexander S. KleninAssigned ToMartin Friebe 
Status assignedResolutionopen 
Product VersionProduct Build 
Target VersionFixed in Version 
Summary0013974: Region identifiers for code folding
DescriptionSince ,
{%REGION} directive supports /fold argument to signify that
it should be auto-folded.

It is proposed to:
1) For %REGION directive, either:
  1a) use description text as an identifier, or
  1b) allow an arbitrary identifier text
    separated from the description text by "/fold", "/id", "|" or similar.
2) Add "Auto-fold" option string, containing regexp.
2.1) For compatibility with current implementation, this string should
  by default be "/fold".
3) Automatically fold regions whose identifier text satisfies the regexp.
Additional InformationHere is an excerpt from IRC logs discussing this feature:

(2009-06-14 02:16:30) martin_frb: the region already has that
(2009-06-14 02:16:52) _Ask_: it would allow me to automatically fold/unfold even new code added by other developers, provided they mark their regions correctly
(2009-06-14 02:17:29) martin_frb: region has a flag, to inidcate it gets fold on load, and thats already working
(2009-06-14 02:17:54) _Ask_: martin: the problem is that single flag is not enough
(2009-06-14 02:18:04) martin_frb: ok, so what other flags you need?
(2009-06-14 02:18:11) martin_frb: plus that is for regions.
(2009-06-14 02:18:35) martin_frb: we can ofcourse add end of line comments like {%F b1} to fold the first begin in that line
(2009-06-14 02:18:48) _Ask_: as I said in the bug, simply an arbitrary string and and regexp-like option
(2009-06-14 02:20:56) martin_frb: yes that could be an extionsen, please add anew bug for this: /fold=some_id
(2009-06-14 02:21:12) martin_frb: and options to specify: white or blacklist
(2009-06-14 02:21:32) _Ask_: another example: class completion code might be extended to generate something like {%REGION TMyClass implementation} and {%REGION TMyClass interface} instead of just { TMyClass } as is currently
(2009-06-14 02:21:47) martin_frb: but it doesnt do for begin end folds // except if added comment like {%f b1} at the end of line
(2009-06-14 02:22:01) _Ask_: then one could easily: 1) fold all class implementations and/or interfaces
(2009-06-14 02:22:30) martin_frb: hm, the id, should be in some kind of "switch"
(2009-06-14 02:22:34) martin_frb: not in the free txt
(2009-06-14 02:22:48) _Ask_: 2) fold/unfold an implementation of concrete class (or group of classes with similar names)
(2009-06-14 02:22:59) martin_frb: so something like {%region foo bar abc /fold=IMPLEMENTATION }
(2009-06-14 02:23:12) martin_frb: maybe comma separated, or multiply /fald
(2009-06-14 02:23:23) _Ask_: as for {%f b1} idea -- it may have its uses too, but that is a separate topic
(2009-06-14 02:23:25) martin_frb: or /id=abc
(2009-06-14 02:23:37) martin_frb: yes, so we got 3 topics already
(2009-06-14 02:23:41) martin_frb: {B}
(2009-06-14 02:23:48) martin_frb: region /fold=id
(2009-06-14 02:23:56) martin_frb: and save seesion for begin end folds
(2009-06-14 02:23:57) _Ask_: martin: why not free text? it is the simplest and most powerful IMHO
(2009-06-14 02:24:24) martin_frb: because free text, or text in quotes, is waht the user should read, if the mark is folded.
(2009-06-14 02:24:27) martin_frb: try delphi
(2009-06-14 02:24:41) martin_frb: the free text is displayed in a rectangle
(2009-06-14 02:24:45) martin_frb: like [...]
(2009-06-14 02:25:22) martin_frb: and if it is added automatically eg codetools, then it can easily be /ID=abc
(2009-06-14 02:25:46) _Ask_: well-chosen texts may serve both roles ;-)
(2009-06-14 02:26:10) martin_frb: ok, but what is the problem with adding /id or -id ?
(2009-06-14 02:26:48) martin_frb: or -fold=abc
(2009-06-14 02:26:53) _Ask_: this is minor, so I agree to any case -- but if you add /id, please allow for _arbitrary text after that, not just one word
(2009-06-14 02:27:16) martin_frb:
(2009-06-14 02:27:32) martin_frb: -did='ab cd' /
(2009-06-14 02:27:48) martin_frb: -iid='ab cd' /
(2009-06-14 02:27:52) martin_frb: -id='ab cd' /
(2009-06-14 02:28:12) lazidealist: martin_frb: can you add an event for the indent on paste?
(2009-06-14 02:28:17) martin_frb: or an alternative
(2009-06-14 02:28:33) martin_frb: {%region -fold -id= abc def foo bar }
(2009-06-14 02:28:48) martin_frb: the -id is followed by a space => makes the whole res ID
(2009-06-14 02:29:18) _Ask_: maybe {%REGION Description text | list of ids}
(2009-06-14 02:29:31) martin_frb: lazidealist: at some stage yes. not immediate
(2009-06-14 02:29:44) lazidealist: no need to hurry
(2009-06-14 02:30:24) martin_frb: _Ask_: In general I prefer IDs, to be comma separated or the like, and noramlly ayou would specify an ID ase exact text, but I am happy to have reg-ex
(2009-06-14 02:30:44) martin_frb: => anywatif you will , pllease add to mantis,
(2009-06-14 02:31:44) martin_frb: lazidealist: on paste, you want a separate event => so one event for the WHOLE paste / or un thruoufgh the default one-line evnet, for each line top to bottom ?
(2009-06-14 02:31:46) lazidealist: I wonder if regex are too slow for for 100kloc
(2009-06-14 02:32:04) lazidealist: one event for the whole paste
(2009-06-14 02:32:07) _Ask_: I think Regexps might get useful for things like TChart* or *Error to fold/onlold corresponding groups of classes
(2009-06-14 02:32:13) martin_frb: lazidealist: Ok
(2009-06-14 02:32:37) _Ask_: lazidealist: it is to be applied only to %Region lines
(2009-06-14 02:32:47) martin_frb: _Ask_: I would use the simplified reg ex, with "*" insted of ".*"
(2009-06-14 02:33:15) martin_frb: _Ask_: and ids can not contain a comma, since tthat separates 2 ids
(2009-06-14 02:33:26) _Ask_: mertin: ok, afaics there is already a library for regexps in fpc
(2009-06-14 02:34:01) lazidealist: see
(2009-06-14 02:36:27) lazidealist: _Ask_: if the %region lines are auto created then you will easily end up with thousands of them
(2009-06-14 02:38:08) _Ask_: then the only way to know is to test. as for the regexp syntax, the one in the link you provided is quite sufficient
TagsNo tags attached.
Fixed in Revision
Attached Files


child of 0013975 acknowledged Insert regions in code generated by class completion 


There are no notes attached to this issue.

Issue History

Date Modified Username Field Change
2009-06-13 18:00 Alexander S. Klenin New Issue
2009-06-13 18:00 Alexander S. Klenin LazTarget => -
2009-06-13 18:08 Alexander S. Klenin Relationship added child of 0013975
2009-06-13 18:14 Martin Friebe Status new => assigned
2009-06-13 18:14 Martin Friebe Assigned To => Martin Friebe