Right now only the "document-save" is fired when performing "save as" which lacks the information about the original file name (which, for instance, is necessary for the LSP client where it needs to notify the server that the "old" document was closed and the document under the new name opened).
Right now the plugin at https://github.com/techee/geany-lsp has the code using this signal commented-out - I'll uncomment it once it's added to Geany (so renaming a file might cause problems synchronizing the document with the server with the current implementation). You can view, comment on, or merge this pull request online at:
https://github.com/geany/geany/pull/3572
-- Commit Summary --
* Add "document-before-save-as" signal
-- File Changes --
M doc/pluginsignals.c (11) M src/document.c (2) M src/geanyobject.c (7) M src/geanyobject.h (1)
-- Patch Links --
https://github.com/geany/geany/pull/3572.patch https://github.com/geany/geany/pull/3572.diff
@kugel- commented on this pull request.
@@ -92,6 +92,17 @@ signal void (*document_reload)(GObject *obj, GeanyDocument *doc, gpointer user_d
*/ signal void (*document_before_save)(GObject *obj, GeanyDocument *doc, gpointer user_data);
+/** Sent before save as is performed with the original document. + * + * @param obj a GeanyObject instance, should be ignored. + * @param doc the original document. The document with the new file name is still + * reported by the "document-save" signal sent afterwards. + * @param user_data user data. + * + * @since TODO + */ +signal void (*document_before_save_as)(GObject *obj, GeanyDocument *doc, gpointer user_data);
Perhaps add a `boolean` return value to potentially allow the plugin to block saving the file?
@techee commented on this pull request.
@@ -92,6 +92,17 @@ signal void (*document_reload)(GObject *obj, GeanyDocument *doc, gpointer user_d
*/ signal void (*document_before_save)(GObject *obj, GeanyDocument *doc, gpointer user_data);
+/** Sent before save as is performed with the original document. + * + * @param obj a GeanyObject instance, should be ignored. + * @param doc the original document. The document with the new file name is still + * reported by the "document-save" signal sent afterwards. + * @param user_data user data. + * + * @since TODO + */ +signal void (*document_before_save_as)(GObject *obj, GeanyDocument *doc, gpointer user_data);
Hmm, I'm not sure if plugins should be allowed to do that and what exactly would this be good for. Do you have some example?
@elextr commented on this pull request.
@@ -92,6 +92,17 @@ signal void (*document_reload)(GObject *obj, GeanyDocument *doc, gpointer user_d
*/ signal void (*document_before_save)(GObject *obj, GeanyDocument *doc, gpointer user_data);
+/** Sent before save as is performed with the original document. + * + * @param obj a GeanyObject instance, should be ignored. + * @param doc the original document. The document with the new file name is still + * reported by the "document-save" signal sent afterwards. + * @param user_data user data. + * + * @since TODO + */ +signal void (*document_before_save_as)(GObject *obj, GeanyDocument *doc, gpointer user_data);
No, the plugin should not block a user saving a file, under any circumstances.
@techee pushed 1 commit.
eab9cc19ab8280f2eef24675c621fe78352595af Add "document-before-save-as" signal
Looks ok to me but I know nothing about GTK objects, but it looks the same as document_before_save :-)
@techee pushed 1 commit.
0dfd4655a98778c74ba2f3c2de135627acb84e01 Add "document-before-save-as" signal
@b4n approved this pull request.
LGTM
Merged #3572 into master.
github-comments@lists.geany.org