<p>It is now possible to use patterns to specify the context action command to be executed<br>
if the user selects "Context Action" from the context menu. The patterns can be configured<br>
in the filetypes configuration files.</p>
<p>Each action pattern entry needs to have a key of the form "context_action_pattern" followed by<br>
a number from 1 to 99 (e.g. "context_action_pattern1", "context_action_pattern2"). The value<br>
assigned must be a ';' separated string list with two entries. First, the pattern to match and<br>
then the command to execute. So a complete entry looks like this:</p>
<p>context_action_pattern1=pattern;command;</p>
<p>Loading of the patterns stops after the 99th entry or if no more entries are found.<br>
A gap in the entries numeration would lead to early abort of loading.</p>
<p>To find the corresponding action command for the current word/selection the following<br>
procedure is performed:</p>
<ol>
<li>Try to match the current selection/word against a pattern.<br>
If there is a match then the corresponding command is returned.<br>
Patterns are matched in the order in which they are specified in the filetype config file.<br>
The pattern matching uses the flag "G_REGEX_MATCH_ANCHORED" which means the pattern<br>
needs to match the word from the start. This is equal to using "^" at the start<br>
of the pattern.</li>
<li>If there is no match return the "context_action_cmd" for the filetype.</li>
<li>If that is empty use the context action from the global "Tools" preferences</li>
</ol>
<p>Here is an example config for <code>filetype.c</code> to try out the feature:</p>
<pre><code># context action command (please see Geany's main documentation for details)
context_action_cmd=firefox --new-tab "http://www.cplusplus.com/search.do?q=%s"
context_action_pattern1=g_.*;firefox --new-tab "https://developer.gnome.org/symbols/search?q=%s";
context_action_pattern2=xml.*;firefox --new-tab "http://xmlsoft.org/search.php?query=%s";
</code></pre>
<p>This config will open/search the cplusplus website if there is no match in the patterns. If the current word/selection starts with <code>g_</code> then it searches the gnome API. If the current word/selection starts with <code>xml</code> then it searches the Libxml2 website.</p>

<hr>

<h4>You can view, comment on, or merge this pull request online at:</h4>
<p>  <a href='https://github.com/geany/geany/pull/1643'>https://github.com/geany/geany/pull/1643</a></p>

<h4>Commit Summary</h4>
<ul>
  <li>Added Context Action Patterns.</li>
</ul>

<h4>File Changes</h4>
<ul>
  <li>
    <strong>M</strong>
    <a href="https://github.com/geany/geany/pull/1643/files#diff-0">src/callbacks.c</a>
    (7)
  </li>
  <li>
    <strong>M</strong>
    <a href="https://github.com/geany/geany/pull/1643/files#diff-1">src/filetypes.c</a>
    (107)
  </li>
  <li>
    <strong>M</strong>
    <a href="https://github.com/geany/geany/pull/1643/files#diff-2">src/filetypes.h</a>
    (3)
  </li>
</ul>

<h4>Patch Links:</h4>
<ul>
  <li><a href='https://github.com/geany/geany/pull/1643.patch'>https://github.com/geany/geany/pull/1643.patch</a></li>
  <li><a href='https://github.com/geany/geany/pull/1643.diff'>https://github.com/geany/geany/pull/1643.diff</a></li>
</ul>

<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/pull/1643">view it on GitHub</a>, or <a href="https://github.com/notifications/unsubscribe-auth/ABDrJ0YpfoYFSqRYn6Tk1bwMZ_Axiwhfks5ssLzYgaJpZM4P5YzU">mute the thread</a>.<img alt="" height="1" src="https://github.com/notifications/beacon/ABDrJzpJPuT3g0qirowL3qUpb8nMAatxks5ssLzYgaJpZM4P5YzU.gif" width="1" /></p>
<div itemscope itemtype="http://schema.org/EmailMessage">
<div itemprop="action" itemscope itemtype="http://schema.org/ViewAction">
  <link itemprop="url" href="https://github.com/geany/geany/pull/1643"></link>
  <meta itemprop="name" content="View Pull Request"></meta>
</div>
<meta itemprop="description" content="View this Pull Request on GitHub"></meta>
</div>

<script type="application/json" data-scope="inboxmarkup">{"api_version":"1.0","publisher":{"api_key":"05dde50f1d1a384dd78767c55493e4bb","name":"GitHub"},"entity":{"external_key":"github/geany/geany","title":"geany/geany","subtitle":"GitHub repository","main_image_url":"https://cloud.githubusercontent.com/assets/143418/17495839/a5054eac-5d88-11e6-95fc-7290892c7bb5.png","avatar_image_url":"https://cloud.githubusercontent.com/assets/143418/15842166/7c72db34-2c0b-11e6-9aed-b52498112777.png","action":{"name":"Open in GitHub","url":"https://github.com/geany/geany"}},"updates":{"snippets":[{"icon":"DESCRIPTION","message":"Added Context Action Patterns. (#1643)"}],"action":{"name":"View Pull Request","url":"https://github.com/geany/geany/pull/1643"}}}</script>