[Github-comments] [geany/geany-plugins] Project Organizer: Set header filetype to match source filetype (PR #1122)

Jiří Techet notifications at xxxxx
Thu Oct 28 21:31:17 UTC 2021


@techee requested changes on this pull request.

I think it principle the patch is fine, I just don't like that there are now 2 more or less identical implementations, one used for swapping header/sources, the other for setting filetypes.

I think the implementations could be unified as follows:

1. implement `try_find_header_source()` which would be basically the current `try_swap_header_source()` that returns `full_name` inside the inner `if`.
2. implement `find_header_source()` which which would be basically `on_swap_header_source()` returning the filename (if found) by the `try_find_header_source()` calls.
3. move these 2 functions to rpjorg-utils.
4. implement `on_swap_header_source()` as
```
gchar *full_name = find_header_source(doc);
open_file(full_name);
g_free(full_name);
```
5. implement `on_doc_filetype_set()` as
```
gchar *full_name = find_header_source(doc);
GeanyFiletype * source_filetype = filetypes_detect_from_file(full_name);
GeanyDocument * doc = document_find_by_filename(utf8_file_name);
document_set_filetype(doc, source_filetype);
g_free(full_name);
```

(Maybe I missed some details but in principle this should be it.)



-- 
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-plugins/pull/1122#pullrequestreview-792446788
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <https://lists.geany.org/pipermail/github-comments/attachments/20211028/a928b39b/attachment.htm>


More information about the Github-comments mailing list