<p>Here's a patch.  It was pretty easy to make: <a href="https://github.com/konsolebox/geany/commit/e329b289df38442b96d2b9add6586b2c3ed02c1b" class="commit-link">konsolebox@<tt>e329b28</tt></a></p>

<p>I can create a PR if it's really wanted.</p>

<blockquote>
<p>... separating rename and save is a better idea still.</p>
</blockquote>

<p>In the context of stand-alone renaming yes, but if it's about a document not, because like I said every caller would make sure that all necessary listeners to "document-save" would get notified about the change.  I'm not sure if it makes sense to have the GeanyDocument stay as is while the name of the file in the filesystem gets changed.  I don't say any use case for it.  Not to mention <code>document_rename_file()</code> already calls <code>document_stop_file_monitoring()</code> and it expects <code>document_save_file_as()</code> to be called after.  We wouldn't want plugins (or anything that calls <code>document_rename_file()</code>) to always do both sequences separately.</p>

<p>... Ok, maybe since nothing is really changed in GeanyDocument when a file is renamed, notifying listeners to "document-save" may not be necessary (until the save operation actually starts), but both operations are still better put together in a single API function due to the fact that <code>document_rename_file()</code> can't be used alone in one operating session.</p>

<p>Here's a gist for the function: <a href="https://gist.github.com/konsolebox/b95bd34e518ac1d1aa60a6348bd498b9">https://gist.github.com/konsolebox/b95bd34e518ac1d1aa60a6348bd498b9</a></p>

<p>There are surprising things about <code>doc->priv->file_disk_status</code> but I haven't looked into it thoroughly yet.  Basically the idea is that <code>document_save_file_as()</code> does not revert <code>doc->priv->file_disk_status</code> to its original state if the save fails.  And so does <code>document_rename_file()</code>.  Simply because it can't, because it's used separately from <code>document_save_file_as()</code>.</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/pull/1180#issuecomment-240984242">view it on GitHub</a>, or <a href="https://github.com/notifications/unsubscribe-auth/ABDrJ_ZNiwMRaJeLIytQSc-ttrMaIGL0ks5qhYWYgaJpZM4JnQzb">mute the thread</a>.<img alt="" height="1" src="https://github.com/notifications/beacon/ABDrJ-PzNp4EmfYsh_baPD0NwSWP3tp-ks5qhYWYgaJpZM4JnQzb.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/1180#issuecomment-240984242"></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":"PERSON","message":"@konsolebox in #1180: Here's a patch.  It was pretty easy to make: https://github.com/konsolebox/geany/commit/e329b289df38442b96d2b9add6586b2c3ed02c1b\r\n\r\nI can create a PR if it's really wanted.\r\n\r\n\u003e ... separating rename and save is a better idea still.\r\n\r\nIn the context of stand-alone renaming yes, but if it's about a document not, because like I said every caller would make sure that all necessary listeners to \"document-save\" would get notified about the change.  I'm not sure if it makes sense to have the GeanyDocument stay as is while the name of the file in the filesystem gets changed.  I don't say any use case for it.  Not to mention `document_rename_file()` already calls `document_stop_file_monitoring()` and it expects `document_save_file_as()` to be called after.  We wouldn't want plugins (or anything that calls `document_rename_file()`) to always do both sequences separately.\r\n\r\n... Ok, maybe since nothing is really changed in GeanyDocument when a file is renamed, notifying listeners to \"document-save\" may not be necessary (until the save operation actually starts), but both operations are still better put together in a single API function due to the fact that `document_rename_file()` can't be used alone in one operating session.\r\n\r\nHere's a gist for the function: https://gist.github.com/konsolebox/b95bd34e518ac1d1aa60a6348bd498b9\r\n\r\nThere are surprising things about `doc-\u003epriv-\u003efile_disk_status` but I haven't looked into it thoroughly yet.  Basically the idea is that `document_save_file_as()` does not revert `doc-\u003epriv-\u003efile_disk_status` to its original state if the save fails.  And so does `document_rename_file()`.  Simply because it can't, because it's used separately from `document_save_file_as()`."}],"action":{"name":"View Pull Request","url":"https://github.com/geany/geany/pull/1180#issuecomment-240984242"}}}</script>