[Github-comments] [geany/geany] New tagmanager query module (#1187)

Thomas Martitz notifications at xxxxx
Tue Aug 23 07:58:33 UTC 2016


Am 23.08.2016 um 09:27 schrieb Jiří Techet:
>
>     Another goal is to eventually use this in the existing tag search/query functions.
>
> For C this new API is more or less useless because the filtering can easily be done by directly looking at the tag values and IMO it's more explicit and clearer than using some layer in between.

I disagree. It's a very nice improvement if `tm_workspace_find_prefix()` along with its helper `fill_find_tags_array_prefix()` can be replaced with a simple implementation like this:

```
GPtrArray *tm_workspace_find_prefix(const char *prefix, TMParserType lang, guint max_num)
{
    TMTagAttrType dedup_attrs[] = { tm_tag_attr_name_t, 0 };
    GPtrArray *tags;
    TMQuery *q = tm_query_new(theWorkspace, TM_QUERY_SOURCE_GLOBAL_TAGS | TM_QUERY_SOURCE_SESSION_TAGS);
    tm_query_add_name(q, prefix, strlen(prefix));
    tm_query_add_lang(q, lang);
    tags = tm_query_exec(q, NULL, dedup_attr);

    if (tags->len > max_num)
        tags->len = max_num;
    return tags;
}
```

Same goes for `tm_workspace_find()` and `tm_workspace_find_scope_members()`

-- 
You are receiving this because you are subscribed to this thread.
Reply to this email directly or view it on GitHub:
https://github.com/geany/geany/pull/1187#issuecomment-241656001
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <https://lists.geany.org/pipermail/github-comments/attachments/20160823/f5cf4307/attachment.html>


More information about the Github-comments mailing list