Post by Aleix Pol$ kmimetypefinder5 kcategorizedview.h
text/x-chdr
Maybe you can look at the code how the language is inferred.
kmimetypefinder5 simply calls QMimeDatabase::mimeTypeForFile(). You can invoke the app with `-c` in which case the returned mimetype will be determined from the file contents only. Not a win: for the above file it returns text/x-csrc ...
I don't think it'd be a good idea to try and do better than QMimeDatabase, at least I'm not going to claim I can.
KDevelop might tune the response based on what it knows about in which files a given .h file is included but even that remains tricky. How to you classify and format a headerfile that contains both C and C++ code?
Is the formatting handled purely inside KDevelop code, or does it in fact rely on KTextEditor or KSyntaxHighlighting? If purely in-house it might be possible to couple it to the known value of __cplusplus (and __OBJC__)?
And it would probably be a good idea anyway to make it possible to couple the formatting for all C dialects. How often does it happen that you want different formatting for the C and C++ files in a given session which does NOT coincide with different formatting for different projects in that session? IOW, why can C/C++ formatting be different but is it not possible to have one project say using tabs for indentation and another using spaces? (That happens much more often for me...)
R.