<p>As a Geany user, so that I can invoke a web browser in the process of executing a build step, I would like to be able to reference the browser command setting.</p>
<p>I noticed in the Geany manual that if the user wants to configure a context action that uses a web browser (e.g., use the selected text (via '%s') as a parameter to firefox), they're encouraged to specify a command like this:<br>
<code>firefox "http://www.php.net/%s"</code></p>
<p><a href="https://www.geany.org/manual/current/#context-actions" rel="nofollow">https://www.geany.org/manual/current/#context-actions</a></p>
<p>So, I got to thinking that Geany already has the user's browser of choice via the preferences mechanism.  Why, then, would Geany need the user to specify a browser when it already "knows?"</p>
<p>In the callbacks.c we can see the call to <code>spawn_async</code> on the command line after the '%s' has been substituted.</p>
<p><a href="https://github.com/geany/geany/blob/master/src/callbacks.c#L1492">https://github.com/geany/geany/blob/master/src/callbacks.c#L1492</a></p>
<p>Then I thought, what if instead of having the filetype specify the command to run, security concerns aside, could we include a pattern that could be replaced by the browser specified by the user?</p>
<p>Seeing how the browser command is accessed in utils.c it looks like this could be done by replacing the pattern with <code>tool_prefs.browser_cmd</code>.</p>
<p><a href="https://github.com/geany/geany/blob/master/src/prefs.c#L681">https://github.com/geany/geany/blob/master/src/prefs.c#L681</a></p>
<p><a href="https://github.com/geany/geany/blob/master/src/utils.c#L85">https://github.com/geany/geany/blob/master/src/utils.c#L85</a></p>
<p>The user could then specify a context action like this:</p>
<p><code>%b "https://www.php.net/%s"</code></p>
<p>(where <code>%b</code> is the pattern)</p>
<p>The additional stanza would look similar to what's in earlier in callbacks.c</p>
<p><a href="https://github.com/geany/geany/blob/master/src/callbacks.c#L1490">https://github.com/geany/geany/blob/master/src/callbacks.c#L1490</a></p>
<p>Something like</p>
<div class="highlight highlight-source-c"><pre><span class="pl-en">utils_str_replace_all</span>(&command_line, <span class="pl-s"><span class="pl-pds">"</span>%b<span class="pl-pds">"</span></span>, tool_prefs.browser_cmd);</pre></div>
<p>Similarly, it would be nice if we could do something similar with the user's preferred terminal</p>
<div class="highlight highlight-source-c"><pre><span class="pl-en">utils_str_replace_all</span>(&command_line, <span class="pl-s"><span class="pl-pds">"</span>%t<span class="pl-pds">"</span></span>, tool_prefs.term_cmd);</pre></div>
<p><a href="https://github.com/geany/geany/blob/master/src/prefs.c#L678">https://github.com/geany/geany/blob/master/src/prefs.c#L678</a></p>
<p>It would also be nice if we could do the same with build commands</p>
<p><a href="https://github.com/geany/geany/blob/master/src/build.c#L726">https://github.com/geany/geany/blob/master/src/build.c#L726</a></p>
<p>As a use-case, it's handy for me to kick off a web browser to view something that results in HTML output.  For example, I have a markdown build command that uses 'grep' to convert Markdown to HTML.  From my filetypes.markdown:</p>
<pre><code>FT_01_LB=_Convert to HTML
FT_01_CM=docker run -i --rm mbentley/grip - --export - < "%d/%f" > "%d/%e.html"
FT_01_WD=
</code></pre>
<p>Here, it would be nice if I could append <code> && %b %d/%e.html &</code> to that command.</p>
<p>Please let me know if what I'm describing is viable and useful; if so, I can draft something and send along a PR.</p>
<p>Thanks!</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/issues/2395?email_source=notifications&email_token=AAIOWJYJ6X4HUGZHYRYMJELQTMW33A5CNFSM4JMKD6G2YY3PNVWWK3TUL52HS4DFUVEXG43VMWVGG33NNVSW45C7NFSM4HY2YHDA">view it on GitHub</a>, or <a href="https://github.com/notifications/unsubscribe-auth/AAIOWJYTKP5OCL4YMVDJFW3QTMW33ANCNFSM4JMKD6GQ">unsubscribe</a>.<img src="https://github.com/notifications/beacon/AAIOWJ2QHQRXHUJ2MC3MUKLQTMW33A5CNFSM4JMKD6G2YY3PNVWWK3TUL52HS4DFUVEXG43VMWVGG33NNVSW45C7NFSM4HY2YHDA.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/issues/2395?email_source=notifications\u0026email_token=AAIOWJYJ6X4HUGZHYRYMJELQTMW33A5CNFSM4JMKD6G2YY3PNVWWK3TUL52HS4DFUVEXG43VMWVGG33NNVSW45C7NFSM4HY2YHDA",
"url": "https://github.com/geany/geany/issues/2395?email_source=notifications\u0026email_token=AAIOWJYJ6X4HUGZHYRYMJELQTMW33A5CNFSM4JMKD6G2YY3PNVWWK3TUL52HS4DFUVEXG43VMWVGG33NNVSW45C7NFSM4HY2YHDA",
"name": "View Issue"
},
"description": "View this Issue on GitHub",
"publisher": {
"@type": "Organization",
"name": "GitHub",
"url": "https://github.com"
}
}
]</script>