Hi all.
One more silly question. ;-)
I'm using folding marks within comments with my long-time emacs installation. I'm using this marks to group functions or other variable declarations.
/* ===================================================================== */ /* {{{ */
// the code...
/* }}} */
Is there a way to use these marks? I haven't found anything about "folding marks" in the manual.
Bye
On Monday 31 August 2009 04:39:33 am Joerg Desch wrote:
I'm using folding marks within comments with my long-time emacs installation. I'm using this marks to group functions or other variable declarations.
/*
*/ /* {{{ */
// the code...
/* }}} */
Is there a way to use these marks? I haven't found anything about "folding marks" in the manual.
I'm a newbie to Geany, and only a little experienced with Scintilla, but I'll try to answer your question anyway. (I am one of "all" ;-)
There are at least two answers (and I assume we're talking about C++ code).
You can revise or write a new lexer for Scintilla that handles those marks, or you can use the alternatives already defined in the C/C++ lexer for Scintilla, which are:
For opening:
//{
and, for closing:
//}
These don't work out of the box in Scintilla, you must set a specific property to make them work--let me see if I can find that...ahh, yes--you need to set the property "fold.comment=1" in a property file.
In Scite, I set it in my user property file: ~/.SciTEUSER.properties--I assume that Geany makes use of similar property files, somewhere, somehow.
There is a similar property available named fold.preprocessor=1 that is supposed to fold preprocessor stuff like #if #endif blocks--so far that hasn't worked for me, but I haven't tried very hard. ;-)
I'm almost sure these work only for C/C++ languages, specifically those lexed by the LexCPP.cxx lexer.
Hope this helps! Randy Kramer
Hi Randy.
On Mon, 31 Aug 2009 08:52:56 -0400 Randy Kramer rhkramer@gmail.com wrote:
You can revise or write a new lexer for Scintilla that handles those marks, or you can use the alternatives already defined in the C/C++ lexer for Scintilla, which are:
For opening:
//{
and, for closing:
//}
OK. I assume there is no option to configure this?
These don't work out of the box in Scintilla, you must set a specific property to make them work--let me see if I can find that...ahh, yes--you need to set the property "fold.comment=1" in a property file.
Is this a property which is available in the geany configuration files? Or do you mean a function call?
I'm almost sure these work only for C/C++ languages, specifically those lexed by the LexCPP.cxx lexer.
Hard to believe that this feature is implemented in the lexer. Most languages have single line comments, so it should be easy implements foldings marks for all languages. But this is only a thought.
Nevertheless, thanks for your answer.
Good morning, Joerg,
(At least it's morning for me ;-)
I probably shouldn't have jumped in to try to answer your questions--I guess I got out of my depth--knowing that Geany uses Scintilla, I assumed (I know) that the same possibilities existed for configuration by .properties files. Oh, wait, it looks like there are something like Scintilla's properties in the filetypes files in /user/share/geany. Also, there are some .conf files, including your personal .conf file, ~/geany.conf. You might check those out, or someone else might be know whether Scintilla properties can be utilized directly in one or the other of those files.
I'll add some comments below, but somebody else will have to chip in to answer your questions...
On Tuesday 01 September 2009 05:21:03 am Joerg Desch wrote:
On Mon, 31 Aug 2009 08:52:56 -0400 Randy Kramer rhkramer@gmail.com wrote:
You can revise or write a new lexer for Scintilla that handles those marks, or you can use the alternatives already defined in the C/C++ lexer for Scintilla, which are:
For opening:
//{
and, for closing:
//}
OK. I assume there is no option to configure this?
It's not mentioned in the documentation, so I suspect not. OTOH, (without having spent much time looking at the C/C++ lexer in Scintilla (geany/scintilla/LexCPP.cxx)), it might not be too hard to make a change and then recompile:
</code> if (foldComment && IsStreamCommentStyle(style)) { if (!IsStreamCommentStyle(stylePrev) && (stylePrev != SCE_C_COMMENTLINEDOC)) { levelNext++; } else if (!IsStreamCommentStyle(styleNext) && (styleNext != SCE_C_COMMENTLINEDOC) && !atEOL) { // Comments don't end at end of line and the next character may be unstyled. levelNext--; } } if (foldComment && (style == SCE_C_COMMENTLINE)) { if ((ch == '/') && (chNext == '/')) { char chNext2 = styler.SafeGetCharAt(i + 2); if (chNext2 == '{') { levelNext++; } else if (chNext2 == '}') { levelNext--; } } } <code>
Clearly (??), if your comment delimiter is longer than 3 characters, you'll need to check more than the 3 characters checked above, presumably using styler.SafeGetCharAt(i + 3) and higher.
BTW, in Scintilla, foldComment is set based on the value of the Scintilla property: fold.comment.
<also from LexCPP.cxx> bool foldComment = styler.GetPropertyInt("fold.comment") != 0;
BTW, LexCPP.cxx is used for C++, C, Java, and JavaScript.
These don't work out of the box in Scintilla, you must set a specific property to make them work--let me see if I can find that...ahh, yes--you need to set the property "fold.comment=1" in a property file.
Is this a property which is available in the geany configuration files? Or do you mean a function call?
I'm not sure, and don't have time to look atm (busy day)--I'd look in the geany *.conf and filetype.* (in ~ and /usr/share/geany)--you might be able to put Scintilla property "declarations" in those files directly (but maybe Geany does some sort of transformation and can't use the Scintilla properties directly?).
I'm almost sure these work only for C/C++ languages, specifically those lexed by the LexCPP.cxx lexer.
Hard to believe that this feature is implemented in the lexer. Most languages have single line comments, so it should be easy implements foldings marks for all languages. But this is only a thought.
Nevertheless, thanks for your answer.
Hope I haven't mislead you too much!
Randy Kramer
Hello Randy.
On Tue, 1 Sep 2009 07:20:39 -0400 Randy Kramer rhkramer@gmail.com wrote:
I probably shouldn't have jumped in to try to answer your questions--I guess I got out of my depth--knowing that Geany uses Scintilla, I assumed (I know) that the same possibilities existed for configuration by .properties files. Oh, wait, it looks like there are something like Scintilla's properties in the filetypes files in /user/share/geany. Also, there are some .conf files, including your personal .conf file, ~/geany.conf. You might check those out, or someone else might be know whether Scintilla properties can be utilized directly in one or the other of those files.
Thanx for the answer. I'll give it a try next week.
I'm not sure, and don't have time to look atm (busy day)
Same here. Paired with the 100% lack of spare time. :-(
Hope I haven't mislead you too much!
No. No problem.
On Tue, 1 Sep 2009 11:21:03 +0200 Joerg Desch jd.vvd@web.de wrote:
You can revise or write a new lexer for Scintilla that handles those marks, or you can use the alternatives already defined in the C/C++ lexer for Scintilla, which are:
For opening:
//{
and, for closing:
//}
This is correct, thanks Randy.
OK. I assume there is no option to configure this?
No, Scintilla doesn't have a lexer property for it AFAIK.
These don't work out of the box in Scintilla, you must set a specific property to make them work--let me see if I can find that...ahh, yes--you need to set the property "fold.comment=1" in a property file.
Is this a property which is available in the geany configuration files?
Geany doesn't support Scintilla's property names at all, but has its own filetype-specific settings, some of which may be similar - but in this case, the //{ user folding strings should just work for C/C++ files - or it does here anyway. There is no setting.
Regards, Nick
On Tuesday 01 September 2009 02:01:16 pm Nick Treleaven wrote:
On Tue, 1 Sep 2009 11:21:03 +0200 Joerg Desch jd.vvd@web.de wrote:
This is correct, thanks Randy.
You're welcome! But I learned more than I helped anyone else. ;-)
OK. I assume there is no option to configure this?
No, Scintilla doesn't have a lexer property for it AFAIK.
These don't work out of the box in Scintilla, you must set a specific property to make them work--let me see if I can find that...ahh, yes--you need to set the property "fold.comment=1" in a property file.
Like the above!
Is this a property which is available in the geany configuration files?
Geany doesn't support Scintilla's property names at all, but has its own filetype-specific settings, some of which may be similar - but in this case, the //{ user folding strings should just work for C/C++ files - or it does here anyway. There is no setting.
And the above!
regards, Randy Kramer
On Tue, 1 Sep 2009 19:01:16 +0100 Nick Treleaven nick.treleaven@btinternet.com wrote:
Geany doesn't support Scintilla's property names at all, but has its own filetype-specific settings, some of which may be similar - but in this case, the //{ user folding strings should just work for C/C++ files - or it does here anyway. There is no setting.
Thanks. It works! Even if an comment is following the opening mark. Great.
Nevertheless it would make much more sense, if Scintilla move the code for folding marks out of the lexxer. I personally use folding marks for C/C++, LaTeX, ...
For now I change my folding marks.
On Wed, 2 Sep 2009 07:26:52 +0200, Joerg wrote:
On Tue, 1 Sep 2009 19:01:16 +0100 Nick Treleaven nick.treleaven@btinternet.com wrote:
Geany doesn't support Scintilla's property names at all, but has its own filetype-specific settings, some of which may be similar - but in this case, the //{ user folding strings should just work for C/C++ files - or it does here anyway. There is no setting.
Thanks. It works! Even if an comment is following the opening mark. Great.
Nevertheless it would make much more sense, if Scintilla move the code for folding marks out of the lexxer. I personally use folding marks for
I guess there is a reason why folding code is lexer-specific in Scintilla. The languages which are handled by the various lexers are quite different. The most obvious example where it wouldn't work is Python. There are no brackets at all to define blocks.
But this is mostly a Scintilla topic and should be discussed there.
Regards, Enrico