[Geany-Users] Geany templates

Lex Trotman elextr at xxxxx
Wed Nov 11 07:36:03 UTC 2015


On 11 November 2015 at 15:04, Little Girl <littlergirl at gmail.com> wrote:
> Hey there,
>
> rch wrote:
>
>> That does seem to be part of the  problem.
>> Did that and I've now got a template
>> which works almost but not quite.
>> Template and output below the line at (a), (b)
>
>> The following wildcards work nicely
>>   {fileheader}, {datetime} and {geanyversion}
>> See lines 3, 4, 5
>
>> The following wild cards do not work
>>   {untitled} and (trying to get the full path)
>>   {command:readlink -f {ob}{untitled}{cb}}
>> See lines 2, 6
>
> I'm not sure what's up with this. It might be because there's already
> one untitled in the template, so the second one isn't expanded on
> save. It might also be that untitled has to be within the first X
> number of rows in the file (although there's nothing about that in
> the manual).

Yes untitled.xxx (where xxx is the file extension) has to be in the
first three lines and only the first occurrence is replaced.  This has
nothing to do with templates, its a new-file save feature, and it does
not appear to be documented, can you raise an issue so its not
forgotten.

>
>  Notice that the first one does expand perfectly when you save
> the file. As for the opening and closing brace wildcards in
> {ob}{untitled}{cb}, that could be because the command wildcard
> literally runs a command in the shell and then sends its output back
> into Geany. Since the Geany wildcards are unknown to the shell, it
> either ignores them or has an error (not sure).

There are no substitutes in the command, and the command stops at the
first } so its going to be hard to include } in the command.

>
> I tried it without the {ob} and {cb}, with quotes around it with and
> without the {ob} and {cb}, and with $GEANY_FILENAME with and without
> quotes around it. I couldn't get any of them to work. The shell isn't
> getting the data it needs to finish the command. Maybe someone who's
> reading along will jump in and suggest a better approach. (:
>
>> What is curious is that
>> {fileheader} → «foobar.pl» ; good (line 3 )
>> {untitled}   → «untitled»  ; bad (line 2)

The $GEANY_FILENAME and friends are only given values if they are
known, but the filename isn't known for a new file so the variable is
set but to nothing.  That may be your problem.

>
> Line 2 actually isn't bad. Remember that you have to add something to
> the file - either just a press of the Enter key or some typing and a
> press of the Enter key. Once you do that and save the file, untitled
> in line 2 will be replaced with the saved file name.
>
>> Using Geany ver 0.21 running under Ubuntu 12.04
>
> I'm using Geany version 1.25 under Linux Mint MATE 17.1 'Rebecca'.
> You might want to upgrade to the latest version of Geany. (:

Indeed 0.21 is very old and no longer supported.

Cheers
Lex


>
>> ---------------------------------------------
>> (a) Top six lines of template file (line numbers added)
>>
>> #!/usr/bin/perl                      1
>> # This is file {untitled}            2
>> {fileheader}                         3
>> # Made {datetime}                    4
>> # By Geany version {geanyversion}    5
>> # file://{command:readlink -f {ob}{untitled}{cb}} 6
>>
>> (b) Top part of Perl script made by that template
>> and saved as «foobar.pl»
>> Lines numbered as in the template
>>
>> # #!/usr/bin/perl                     1
>> # This is file untitled               2
>> #  foobar.pl                          3
>> #
>> #  Copyright 2015 RCH <rch at Ubuntu>
>> #
>> #  This program is free software; ...
>> #  it under the terms of the GNU  ...
>> ...etc..
>> # Made 10.11.2015 20:47:12 CET        4
>> # By Geany version Geany 0.21         5
>> # file:///home/rch/{obuntitled}}      6
>> ... snip ...
>
> I'm getting similar results here.
>
> --
> Little Girl
>
> There is no spoon.
> _______________________________________________
> Users mailing list
> Users at lists.geany.org
> https://lists.geany.org/cgi-bin/mailman/listinfo/users


More information about the Users mailing list