On 13. Feb 2007, at 15:07, Pierre Mareschal wrote:
In JavaScript, I'd like to be able to fold not only functions (that works great) but also "variables" as declared in json for example.
function Bookmark(p_idx, p_type, p_text) { this.index = p_idx; this.bookmarkType = p_type; this.text = p_text; } folds great, but: var UNITS_METRIC = { name: "metric", distance: " m.", speed: " m/min.", weight: " kg.", pressure: " bar" } does not fold when JavaScript language is selected but folds when HTML language is selected!
So what you call “variables” is effectively folding on { and }?
Wouldn't it be possible to add a "rule" to be able to fold such variables in JavaScript language as it works in the HTML language? How?
The manual has a section about it: http://macromates.com/textmate/ manual/navigation_overview#customizing_foldings
With JavaScript, the folding is done on the function keyword (iirc), so additionally folding on { would be problematic (as a function then causes two fold start markers) -- but one could remove folding for the function keyword.
Are JavaScript developers married to the concept of folding on ‘function’ instead of the brackets?