<p></p>
<p><b>@techee</b> requested changes on this pull request.</p>

<p>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.</p>
<p>I think the implementations could be unified as follows:</p>
<ol>
<li>implement <code>try_find_header_source()</code> which would be basically the current <code>try_swap_header_source()</code> that returns <code>full_name</code> inside the inner <code>if</code>.</li>
<li>implement <code>find_header_source()</code> which which would be basically <code>on_swap_header_source()</code> returning the filename (if found) by the <code>try_find_header_source()</code> calls.</li>
<li>move these 2 functions to rpjorg-utils.</li>
<li>implement <code>on_swap_header_source()</code> as</li>
</ol>
<pre><code>gchar *full_name = find_header_source(doc);
open_file(full_name);
g_free(full_name);
</code></pre>
<ol start="5">
<li>implement <code>on_doc_filetype_set()</code> as</li>
</ol>
<pre><code>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);
</code></pre>
<p>(Maybe I missed some details but in principle this should be it.)</p>

<p style="font-size:small;-webkit-text-size-adjust:none;color:#666;">—<br />You are receiving this because you are subscribed to this thread.<br />Reply to this email directly, <a href="https://github.com/geany/geany-plugins/pull/1122#pullrequestreview-792446788">view it on GitHub</a>, or <a href="https://github.com/notifications/unsubscribe-auth/AAIOWJ2EIK24MN7XLRS5CHTUJHFLLANCNFSM5GF3IVPA">unsubscribe</a>.<br />Triage notifications on the go with GitHub Mobile for <a href="https://apps.apple.com/app/apple-store/id1477376905?ct=notification-email&mt=8&pt=524675">iOS</a> or <a href="https://play.google.com/store/apps/details?id=com.github.android&referrer=utm_campaign%3Dnotification-email%26utm_medium%3Demail%26utm_source%3Dgithub">Android</a>.
<img src="https://github.com/notifications/beacon/AAIOWJ6AJH37VPN5ZMT3ZLTUJHFLLA5CNFSM5GF3IVPKYY3PNVWWK3TUL52HS4DFWFIHK3DMKJSXC5LFON2FEZLWNFSXPKTDN5WW2ZLOORPWSZGOF454ORA.gif" height="1" width="1" alt="" /></p>
<script type="application/ld+json">[
{
"@context": "http://schema.org",
"@type": "EmailMessage",
"potentialAction": {
"@type": "ViewAction",
"target": "https://github.com/geany/geany-plugins/pull/1122#pullrequestreview-792446788",
"url": "https://github.com/geany/geany-plugins/pull/1122#pullrequestreview-792446788",
"name": "View Pull Request"
},
"description": "View this Pull Request on GitHub",
"publisher": {
"@type": "Organization",
"name": "GitHub",
"url": "https://github.com"
}
}
]</script>