Geany can detect a document’s filetype from an explicit Emacs-style mode declaration. The docs say:
The `GEANY_DEFAULT_FILETYPE_REGEX` default value is `-*-\s*([^\s]+)\s*-*-` which finds Emacs filetypes.
In fact, this only works if the captured name case-sensitively matches a Geany filetype name. So `-*-Sh-*-` works, but `-*-sh-*-` doesn’t. `-*-reStructuredText-*-` works in Geany, but not in Emacs, which expects `-*-rst-*-`.
Perhaps the [Geany filetypes table](https://github.com/geany/geany/blob/35a5d457f48c92ecb71b5a2ecf7d718701d5ef63...) should have an “Emacs mode name” field (like it already has a “human title” field), to be matched case-insensitively.
Failing that, at least the docs should be clarified.
The filetype extractor is a regex so it can be changed to read any (reasonable) filetype marks the users code already contains, it could be changed to read Vim's `vim: syntax=xxx`. Its just got a default value for Emacs style because some C++ system headers which have no extensions have the Emacs mark and IIRC thats what the contributor wanted to detect at the time.
At the moment it is intended to *extract* the Geany filetype and nothing else.
As the extractor regex is user variable a comparison table shouldn't be hard coded into Geany (eg in the filetypes table), it should be a data file like `filetypes.extensions`, maybe `filetypes.alternative_names` with a list of alternative names like `filetypes.extensions` has a list of alternative extensions. This will also allow it to work for custom filetypes as well as builtin ones.
PS the "human" name is actually the menu item name.
What @elextr said or maybe we could maintain the alternative names even in the filetype definition files.
@eht16 the filetype detections need to be outside the filetype files since Geany doesn't load them all on startup, so if it doesn't have the detection data it can't detect the filetype to load the filetype file to get the detection data to ... :grin:
I'm guessing thats why `filetypes.extensions` exists as well.
Ah yes, so only what @elextr said before :).
github-comments@lists.geany.org