[Geany] Template for C++ headers

jay jay.27182818 at xxxxx
Mon Nov 10 19:55:11 UTC 2008


On Mon, 2008-11-10 at 20:01 +0100, Enrico Tröger wrote:
> On Tue, 04 Nov 2008 15:24:05 +0200, jay <jay.27182818 at gmail.com> wrote:
> 
> Hi Jay,
> 
> sorry for the late answer.
> 
> 
> >hi guys! i've recently switched to geany from cdt (eclipse plugin for
> >c/c++). when you create a new header file in cdt it's default content
> >is like below:
> >
> >#ifndef SOMEHEADER_H_
> >#define SOMEHEADER_H_
> >
> >#endif /*SOMEHEADER_H_*/
> >
> >where SOMEHEADER is the name of the file. Can you tell me how can i
> >make it in geany? I have created a template and put it into
> >~/.geany/templates but geany doesn't seem to see it even after restart.
> >my template has this content:
> >
> >#ifndef {filename}
> >#define {filename}
> >
> >#endif /*{filename}*/
> >
> >but filename is not what i need. I got stuck at this point. Need your
> >help.
> 
> Unfortunately, most of the wildcards (to be more specific: all except
> {fileheader}) are not replaced for custom file templates.
> I just changed this in the SVN version so that the other wildcards can
> be used, too. So, also {filename} will now be replaced.
> 
> But this still doesn't help you because when you create a new document
> from a fle template, Geany will name this document 'untitled.xxx' where
> xxx is the extension of the template file.
> 
> So, even if you would use something like
> 
> ifndef {filename}
> define {filename}
> 
> endif /*{filename}*/
> 
> would result in
> 
> #ifndef untitled.h
> #define untitled.h
> 
> #endif /*untitled.h*/
> 
> 
> The problem is that you want to have the final filename in the document
> after you initially saved it to disk. But at this point Geany doesn't
> know anything anymore about the template.
> 
> I don't think we should do anything about this in Geany itself.
> But it should be possible and reasonable to do this for a plugin, maybe
> with some other useful additions to the template system.
> If anyone wants to work on this, feel free to do so and to ask for help.
> 
> Regards,
> Enrico
> 
> _______________________________________________
> Geany mailing list
> Geany at uvena.de
> http://lists.uvena.de/cgi-bin/mailman/listinfo/geany

Hi Enrico,

thanks for reply. it would be great to move all template related stuff
into a plugin. most ide's like eclipse or netbeans or even vs first ask
user to select a template and then to specify a name for the new file.
if i'm not mistaken eclipse cdt can create unnamed files the same way
geany does but in such cases it doesn't use any templates. so geany is
just missing asking for a filename. It'd be nice if you make it possible
for plugins to intercept menu actions like file creation or saving - it
will make it easy to store all template related code in a plugin that
would handle creating new files.

Jay




More information about the Users mailing list