[Geany-devel] get build command from a plugin

Lex Trotman elextr at xxxxx
Wed Feb 1 00:24:01 UTC 2012

On Wed, Feb 1, 2012 at 5:20 AM, Dimitar Zhekov <dimitar.zhekov at gmail.com> wrote:
> On Tue, 31 Jan 2012 15:39:52 +1100
> Lex Trotman <elextr at gmail.com> wrote:
>> Dimitar, Matthew,
>> See git://github.com/elextr/geany.git, the more testing the better :)
> I compile Geany with -Wall -W -Wno-unused-parameter (not the normal
> practice) and received a few warnings:

Well, it should be normal practice, thats what HACKING says, I just
forgot to set it with a new clean clone, oops.  Actually you should
add -O2 because a couple of the warnings need the dataflow computation
that the optimisation does.

> build.c: In function 'build_get_current_menu_item':
> build.c:576:2: warning: enumeration value 'GEANY_BC_CMDENTRIES_COUNT'
> not handled in switch [-Wswitch] build.c: In function
> 'build_set_menu_item': build.c:620:2: warning: enumeration value
> 'GEANY_BC_CMDENTRIES_COUNT' not handled in switch [-Wswitch]
> build.c:607:9: warning: unused variable 'str' [-Wunused-variable]
> These are probably harmless.

Yes, stupid compiler can't see that there is a g_return_if_fail just
before that limits fld to the range in the switch, fixed now anyway.

> build_get_current_menu_item() works, and returns the non-expanded
> values (%e, %f) as I expected.
> About returning NULL instead of "" for the empty fields, I'm not very
> sure. How do we separate a completely empty command with a valid cmd,
> such as the 3rd default C command, and an out-of-range cmd?

The semantics of a command (well actually the label) that is "" vs
NULL is important, a "" label hides commands from a lower priority
source without showing itself in the menu, a NULL does not.  So a for
example a project that isn't using make could override the first make
command with whatever it is using and hide the other two unused
default make commands by setting the labels to "".

Unfortunately there isn't anthing else besides NULL that is sensible
to return to indicate out of range.

So I've exposed build_get_group_count() as well so you can get the
count and then its your fault if you pass an out of range index :).


> --
> E-gards: Jimmy
> _______________________________________________
> Geany-devel mailing list
> Geany-devel at uvena.de
> https://lists.uvena.de/cgi-bin/mailman/listinfo/geany-devel

More information about the Devel mailing list