Is it possible to have different templates for source and header files for a file type like C or C++?
I'm using Geany on Ubuntu Karmic (from PPA).
On Wed, 28 Apr 2010 13:17:14 +0200 Joerg Desch jd.vvd@web.de wrote:
Is it possible to have different templates for source and header files for a file type like C or C++?
Not in the last release. In the SVN version you can have as many file templates as you like even for the same filetype.
Regards, Nick
On Wed, 28 Apr 2010 13:34:38 +0100 Nick Treleaven nick.treleaven@btinternet.com wrote:
Hi Nick.
Is it possible to have different templates for source and header files for a file type like C or C++?
Not in the last release. In the SVN version you can have as many file templates as you like even for the same filetype.
I only need 2 (*.c/*.h) ;-)
What is the way to "assign" one of these (multiple) templates (for the same type)?
On Wed, 28 Apr 2010 15:04:52 +0200 Joerg Desch jd.vvd@web.de wrote:
Is it possible to have different templates for source and header files for a file type like C or C++?
Not in the last release. In the SVN version you can have as many file templates as you like even for the same filetype.
I only need 2 (*.c/*.h) ;-)
What is the way to "assign" one of these (multiple) templates (for the same type)?
See: http://www.geany.org/manual/dev/index.html#file-templates
Basically you just make a number of files like source.c, header.h and put them in ~/.config/geany/templates/files/. They should appear in the 'New with template' menu.
Regards, Nick
On Wed, 28 Apr 2010 14:18:05 +0100 Nick Treleaven nick.treleaven@btinternet.com wrote:
Hi Nick.
Basically you just make a number of files like source.c, header.h and put them in ~/.config/geany/templates/files/. They should appear in the 'New with template' menu.
Thanks. This works fine. But as always, there is something that doesn't work as expected. ;-)
The template wildcard {filename} is replaced with "unnamed.c" (in German "unbenannt.c"). This isn't a good choose, because you have to rename it afterwards. Wouldn't it be better to open a dialog and ask for the name to use?
While we talk about template wildcards. Please add {filebasename}! Below is a part of my header template. You can easily see the reason for {filebasename}...
============================================================= /* -*- Mode: C -*- * * $Id$ * -------------------------------------------------------------------------- * Copyright (c) {company} * -------------------------------------------------------------------------- * PROJECT: * MODULE.: {filename} * AUTHOR.: {developer} * CREATED: {datetime} * -------------------------------------------------------------------------- * DESCRIPTION: * * -------------------------------------------------------------------------- * COMPILER-FLAGS: * * -------------------------------------------------------------------------- */
#ifndef __{basefilename}_H__ #define __{basefilename}_H__ 1
=============================================================
On Thu, 29 Apr 2010 09:59:49 +0200 Joerg Desch jd.vvd@web.de wrote:
The template wildcard {filename} is replaced with "unnamed.c" (in German "unbenannt.c"). This isn't a good choose, because you have to rename it
If it's found near the start of the file, e.g. 2nd line, then it is replaced when the file is first saved. This could be improved.
afterwards. Wouldn't it be better to open a dialog and ask for the name to use?
Personally I'm not keen on that behaviour, maybe there's a better solution.
While we talk about template wildcards. Please add {filebasename}! Below is a part of my header template. You can easily see the reason for {filebasename}...
#ifndef __{basefilename}_H__
If we improve the {filename} issue above then it would be simple to add this.
Regards, Nick
On Mon, 3 May 2010 16:01:11 +0100 Nick Treleaven nick.treleaven@btinternet.com wrote:
The template wildcard {filename} is replaced with "unnamed.c" (in German "unbenannt.c"). This isn't a good choose, because you have to rename it
If it's found near the start of the file, e.g. 2nd line, then it is replaced when the file is first saved. This could be improved.
Could you determine the line range of the "first comment"? I think the replacement isn't done outside of an comment.
afterwards. Wouldn't it be better to open a dialog and ask for the name to use?
Personally I'm not keen on that behaviour, maybe there's a better solution.
If the template wildcard is replaced after saving the file, the "Save file" dialog isn't needed.
But while we talk about opening dialogs. What do you think about template wildcard which ask for it value? This could be done by appending an question mark. Something like "{project?}".
#ifndef __{basefilename}_H__
If we improve the {filename} issue above then it would be simple to add this.
Great!
On Mon, 3 May 2010 16:01:11 +0100 Nick Treleaven nick.treleaven@btinternet.com wrote:
On Thu, 29 Apr 2010 09:59:49 +0200 Joerg Desch jd.vvd@web.de wrote:
The template wildcard {filename} is replaced with "unnamed.c" (in German "unbenannt.c"). This isn't a good choose, because you have to rename it
If it's found near the start of the file, e.g. 2nd line, then it is replaced when the file is first saved. This could be improved.
I've tried this. In my release of Geany (0.18 / Ubuntu PPA), the template wildcard {filename} is always replaced with "unnamed"/"unbekannt". Immediately after loading the template. Even in the first two lines of the file.
On Tue, 4 May 2010 09:21:08 +0200 Joerg Desch jd.vvd@web.de wrote:
The template wildcard {filename} is replaced with "unnamed.c" (in German "unbenannt.c"). This isn't a good choose, because you have to rename it
If it's found near the start of the file, e.g. 2nd line, then it is replaced when the file is first saved. This could be improved.
I've tried this. In my release of Geany (0.18 / Ubuntu PPA), the template wildcard {filename} is always replaced with "unnamed"/"unbekannt". Immediately after loading the template. Even in the first two lines of the file.
The {filename} wildcard is replaced with e.g. 'untitled', then the 'untitled' is replaced when the file is saved.
Regards, Nick
On Tue, 4 May 2010 14:22:14 +0100 Nick Treleaven nick.treleaven@btinternet.com wrote:
The {filename} wildcard is replaced with e.g. 'untitled', then the 'untitled' is replaced when the file is saved.
Not here. The translated place holder 'unbenannt.c' is not replaced after saving under a new name.
On 5 May 2010 18:15, Joerg Desch jd.vvd@web.de wrote:
On Tue, 4 May 2010 14:22:14 +0100 Nick Treleaven nick.treleaven@btinternet.com wrote:
The {filename} wildcard is replaced with e.g. 'untitled', then the 'untitled' is replaced when the file is saved.
Not here. The translated place holder 'unbenannt.c' is not replaced after saving under a new name.
Are you changing the filetype either before saving or while saving?
Cheers Lex
PS I think that can cause the "unbenannt.c" to be not found because itis looking for "unbenannt.something_else"
--
Email: Joerg Desch <jd DOT vvd AT web DOT de> _______________________________________________ Geany mailing list Geany@uvena.de http://lists.uvena.de/cgi-bin/mailman/listinfo/geany
On Wed, 5 May 2010 21:29:26 +1000 Lex Trotman elextr@gmail.com wrote:
Are you changing the filetype either before saving or while saving?
Not really. I use a template called 'source.c' to get a C source. This is automagically called 'unbenannt.c' in the editor. Since "File/Save" is inactive, I use "File/Save as" to store it as 'test.c'.
On 5 May 2010 21:53, Joerg Desch jd.vvd@web.de wrote:
On Wed, 5 May 2010 21:29:26 +1000 Lex Trotman elextr@gmail.com wrote:
Are you changing the filetype either before saving or while saving?
Not really. I use a template called 'source.c' to get a C source. This is automagically called 'unbenannt.c' in the editor. Since "File/Save" is inactive, I use "File/Save as" to store it as 'test.c'.
Ahhhh, a custom file template!!! Yes you are right it doesn't work, untitled (as it is for me) isn't replaced in fiels created from custom templates. Can't see why. Works for a standard file template.
Cheers Lex
-- Email: Joerg Desch <jd DOT vvd AT web DOT de> _______________________________________________ Geany mailing list Geany@uvena.de http://lists.uvena.de/cgi-bin/mailman/listinfo/geany
On Wed, 5 May 2010 10:15:22 +0200 Joerg Desch jd.vvd@web.de wrote:
The {filename} wildcard is replaced with e.g. 'untitled', then the 'untitled' is replaced when the file is saved.
Not here. The translated place holder 'unbenannt.c' is not replaced after saving under a new name.
OK, the replacement is only made on the first save.
Also, I just fixed a bug where if the extension is not the default one, the untitled.foo string is not replaced. Perhaps that was the problem?
Thanks for testing this ;-)
Regards, Nick
On 5 May 2010 22:53, Nick Treleaven nick.treleaven@btinternet.com wrote:
On Wed, 5 May 2010 10:15:22 +0200 Joerg Desch jd.vvd@web.de wrote:
The {filename} wildcard is replaced with e.g. 'untitled', then the 'untitled' is replaced when the file is saved.
Not here. The translated place holder 'unbenannt.c' is not replaced after saving under a new name.
OK, the replacement is only made on the first save.
Also, I just fixed a bug where if the extension is not the default one, the untitled.foo string is not replaced. Perhaps that was the problem?
Yup, just found that was my problem, I'd used a C++ .hpp header & it failed but if I used a C++ .cpp header it worked because it matched the standard extension.
Cheers Lex
Thanks for testing this ;-)
Regards, Nick _______________________________________________ Geany mailing list Geany@uvena.de http://lists.uvena.de/cgi-bin/mailman/listinfo/geany
On Wed, 5 May 2010 22:57:40 +1000 Lex Trotman elextr@gmail.com wrote:
Also, I just fixed a bug where if the extension is not the default one, the untitled.foo string is not replaced. Perhaps that was the problem?
Yup, just found that was my problem, I'd used a C++ .hpp header & it failed but if I used a C++ .cpp header it worked because it matched the standard extension.
OK, hopefully this should now work in latest svn.
Regards, Nick
On Wed, 5 May 2010 13:53:52 +0100 Nick Treleaven nick.treleaven@btinternet.com wrote:
OK, the replacement is only made on the first save.
See my reply to Lex. While using "custom templates", the replacement never works. Sorry. ;-)
On Wed, 5 May 2010 15:07:27 +0200 Joerg Desch jd.vvd@web.de wrote:
OK, the replacement is only made on the first save.
See my reply to Lex.
Yes, I saw it ;-)
While using "custom templates", the replacement never works. Sorry. ;-)
Have you tried latest SVN?
Regards, Nick
Joerg,
Nicely caught, I've been using these custom templates for a while now. According to grep I now have to go back and change a pile of files headed untitled.hpp.
Shows how much attention I was paying :-)
Cheers Lex
On 6 May 2010 01:10, Nick Treleaven nick.treleaven@btinternet.com wrote:
On Wed, 5 May 2010 15:07:27 +0200 Joerg Desch jd.vvd@web.de wrote:
OK, the replacement is only made on the first save.
See my reply to Lex.
Yes, I saw it ;-)
While using "custom templates", the replacement never works. Sorry. ;-)
Have you tried latest SVN?
Regards, Nick _______________________________________________ Geany mailing list Geany@uvena.de http://lists.uvena.de/cgi-bin/mailman/listinfo/geany
On Thu, 6 May 2010 14:37:56 +1000 Lex Trotman elextr@gmail.com wrote:
According to grep I now have to go back and change a pile of files headed untitled.hpp.
grep? Sounds more that you have to use perl/python. ;-)
Shows how much attention I was paying :-)
Isn't that normal? ;-)
On Wed, 5 May 2010 16:10:15 +0100 Nick Treleaven nick.treleaven@btinternet.com wrote:
Have you tried latest SVN?
No. I'm using Geany in an production environment. So I can't play with SVN releases.
Nevertheless, is it possible to install geany parallel to an "official" release (Ubuntu Karmic with geanydev PPA)?
Are the configuration files in ~/.config/geany save?
On 6 May 2010 15:43, Joerg Desch jd.vvd@web.de wrote:
On Wed, 5 May 2010 16:10:15 +0100 Nick Treleaven nick.treleaven@btinternet.com wrote:
Have you tried latest SVN?
No. I'm using Geany in an production environment. So I can't play with SVN releases.
Nevertheless, is it possible to install geany parallel to an "official" release (Ubuntu Karmic with geanydev PPA)?
You can build the SVN version with the option --prefix=the_full_path_to_your_home/a_temp_geany_dir (note you have to spell out your home dir no ~)
~/a_temp_geany_dir/bin/geany will be the executable, run it with -c to specify where you want the config to be.
Thats how I test things.
Cheers Lex
Are the configuration files in ~/.config/geany save?
-- Email: Joerg Desch <jd DOT vvd AT web DOT de> _______________________________________________ Geany mailing list Geany@uvena.de http://lists.uvena.de/cgi-bin/mailman/listinfo/geany
On Thu, 6 May 2010 17:39:53 +1000 Lex Trotman elextr@gmail.com wrote:
On 6 May 2010 15:43, Joerg Desch jd.vvd@web.de wrote: ~/a_temp_geany_dir/bin/geany will be the executable, run it with -c to specify where you want the config to be.
OK, that was the missing tip. ;-)
OK, if compiled and installed rev4880. The replacement doesn't work. After saving the custom template, the display is cluttered. After playing with geany in this state, I've got one segfault. Restarting geany with the previously cluttered file comes up the a file which is less bad.
I've made some screenshots. Anyone interested in the screenshots and the stored files?
On 7 May 2010 19:19, Joerg Desch jd.vvd@web.de wrote:
On Thu, 6 May 2010 17:39:53 +1000 Lex Trotman elextr@gmail.com wrote:
On 6 May 2010 15:43, Joerg Desch jd.vvd@web.de wrote: ~/a_temp_geany_dir/bin/geany will be the executable, run it with -c to specify where you want the config to be.
OK, that was the missing tip. ;-)
OK, if compiled and installed rev4880. The replacement doesn't work. After saving the custom template, the display is cluttered.
Just tried it and 4880 works for me, don't you hate people who say that!!!
Fresh build Opensuse 11.0 x86-64 Using GTK version : 2.12.9 Compiling Subversion revision : r4880
After playing with geany in this state, I've got one segfault. Restarting geany with the previously cluttered file comes up the a file which is less bad.
I've made some screenshots. Anyone interested in the screenshots and the stored files?
Yes screenshot is a good idea, sorry, but "cluttered" could mean anything :-)
Cheers Lex
-- Email: Joerg Desch <jd DOT vvd AT web DOT de> _______________________________________________ Geany mailing list Geany@uvena.de http://lists.uvena.de/cgi-bin/mailman/listinfo/geany
On Fri, 7 May 2010 21:03:10 +1000 Lex Trotman elextr@gmail.com wrote:
Just tried it and 4880 works for me, don't you hate people who say that!!!
;-)
Fresh build Opensuse 11.0 x86-64 Using GTK version : 2.12.9 Compiling Subversion revision : r4880
13:34:58: INFO : Geany 0.19 (svn >= r4880), GTK+ 2.18.3, GLib 2.22.3
Yes screenshot is a good idea, sorry, but "cluttered" could mean anything :-)
Yes, I know. That's why i've made the screenshots. ;-)
I send you an email within the next minutes...
On 7 May 2010 21:36, Joerg Desch jd.vvd@web.de wrote:
On Fri, 7 May 2010 21:03:10 +1000 Lex Trotman elextr@gmail.com wrote:
Just tried it and 4880 works for me, don't you hate people who say that!!!
;-)
Fresh build Opensuse 11.0 x86-64 Using GTK version : 2.12.9 Compiling Subversion revision : r4880
13:34:58: INFO : Geany 0.19 (svn >= r4880), GTK+ 2.18.3, GLib 2.22.3
Yes screenshot is a good idea, sorry, but "cluttered" could mean anything :-)
Yes, I know. That's why i've made the screenshots. ;-)
I send you an email within the next minutes...
Ok, the substitution for untitled (unbenannt) didn't happen because it is only done in the first two/three lines of the file. This is probably sensible, I wouldn't want my editor to randomly change any variables called untitled throughout the program.
Perhaps the {filename} could be left in the file until it is saved the first time and all occurrences replaced. But then, are there any languages where that is a valid sequence? Looks vaguely like Perl or Ruby but its been a while since I've used them?? Maybe templates are going to have to force immediate saving so they can get a filename.
As for the scrambled screen, I'm not sure what that is, but it probably isn't related to the template, does it happen with any other existing files?
I suggest that you post the tgz to the mailing list (taking out anything that you don't want on a public forum of course) so that Nick/Enrico can look at it.
In my timezone its bedtime :-)
Cheers Lex
--
Email: Joerg Desch <jd DOT vvd AT web DOT de> _______________________________________________ Geany mailing list Geany@uvena.de http://lists.uvena.de/cgi-bin/mailman/listinfo/geany
On Fri, 7 May 2010 22:18:57 +1000 Lex Trotman elextr@gmail.com wrote:
Perhaps the {filename} could be left in the file until it is saved the first time and all occurrences replaced. But then, are there any languages where that is a valid sequence? Looks vaguely like Perl or Ruby but its been a while since I've used them?? Maybe templates are going to have to force immediate saving so they can get a filename.
After the 0.19 release I think we could maybe do this: Replace {filename} with e.g. {GEANY_TEMPLATE_filename} and set a document flag. When first saving the new file, if the flag is set, replace {GEANY_TEMPLATE_filename} with the real filename.
I think that string is unlikely to occur in a file, and much less in an unsaved document.
As for the scrambled screen, I'm not sure what that is, but it probably isn't related to the template, does it happen with any other existing files?
I suggest that you post the tgz to the mailing list (taking out anything that you don't want on a public forum of course) so that Nick/Enrico can look at it.
Maybe post in a new thread.
Regards, Nick
On 7 May 2010 22:56, Nick Treleaven nick.treleaven@btinternet.com wrote:
On Fri, 7 May 2010 22:18:57 +1000 Lex Trotman elextr@gmail.com wrote:
Perhaps the {filename} could be left in the file until it is saved the
first
time and all occurrences replaced. But then, are there any languages
where
that is a valid sequence? Looks vaguely like Perl or Ruby but its been a while since I've used them??
Right near the beginning, my Ruby book has the example line :-)
puts "Can't open file #{filename}"
Maybe templates are going to have to force
immediate saving so they can get a filename.
After the 0.19 release I think we could maybe do this: Replace {filename} with e.g. {GEANY_TEMPLATE_filename} and set a document flag. When first saving the new file, if the flag is set, replace {GEANY_TEMPLATE_filename} with the real filename.
I think that string is unlikely to occur in a file, and much less in an unsaved document.
Good solution, then also GEANY_TEMPLATE_filebase and I would request GEANY_TEMPLATE_filebasecaps for use in header guards where macros should be all caps.
I don't think this uglification is needed for the substitutions that are made as the template is loaded, just those made at save time after the user has time to type any arbitrary text, but you might want to make them all consistent.
Cheers Lex
As for the scrambled screen, I'm not sure what that is, but it probably isn't related to the template, does it happen with any other existing
files?
I suggest that you post the tgz to the mailing list (taking out anything that you don't want on a public forum of course) so that Nick/Enrico can look at it.
Maybe post in a new thread.
Regards, Nick _______________________________________________ Geany mailing list Geany@uvena.de http://lists.uvena.de/cgi-bin/mailman/listinfo/geany
On Fri, 7 May 2010 22:18:57 +1000 Lex Trotman elextr@gmail.com wrote:
Hi Lex,
As for the scrambled screen, I'm not sure what that is, but it probably isn't related to the template, does it happen with any other existing files?
Only the stored template is scrambled.
I suggest that you post the tgz to the mailing list (taking out anything that you don't want on a public forum of course) so that Nick/Enrico can look at it.
OK. I'll post it in a new thread.
On Fri, 7 May 2010 21:03:10 +1000 Lex Trotman elextr@gmail.com wrote:
OK, if compiled and installed rev4880. The replacement doesn't work. After saving the custom template, the display is cluttered.
Hmm, maybe the display problem was introduced r4878.
Can you try: svn up -r 4877
Then rebuild and test the display problem please?
Just tried it and 4880 works for me, don't you hate people who say that!!!
Hehe, thanks for testing Lex ;-)
Regards, Nick
On Fri, 7 May 2010 14:02:27 +0100 Nick Treleaven nick.treleaven@btinternet.com wrote:
OK, if compiled and installed rev4880. The replacement doesn't work. After saving the custom template, the display is cluttered.
Hmm, maybe the display problem was introduced r4878.
Can you try: svn up -r 4877
Then rebuild and test the display problem please?
Actually now can you try just: svn up
Then rebuild and see if that fixes the problem? If not then try r4877. Also do you get any error messages - check Help->Debug Messages or run geany from a terminal.
Regards, Nick