Skip to content

Feature requests: regex-based matching + recursive glob for directory includes/excludes #5

Description

@lammmab

Two related asks that would make from.ignore (and other pattern-based fields like to.trim_prefix, to.extern, etc.) significantly more precise for large/nested C libraries like the GTK family.


1. Proper regex support, not just wildcards

Current pattern matching ('gtk_icon*', '*autoptr*', etc.) as far as I'm aware only supports glob-style * wildcards. This forces broad, blunt patterns because there's no way to express things like:

  • "match gtk_ followed by anything except source_": impossible with globs, easy with a negative lookahead or alternation in regex
  • word-boundary-aware prefix matching (gtk_tree should match gtk_tree_view_new but not gtk_treasure_thing: contrived example, but the general class of false-positive substring matches is real)
  • anchoring only at start/end without wildcarding the whole pattern
    Proposal: support real regex patterns, distinguished from glob patterns either by:
  • a field-level flag (e.g. from.ignore.functions.regex: true alongside a patterns: list), or
  • a prefix convention (e.g. re:^gtk_(?!source_) vs plain glob strings), similar to how many tools disambiguate glob vs regex inputs
    This directly solves the GTK vs. GtkSourceView collision problem from a single ignore list instead of needing per-widget-family enumeration (gtk_icon*, gtk_font*, gtk_info*, gtk_lock*, gtk_print*, gtk_tree*, ...) or a split-config workaround. One pattern: ^gtk_(?!foo_) can replace entire manually-curated lists.

2. Recursive glob (/**) for directory includes/excludes

from.extern currently supports glob patterns but explicitly cannot glob across nested folders: the docs state "you can only glob files inside of one folder meaning that patterns like foo_library/** will not work."

For libraries with headers organized into nested subdirectories (common in larger C projects: GTK itself ships headers under multiple nested include dirs depending on distro/version), this means manually listing every subdirectory that needs to be excluded/included, which is fragile across library versions and packaging layouts.

Proposal: support standard recursive glob syntax (dir/**, dir/*/**, etc.) so a single pattern can match arbitrary depth, e.g.:

from:
  extern:
    - "gtk-4.0/**"

instead of having to enumerate every subfolder under gtk-4.0/.


Why both together matter

These two compound well: regex for precise symbol name filtering, recursive glob for precise file path filtering. Together they'd let a rune like the GTK/GtkSourceView case collapse from an 18-entry hand-maintained ignore list plus a directory-structure-dependent extern list into a couple of expressive, version-resilient patterns, reducing maintenance burden every time a new GTK point release adds/renames a widget family or reorganizes headers.

Like the idea?

If you're on board with this expansion, I can draft a new PR adding both features, aswell as expand / correct the documentation. Let me know :)

Activity

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions