[Github-comments] [geany/geany] Req: Auto detect .h filetype based on whether a corresponding C/C++ source file is found (Issue #2946)
elextr
notifications at xxxxx
Sun Oct 17 12:26:48 UTC 2021
Yes, `.h` files are a known problem. C and C++ are not the same language, so getting it wrong means symbols and possibly highlighting will be wrong. Treating C header files as C++ is more likely to work (but not guaranteed) and as Geany treats C and C++ symbols as interchangable they will show in both C and C++ autocomplete.
Emacs has the same problem and uses the `-*-type-*-` in a first line comment to identify them. On the system here almost all system include files have it, sometimes subtly, the following example line one is from my `libffi.h` :-) It is also necessary for system C++ includes that have no extension.
```
/* -----------------------------------------------------------------*-C-*-
```
The standard Geany filetype regex recognises and uses these marks, see the default `extract_filetype_regex` in various prefs. This would be the recommended solution for your own headers if for some reason you can't use `.hpp` or `.hxx` for C++ headers.
Defaulting to C is the right(ish) thing to do for `.h` unless its marked.
Looking for a file with a C or C++ filetype with the same name will only work if the C or C++ file is already open when the header is opened since many/most projects put .h files in an `include` directory separate from the body files. So Geany won't know where to look for body files.
The suggestion of adding the feature to one/all the project plugins would be a better idea since they usually know where files related to the project live, thats their purpose after all. So they know where to search, or may even already have a list of project files they can lookup.
> I am concerned about the longevity of the GeanyLua plugin because Lua 5.1 is over 9 years past EOL.
Unfortunately unless somebody ports GeanyLua to a newer Lua then I would have to agree with you that any script will likely have a limited lifetime.
--
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#issuecomment-945108055
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <https://lists.geany.org/pipermail/github-comments/attachments/20211017/365a0b7d/attachment.htm>
More information about the Github-comments
mailing list