[Geany] Template for C++ headers

Enrico Tröger enrico.troeger at xxxxx
Tue Nov 11 17:59:11 UTC 2008


On Tue, 11 Nov 2008 10:34:54 +1100, "Lex Trotman" <elextr at gmail.com>
wrote:

>2008/11/11 Enrico Tröger <enrico.troeger at uvena.de>
>
>> 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.
>
>
>Perhaps in the meantime Jay could use a snippet and insert it after
>saving the file.

In the meantime?
This is not going to change unless someone writes a plugin.


>e.g.defining in section [C] in your snippets.conf
>hguard=#ifndef HAVE_{filename}\n#define HAVE_{filename}\n\n#endif
>
>This still requires editing the result as it will contain a dot (.h)
>which isn't
>allowed in identifiers but it is part way there.  Perhaps adding an
>extra substitute
>thats equivalent of %e in the make commands would be an easy fix?

Maybe the classbuilder plugin might help you. It does create header
files with appropriate header guards. Just check it out.

Regards,
Enrico

-- 
Get my GPG key from http://www.uvena.de/pub.asc
-------------- next part --------------
A non-text attachment was scrubbed...
Name: not available
Type: application/pgp-signature
Size: 197 bytes
Desc: not available
URL: <http://lists.geany.org/pipermail/users/attachments/20081111/92597080/attachment.pgp>


More information about the Users mailing list