Hi!
I do development work on both MS Windows and Ubuntu. I have had Geany installed on Ubuntu for a while (but not used it much). I was looking for Editors/IDEs that could support HTML, CSS, PHP and Python on both operating systems. Geany poped-up in several search results.
I've downloaded Geany for Windows and installed it - looks great. However, I am now having a problem getting snippets to work. I can find instructions for Linux and have tried the Windows equivalent (the snippets.conf file located in the C:\Documents and Settings\Peter\Application Data\Geany directory). Nothing happens, I don't know how to activate the snippets.
Any help would be greatly appreciated.
Regards, Peter
G'day Peter,
[...] However, I am now having a problem getting snippets to work. I can find instructions for Linux and have tried the Windows equivalent (the snippets.conf file located in the C:\Documents and Settings\Peter\Application Data\Geany directory). Nothing happens, I don't know how to activate the snippets.
Firstly, you need to tell Geany to reload its configuration for it to load your newly created snippets. This happens when you close and restart Geany, or you can select Tools -> Reload Configuration on the menu.
Next, you need to press the TAB key after typing a snippet, and it should replace the snippet.
NB: You need your snippet to be defined for the filetype of your file - e.g. if you're editing a C++ file, you need your snippet in either the [C++] section or the [Default] section of the snippet.conf file.
Ross McKay wrote:
G'day Peter,
[...] However, I am now having a problem getting snippets to work. I can find instructions for Linux and have tried the Windows equivalent (the snippets.conf file located in the C:\Documents and Settings\Peter\Application Data\Geany directory). Nothing happens, I don't know how to activate the snippets.
Firstly, you need to tell Geany to reload its configuration for it to load your newly created snippets. This happens when you close and restart Geany, or you can select Tools -> Reload Configuration on the menu.
Next, you need to press the TAB key after typing a snippet, and it should replace the snippet.
NB: You need your snippet to be defined for the filetype of your file - e.g. if you're editing a C++ file, you need your snippet in either the [C++] section or the [Default] section of the snippet.conf file.
Ross,
Thanks for your quick reply. It works as you describe. How simple was that?
On Windows I have been using EditPlus (a damn fine editor, but Windows only). It uses a similar feature to snippets (clip libraries) and I have defined several clips that I find useful. If I convert these to Greany snippet format is there anywhere I can post them?
Thanks again,
Peter
G'day Peter,
Thanks for your quick reply. It works as you describe. How simple was that?
Same timezone, so I figured I'd better step in. I usually just lurk :)
On Windows I have been using EditPlus (a damn fine editor, but Windows only). It uses a similar feature to snippets (clip libraries) and I have defined several clips that I find useful. If I convert these to Greany snippet format is there anywhere I can post them?
Maybe one of the regulars can help you out there. What language(s) are the snippets for, and in what domain?
I have to admit that I seriously underutilise the snippets feature, mainly I have it for a couple of things I can never remember the syntax of, plus "lorem ipsum ..." :)
On Thu, 01 Jan 2009 16:52:51 +1100 Ross McKay rosko@zeta.org.au wrote:
I have to admit that I seriously underutilise the snippets feature, mainly I have it for a couple of things I can never remember the syntax of, plus "lorem ipsum ..." :)
Lorem ipsum will get a plugin soon. A early development version is already to find inside geany-plugins subversion ;)
Cheers, Frank
Hi,
On Thu, 01 Jan 2009 16:07:38 +1100 Peter Anderson peter.anderson@internode.on.net wrote:
On Windows I have been using EditPlus (a damn fine editor, but Windows only). It uses a similar feature to snippets (clip libraries) and I have defined several clips that I find useful. If I convert these to Greany snippet format is there anywhere I can post them?
Depending on the kind of snippets ;) At http://www.geany.org/Download/Extras there is already a little collection for snippets. I think we could add there also over there.
Thanks, Frank
Frank Lanitz wrote:
Lorem ipsum will get a plugin soon. A early development version is already to find inside geany-plugins subversion ;)
Why would lorem ipsum need a plugin? It works fine as a snippet - type in lorem, press tab... voila! Lorem ipsum dolor sit amet, consectetur adipisicing elit, sed do eiusmod tempor incididunt ut labore et dolore magna aliqua. Ut enim ad minim veniam, quis nostrud exercitation ullamco laboris nisi ut aliquip ex ea commodo consequat. Duis aute irure dolor in reprehenderit in voluptate velit esse cillum dolore eu fugiat nulla pariatur. Excepteur sint occaecat cupidatat non proident, sunt in culpa qui officia deserunt mollit anim id est laborum.
Or am I missing some essential functionality? -- Ross McKay, Toronto, NSW Australia "The lawn could stand another mowing; funny, I don't even care" - Elvis Costello
So, after this mailing list made me aware of the super great snipped feature, I decided to get a bit into Geany hacking to expand the snipped featureset.
What my patch does is basically allow more than 1 cursor position and move to the next one using a hotkey. Little example:
for(i = 0; i < [cursor1]; i++) { [cursor2] } [cursor3]
After doing for<tab>, the cursor ends up at cursor1, now you insert your text (e.g. MAX_COUNT), and hit ctrl+tab and move to cursor2, doing your stuff.
That saves a lot of movement with the arrow keys! The snippet.conf syntax doesn't change, you're just going to add more %cursor%.
However, the current patch is far from intelligent and nice. It's a bit hackish (limited to 10 cursors, global struct in editor.c ...), and the next cursor movement is apparently broken once you hit tab normally between "jumps". To be investigated! Also, I changed the hotkey of "go to last used tab" to nothing, so that ctrl+tab is free for this (this is the best hotkey I can find for), feel free to discuss!
This being my first code contribution to Geany, I'd really like to get some feedback! Don't hit me if it's bad though ;)
PS: Geany is great :D
Thomas Martitz schrieb:
So, after this mailing list made me aware of the super great snipped feature, I decided to get a bit into Geany hacking to expand the snipped featureset.
What my patch does is basically allow more than 1 cursor position and move to the next one using a hotkey. Little example:
for(i = 0; i < [cursor1]; i++) { [cursor2] } [cursor3]
After doing for<tab>, the cursor ends up at cursor1, now you insert your text (e.g. MAX_COUNT), and hit ctrl+tab and move to cursor2, doing your stuff.
That saves a lot of movement with the arrow keys! The snippet.conf syntax doesn't change, you're just going to add more %cursor%.
However, the current patch is far from intelligent and nice. It's a bit hackish (limited to 10 cursors, global struct in editor.c ...), and the next cursor movement is apparently broken once you hit tab normally between "jumps". To be investigated! Also, I changed the hotkey of "go to last used tab" to nothing, so that ctrl+tab is free for this (this is the best hotkey I can find for), feel free to discuss!
This being my first code contribution to Geany, I'd really like to get some feedback! Don't hit me if it's bad though ;)
PS: Geany is great :D
This one should do better with tab indention (the previous only worked for space indention).
Have fun, I like it :)
On Fri, 02 Jan 2009 19:40:21 +0100, Thomas Martitz thomas47@arcor.de wrote:
Hi,
However, the current patch is far from intelligent and nice. It's a bit hackish (limited to 10 cursors, global struct in editor.c ...), and the next cursor movement is apparently broken once you hit tab normally between "jumps". To be investigated! Also, I changed the
Additionally, dmaphy pointed out another problem: when moving the cursor backwards in a completed snippet and then jump to the next defined cursor position, it's messed up. Testcase: Use the following snippet in some PHP code
class=class %cursor% \n{\n\tpublic function __construct(%cursor%)\n\t{\n \t\t%cursor%\n\t}\n\n\tpublic function __destruct(%cursor%)\n\t{\n\t\t% cursor%\n\t}\n\n\t%cursor%\n}
Then use the snippet: class<TAB> and type "abcd" on the first cursor position, move the cursor back by two positions and press the "Move cursor in snippet" keybinding to jump to the next cursor position. The cursor is then inside "__construct" instead of inside the braces. Maybe we can live with that but it'd be better if it would be fixed though this might be not easy.
hotkey of "go to last used tab" to nothing, so that ctrl+tab is free for this (this is the best hotkey I can find for), feel free to discuss!
This was actually not so good and so I reverted in the attached patch. The keybinding for "Go to last used tab" should be left unchanged, and there is currently no default for the new keybinding. I personally used Super-Tab which seems quite handy but not sure whether it should be the default as I have no idea how many people actually have a Super key.
I also fixed a little bug where the cursor wasn't set correctly for snippets like:
cur=%cursor%%brace_open%\n%brace_close%
The cursor should be before the braces but it was placed after.
Regards, Enrico
Enrico Tröger schrieb:
Then use the snippet: class<TAB> and type "abcd" on the first cursor position, move the cursor back by two positions and press the "Move cursor in snippet" keybinding to jump to the next cursor position. The cursor is then inside "__construct" instead of inside the braces. Maybe we can live with that but it'd be better if it would be fixed though this might be not easy.
Yea, it's not too intelligent :) But I personally could live with that. And indeed, as that'd require keeping track of cursor movement, it would probably not be very easy.
hotkey of "go to last used tab" to nothing, so that ctrl+tab is free for this (this is the best hotkey I can find for), feel free to discuss!
This was actually not so good and so I reverted in the attached patch. The keybinding for "Go to last used tab" should be left unchanged, and there is currently no default for the new keybinding. I personally used Super-Tab which seems quite handy but not sure whether it should be the default as I have no idea how many people actually have a Super key.
Yea, I thought so too (and I knew it was controversial) , but then again I couldn't find a better hotkey. Super is problematic I think because that's the Windows key on most keyboards (IIUC), and that's actually used by Windows and not really available for apps when running Geany on Windows. Maybe it's possible though.
Maybe it could also be tab as well, so that just a check for remaining cursor jumps would be inserted after the check for snippets. It's already used for indention AND snippets, maybe it could be used for that too.
But hey, I didn't mean to replace the hotkey for "Go to last tab", i.e. if my patch was complete, it wouldn't have used it, but that way I could get the best feedback on a proper hotkey ;)
I also fixed a little bug where the cursor wasn't set correctly for snippets like:
cur=%cursor%%brace_open%\n%brace_close%
The cursor should be before the braces but it was placed after.
Regards, Enrico
Thanks for that. And thanks for the feedback!
On Fri, 02 Jan 2009 10:39:24 +1100 Ross McKay rosko@zeta.org.au wrote:
Frank Lanitz wrote:
Lorem ipsum will get a plugin soon. A early development version is already to find inside geany-plugins subversion ;)
Why would lorem ipsum need a plugin? It works fine as a snippet - type in lorem, press tab... voila! Lorem ipsum dolor sit amet, consectetur adipisicing elit, sed do eiusmod tempor incididunt ut labore et dolore magna aliqua. Ut enim ad minim veniam, quis nostrud exercitation ullamco laboris nisi ut aliquip ex ea commodo consequat. Duis aute irure dolor in reprehenderit in voluptate velit esse cillum dolore eu fugiat nulla pariatur. Excepteur sint occaecat cupidatat non proident, sunt in culpa qui officia deserunt mollit anim id est laborum.
Or am I missing some essential functionality?
IMHO length of Lipsum text.
Cheers, Frank
Enrico Tröger schrieb:
Then use the snippet: class<TAB> and type "abcd" on the first cursor position, move the cursor back by two positions and press the "Move cursor in snippet" keybinding to jump to the next cursor position. The cursor is then inside "__construct" instead of inside the braces. Maybe we can live with that but it'd be better if it would be fixed though this might be not easy.
Fixed.
Thomas Martitz schrieb:
However, the current patch is far from intelligent and nice. It's a bit hackish (limited to 10 cursors, global struct in editor.c ...), and the next cursor movement is apparently broken once you hit tab normally between "jumps". To be investigated! Also, I changed the hotkey of "go to last used tab" to nothing, so that ctrl+tab is free for this (this is the best hotkey I can find for), feel free to discuss!
Fixed, sort of. Limit is gone (it's now using a dynamically allocated single linked list). pressing tab between jumps should work now. Nesting (i.e. recursively inserting) snippets works too, so that the cursor positions of the old snippets are not destroyed if you insert another snippet. I used my self-made single linked list implementation, since I had problems with GSList (with concating 2 lists and freeing in particular). My implementation does exactly what we need, and is yet extensible and reusable.
Adapting my ages old single linked dynamic list implementation to Geany was the most fun :)
Yea, I thought so too (and I knew it was controversial) , but then again I couldn't find a better hotkey. Super is problematic I think because that's the Windows key on most keyboards (IIUC), and that's actually used by Windows and not really available for apps when running Geany on Windows. Maybe it's possible though.
Default hotkey issue is still open (if there even should be one).
Patch attached. This one works quite well for me.
Small update, fixed/worked around a windows bug, small code cleanup in my queue code
On Fri, 09 Jan 2009 00:59:47 +0100, Thomas Martitz thomas.martitz@fhtw-berlin.de wrote:
Hey,
finally, the latest version of the patch, snippet-v3b.diff, landed in SVN. I did some minor modifications to use more GLib API and avoid using C99-only code.
Thanks a lot Thomas!
Then use the snippet: class<TAB> and type "abcd" on the first cursor position, move the cursor back by two positions and press the "Move cursor in snippet" keybinding to jump to the next cursor position. The cursor is then inside "__construct" instead of inside the braces. Maybe we can live with that but it'd be better if it would be fixed though this might be not easy.
Fixed.
Hrm, it still seems to happen :(.
Thomas Martitz schrieb:
However, the current patch is far from intelligent and nice. It's a bit hackish (limited to 10 cursors, global struct in editor.c ...), and the next cursor movement is apparently broken once you hit tab normally between "jumps". To be investigated! Also, I changed the hotkey of "go to last used tab" to nothing, so that ctrl+tab is free for this (this is the best hotkey I can find for), feel free to discuss!
Fixed, sort of. Limit is gone (it's now using a dynamically allocated single linked list). pressing tab between jumps should work now. Nesting (i.e. recursively inserting) snippets works too, so that the cursor positions of the old snippets are not destroyed if you insert another snippet. I used my self-made single linked list implementation, since I had problems with GSList (with concating 2 lists and freeing in particular). My implementation does exactly what we need, and is yet extensible and reusable.
Maybe we can switch to GLib's GSList or GQueue implementation to save some duplicate code but OTOH, as I said on IRC, the amount of code in your implementation isn't that much and so it's fine, for now.
Yea, I thought so too (and I knew it was controversial) , but then again I couldn't find a better hotkey. Super is problematic I think because that's the Windows key on most keyboards (IIUC), and that's actually used by Windows and not really available for apps when running Geany on Windows. Maybe it's possible though.
Default hotkey issue is still open (if there even should be one).
I guess for now it's sufficient to leave it undefined.
Regards, Enrico
Am 11.01.2009 22:13, schrieb Enrico Tröger:
On Fri, 09 Jan 2009 00:59:47 +0100, Thomas Martitz thomas.martitz@fhtw-berlin.de wrote:
Hey,
finally, the latest version of the patch, snippet-v3b.diff, landed in SVN. I did some minor modifications to use more GLib API and avoid using C99-only code.
Thanks a lot Thomas!
You're welcome :) I had a lot of fun doing this. I'm going to browse your changes as soon as possible, so that such stuff won't be needed the next time. Thanks for your patience and help. I definitely plan to contribute more, so it might pay off :)
Then use the snippet: class<TAB> and type "abcd" on the first cursor position, move the cursor back by two positions and press the "Move cursor in snippet" keybinding to jump to the next cursor position. The cursor is then inside "__construct" instead of inside the braces. Maybe we can live with that but it'd be better if it would be fixed though this might be not easy.
Fixed.
Hrm, it still seems to happen :(.
Uhm, right, seems I read your sentence wrong and "fixed" was regarding another issue.. There's some outstanding quirks, which are not trivial to solve (I sit the last two days trying to find a solution). But in the current way - once you get known to the quirks - it's relatively easy to avoid/work around/get fine with them.
The main use case: Insert the snipped, type, jump to next cursor, type, jump to next cursor, that's what's working fine.
Yes, they should probably be documented.
Maybe we can switch to GLib's GSList or GQueue implementation to save some duplicate code but OTOH, as I said on IRC, the amount of code in your implementation isn't that much and so it's fine, for now.
Maybe. I'll have another try. The issues I had with GSList are: I couldn't free temporary allocated lists, because the concat function didn't allow to copy the values. It concats the list directly. Plus, when I free'd the global list, instead of "nothing", it was filled by zeroes (not what I call a free). Those zeroes where visible with the build-in print function. Those may lead to memory leaks, which *shouldn't* happen with my queueu.
On the other hand, maybe I didn't get this GSList right, and just failed.
Default hotkey issue is still open (if there even should be one).
I guess for now it's sufficient to leave it undefined.
Fine with me :)
On Sun, 11 Jan 2009 22:25:12 +0100, Thomas Martitz thomas.martitz@fhtw-berlin.de wrote:
Then use the snippet: class<TAB> and type "abcd" on the first cursor position, move the cursor back by two positions and press the "Move cursor in snippet" keybinding to jump to the next cursor position. The cursor is then inside "__construct" instead of inside the braces. Maybe we can live with that but it'd be better if it would be fixed though this might be not easy.
Fixed.
Hrm, it still seems to happen :(.
Uhm, right, seems I read your sentence wrong and "fixed" was regarding another issue.. There's some outstanding quirks, which are not trivial to solve (I sit the last two days trying to find a solution). But in the current way - once you get known to the quirks - it's relatively easy to avoid/work around/get fine with them.
The main use case: Insert the snipped, type, jump to next cursor, type, jump to next cursor, that's what's working fine.
Yup, as I said before it's not the worst thing ever. It'd be cool to have it fixed but may cause a lot of work and maybe it's not even worth it.
Regards, Enrico