[Github-comments] [geany/geany] Req: Auto detect .h filetype based on whether a corresponding C/C++ source file is found (Issue #2946)

xiota notifications at xxxxx
Sun Oct 17 11:36:25 UTC 2021


Files with the `.h` extension are currently treated as C source code.  However, the extension is also used for C++.  It would be nice if Geany filetype auto detection switched the header type to C/C++ based on whether a corresponding source file is found.

For instance, many projects match `.cc` and `.h` files.  If both `filename.cc` and `filename.h` exist, it would be reasonable to expect the `.h` file to be a C++ header.  But if `filename.c` is found instead, the `.h` file is most likely a C header.

Since there are fewer C file extensions to check (just `.c`), the default could be for `.h` files to be treated as C++ and switched to C if a corresponding `.c` file is found.  There is a potential issue when isolated `.h` files are loaded.  I don't know how bothersome it would be fore users to have C files treated as C++.

Another option is to treat `.h` files as C and to switch filetype when a `.cc` file is detected, since that seems to be the most common mismatched pair.

Notes:

* I searched and read parts of the manual related to file types, but did not see anything that indicated this has already been implemented in Geany.  I apologize if I missed it.  But the manual is over 70 pages long when printed.

* This feature could be implemented in a plugin.  But the plugins related to managing source code and projects didn't appear to have it.

* I have implemented this feature in a personal plugin, so whether this is implemented in the main program doesn't really affect me personally.  However, I do wonder whether this would be appropriate as a standard feature.

* This functionality can likely be implemented as a Lua script.  However, I am concerned about the longevity of the GeanyLua plugin because Lua 5.1 is over 9 years past EOL.  


-- 
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/issues/2946
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <https://lists.geany.org/pipermail/github-comments/attachments/20211017/bd5e7030/attachment.htm>


More information about the Github-comments mailing list