2008/11/11 Enrico Tröger
<enrico.troeger@uvena.de>
On Tue, 04 Nov 2008 15:24:05 +0200, jay <jay.27182818@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.
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?
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
--
Get my GPG key from http://www.uvena.de/pub.asc
_______________________________________________
Geany mailing list
Geany@uvena.de
http://lists.uvena.de/cgi-bin/mailman/listinfo/geany