<p>Hi there,</p>
<p>A minor problem that comes up a lot when I use Geany is wanting to open additional documents in a particular window. Opening a file with Geany via command line will open it in the first available Geany process—ostensibly the first process to try to create the socket file. This instance's editor window usually isn't the one I want and is typically in another workspace. As a result, my "main" Geany window has over thirty open documents in it right now.</p>
<p>I can often mitigate this problem using the <code>--new-instance</code> flag to just pop open a new editor, but this leads to lots of Geany windows, quickly.</p>
<p>It would be good if Geany could organize its sockets so that more than the first open instance could be communicated with. Ideally, the most recently focused editor would accept document open commands.</p>
<p>If that isn't an option, I often find myself poking around in the Geany Terminal for files I want to edit (usually with <code>grep</code> or <code>find</code>). Once I have a list, though, I have no good way of opening those documents. Simply calling <code>geany `find . -name 'foo.bar'`</code> will open them in the first process. What would be cool is if I could type <code>open</code> or <code>edit</code> instead, to open them in the current instance.</p>
<p>I think the terminal feature might actually be more difficult to implement than proper IPC. I've considered implementing it myself, but didn't want to just drop that feature on you as a big pull request. My thoughts:</p>
<ul>
<li>We could tackle multiple-instance communication by allowing successive instances to listen on the existing socket, or just having them create sequential new sockets. I prefer the former.</li>
<li>However we handle that, we will want to add a <code>socket_get_focus_time</code> (or similar) to look up how recently the editor was used.
<ul>
<li>If we put multiple listeners on a socket, we'll need to tag their responses with a UID (eg, their PID).
<ul>
<li>In this case, I'd probably just call the routine something like <code>socket_identify_instances</code>.</li>
</ul>
</li>
<li>Tracking the focus timestamp is as simple as updating a global in each process's <code>set-focus</code> or <code>notify::is-topmost</code> event.</li>
</ul>
</li>
<li>Once we've iterated all sockets or all responses, we would request the one with the latest (highest) timestamp to open the given files.
<ul>
<li>Again, if we had multiple instance on one socket, we'd need to tag the request with a PID or other UID from the timestamp call.</li>
</ul>
</li>
</ul>
<p>I believe this change isn't all that complicated, and might be interested in making it if the team doesn't have any other plans. Let me know.</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/1727">view it on GitHub</a>, or <a href="https://github.com/notifications/unsubscribe-auth/ABDrJ3-z5s8svvu3Smh0bh6_NbksUI5Wks5tDSCxgaJpZM4RLsks">mute the thread</a>.<img alt="" height="1" src="https://github.com/notifications/beacon/ABDrJwcK3jyIAafHKIoK6bKxzpxEh4k9ks5tDSCxgaJpZM4RLsks.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/issues/1727"></link>
  <meta itemprop="name" content="View Issue"></meta>
</div>
<meta itemprop="description" content="View this Issue 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":"Multiple window headaches (#1727)"}],"action":{"name":"View Issue","url":"https://github.com/geany/geany/issues/1727"}}}</script>