Skip to content

[Feature] Alternative to #pragma magic to fall back to file extension. #2520

@EtiTheSpirit

Description

@EtiTheSpirit

What feature would you like to see?

Currently, #pragma magic [ ... ] can be used to enable automatic loading of patterns by fIle contents. I would like to see the addition of #pragma extensions [ .ext .ext2 ... ] or something similar.

In an ideal case, both would be usable simultaneously, and #pragma extensions would serve as a fallback only after exhausting all options. That is, try to match patterns with #pragma magic first, and if no pattern claims the format, search again using #pragma extensions instead.

How will this feature be useful to you and others?

Ordinarily, I would be against this idea on the count of the fact that a file extension does not reliably identify the contents of a file. However, there are some scenarios where a file doesn't have a header at all, and so there is currently no way to propose a pattern file for its contents. This would fill that gap.

Request Type

  • I can provide a PoC for this feature or am willing to work on it myself and submit a PR

Additional context?

No response

Metadata

Metadata

Assignees

No one assigned

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions