[Github-comments] Re: [geany/geany] Plugin extensions (aka LSP API) (PR #3849)

2024-06-23 Thread elextr via Github-comments
@elextr requested changes on this pull request.

@techee a (mostly) documentation review, lots of minor tweaks, but a 
significant point that I have commented on several times and might be best if I 
summarise here:

It is confusing the way function pointers that are members of struct 
PluginExtension are referred to as eg "`_perform()` function".  They are not 
functions, they are function pointers with specific member names that end in 
`_perform` and `_provided`, the functions they point to are in the plugin and 
can have any name.  You know what you mean and after some confusion I think I 
now know what you mean, so it would be best to fix it to use proper terminology 
so future readers don't go through the same confusion.

IIUC when it says "`_provided()` function" it should be "the function pointed 
to by the `_provided` member".  Yes its longer but one global replace 
should get most of them.

> @@ -1116,4 +1118,130 @@ static void proxy_cleanup(GeanyPlugin *plugin, 
> gpointer pdata)
 @endcode
 
 
+@page plugin_extension Plugin Extension HowTo
+
+@section plugin_extension_intro Introduction
+
+Since Geany 2.1 the PluginExtension API allows plugins to take over some of

Originally the Geany plugin API only allowed plugins to add to Geany 
functionality, plugins could not modify Geany built-in functionality, but since 
Geany 2.1 ...

> @@ -1116,4 +1118,130 @@ static void proxy_cleanup(GeanyPlugin *plugin, 
> gpointer pdata)
 @endcode
 
 
+@page plugin_extension Plugin Extension HowTo
+
+@section plugin_extension_intro Introduction
+
+Since Geany 2.1 the PluginExtension API allows plugins to take over some of
+the core Geany functionality, such as autocopletion, calltip display, symbol 
goto,
+typename highlighting inside document, etc.

instead of hand wavey "such as" would be better to have a proper list of all 
the functions available for replacement that could then be kept up to date.

> @@ -1116,4 +1118,130 @@ static void proxy_cleanup(GeanyPlugin *plugin, 
> gpointer pdata)
 @endcode
 
 
+@page plugin_extension Plugin Extension HowTo
+
+@section plugin_extension_intro Introduction
+
+Since Geany 2.1 the PluginExtension API allows plugins to take over some of
+the core Geany functionality, such as autocopletion, calltip display, symbol 
goto,
+typename highlighting inside document, etc.
+
+@section plugin_extension_init Initialization and cleanup
+

Not sure if doxygen will allow an actual link, but otherwise a reference to the 
plugin docs "Extension plugins are just normal plugins and behave as described 
in [link to plugin docs]."  That provides the docs about what an `init()` 
function of a plugin is and then leads into extensions also having to register.



> +
+Since Geany 2.1 the PluginExtension API allows plugins to take over some of
+the core Geany functionality, such as autocopletion, calltip display, symbol 
goto,
+typename highlighting inside document, etc.
+
+@section plugin_extension_init Initialization and cleanup
+
+First, any plugin interested in using this interface has to register its
+@c PluginExtension instance using @c plugin_extension_register(). This 
typically
+happens in the @c init() function of the plugin. Registered extensions have to 
be
+unregistered before the plugin is unloaded using @c 
plugin_extension_unregister(),
+typically inside the @c cleanup() function of the plugin.
+
+@section plugin_extension_impl Implementing extensions
+
+Inside the @c PluginExtension instance, the plugin fills-in the pointers to

whats a plugin extension instance? 

> +the core Geany functionality, such as autocopletion, calltip display, symbol 
> goto,
+typename highlighting inside document, etc.
+
+@section plugin_extension_init Initialization and cleanup
+
+First, any plugin interested in using this interface has to register its
+@c PluginExtension instance using @c plugin_extension_register(). This 
typically
+happens in the @c init() function of the plugin. Registered extensions have to 
be
+unregistered before the plugin is unloaded using @c 
plugin_extension_unregister(),
+typically inside the @c cleanup() function of the plugin.
+
+@section plugin_extension_impl Implementing extensions
+
+Inside the @c PluginExtension instance, the plugin fills-in the pointers to
+the functions it wishes to implement. Typically, these functions come in pairs:
+ - @c _provided() functions are used to query the plugin whether it implements

... used by Geany to query ...

Hmmm, its not until I got to the example below that I realised that 
`_provided()` is prefixed with the function name, maybe something like  
"`_provided()` where `` is the name of the function being replaced" 

(cultural aside,  is a local brand of beer, some say because the locals 
can't spell beer :grinning: )

> +
+@section plugin_extension_init Initialization and cleanup
+
+First, any plugin interested in using this interface has to register its
+@c PluginExtension instance using @c 

[Github-comments] Re: [geany/geany] "persistent temp files" feature for saveactions plugin (sqashed PR) (PR #3911)

2024-06-23 Thread elextr via Github-comments
> So what I would suggest is to have a checkbox with something like "Scribble 
> mode" inside the "Instant save" tab enabling this feature

"Does it save the Geany Scribble window then?" [user who didn't read the docs 
question]  

Whilst I didn't get the "persistent temp files" either and I still don't know 
what the use-case is beyond persisting unnamed buffers and I don't understand 
what the reason for saving unnamed buffers, if its unnamed how do I know whats 
in it to switch to it when they are all named "Untitled"?  So I can't suggest 
anything better than the descriptive "save unnamed buffers". 



-- 
Reply to this email directly or view it on GitHub:
https://github.com/geany/geany/pull/3911#issuecomment-2185387986
You are receiving this because you are subscribed to this thread.

Message ID: 

[Github-comments] Re: [geany/geany] [Feature request] Zig Language Support (Issue #3724)

2024-06-23 Thread rakshasha-medhi via Github-comments
is there a timeline where Zig programming language is supported in Geany? 
Cheers!

-- 
Reply to this email directly or view it on GitHub:
https://github.com/geany/geany/issues/3724#issuecomment-2185349735
You are receiving this because you are subscribed to this thread.

Message ID: 

[Github-comments] Re: [geany/geany-plugins] Default plugins folder incorrect / not found (Issue #1321)

2024-06-23 Thread Enrico Tröger via Github-comments
Closed #1321 as completed via 9c2ea2c320ffa235777c85e0e9fd5e4002873ac0.

-- 
Reply to this email directly or view it on GitHub:
https://github.com/geany/geany-plugins/issues/1321#event-13258211497
You are receiving this because you are subscribed to this thread.

Message ID: 

[Github-comments] Re: [geany/geany-plugins] Default plugins folder incorrect / not found (Issue #1321)

2024-06-23 Thread Enrico Tröger via Github-comments
Closed #1321 as completed via #1324.

-- 
Reply to this email directly or view it on GitHub:
https://github.com/geany/geany-plugins/issues/1321#event-13258211494
You are receiving this because you are subscribed to this thread.

Message ID: 

[Github-comments] Re: [geany/geany-plugins] Windows installer: Prefer Geany installation directory over user's HOME (PR #1324)

2024-06-23 Thread Enrico Tröger via Github-comments
Merged #1324 into master.

-- 
Reply to this email directly or view it on GitHub:
https://github.com/geany/geany-plugins/pull/1324#event-13258211467
You are receiving this because you are subscribed to this thread.

Message ID: 

[Github-comments] Re: [geany/geany] [RFC] Enable keyboard searching for Compiler and Messages tree views (PR #3823)

2024-06-23 Thread Enrico Tröger via Github-comments
Merged #3823 into master.

-- 
Reply to this email directly or view it on GitHub:
https://github.com/geany/geany/pull/3823#event-13258194272
You are receiving this because you are subscribed to this thread.

Message ID: 

[Github-comments] Re: [geany/geany-plugins] Addons: Hide status icon on startup until Geany has started (PR #1359)

2024-06-23 Thread Enrico Tröger via Github-comments
Merged #1359 into master.

-- 
Reply to this email directly or view it on GitHub:
https://github.com/geany/geany-plugins/pull/1359#event-13258192068
You are receiving this because you are subscribed to this thread.

Message ID: 

[Github-comments] Re: [geany/geany-plugins] Addons: Remove obsolete GTK_CHECK_VERSION checks (PR #1358)

2024-06-23 Thread Enrico Tröger via Github-comments
Merged #1358 into master.

-- 
Reply to this email directly or view it on GitHub:
https://github.com/geany/geany-plugins/pull/1358#event-13258188982
You are receiving this because you are subscribed to this thread.

Message ID: 

[Github-comments] Re: [geany/geany] meson: Prevent showing console after running geany in Windows (PR #3811)

2024-06-23 Thread Enrico Tröger via Github-comments
Do we agree to merge this?

It's a simple change which improves the Meson Windows build. I agree with 
@kugel- that at least for now we don't need to be backwards compatible with a 
four years old Ubuntu system for an alternate build system, the full featured 
Autotools based build system still exists.

-- 
Reply to this email directly or view it on GitHub:
https://github.com/geany/geany/pull/3811#issuecomment-2185319596
You are receiving this because you are subscribed to this thread.

Message ID: 

[Github-comments] Re: [geany/geany] "persistent temp files" feature for saveactions plugin (sqashed PR) (PR #3911)

2024-06-23 Thread LiquidCake via Github-comments
@LiquidCake commented on this pull request.



> @@ -462,6 +462,18 @@ gboolean main_is_realized(void)
 }
 
 
+/**
+ *  Checks whether Geany is quitting completely right now.
+ *
+ *  @return @c TRUE if the Geany is exiting right now or @c FALSE otherwise.
+ **/
+GEANY_API_SYMBOL
+gboolean geany_is_quitting(void)

i guess this is doable. Not sure we necessary want to allow picking default 
filetype for temp files but maybe it can be useful in some case

-- 
Reply to this email directly or view it on GitHub:
https://github.com/geany/geany/pull/3911#discussion_r1650156662
You are receiving this because you are subscribed to this thread.

Message ID: 

[Github-comments] Re: [geany/geany] "persistent temp files" feature for saveactions plugin (sqashed PR) (PR #3911)

2024-06-23 Thread LiquidCake via Github-comments
@LiquidCake commented on this pull request.



> @@ -462,6 +462,18 @@ gboolean main_is_realized(void)
 }
 
 
+/**
+ *  Checks whether Geany is 'closing all' tabs right now.
+ *
+ *  @return @c TRUE if the Geany is 'closing all' tabs right now or @c FALSE 
otherwise.
+ **/
+GEANY_API_SYMBOL
+gboolean geany_is_closing_all_tabs(void)

renamed

-- 
Reply to this email directly or view it on GitHub:
https://github.com/geany/geany/pull/3911#discussion_r1650152649
You are receiving this because you are subscribed to this thread.

Message ID: 

[Github-comments] Re: [geany/geany] "persistent temp files" feature for saveactions plugin (sqashed PR) (PR #3911)

2024-06-23 Thread LiquidCake via Github-comments
@LiquidCake commented on this pull request.



> +
+   g_free(old_file_name);
+   }
+}
+
+
+static void persistent_temp_files_document_save_cb(GObject *obj, GeanyDocument 
*doc, gpointer user_data)
+{
+   gchar *new_file_path, *old_file_path;
+
+   new_file_path = DOC_FILENAME(doc);
+   old_file_path = plugin_get_document_data(geany_plugin, doc, 
new_file_path);
+
+   if (old_file_path != NULL)
+   {
+   gchar *old_file_name = g_path_get_basename(old_file_path);

done

-- 
Reply to this email directly or view it on GitHub:
https://github.com/geany/geany/pull/3911#discussion_r1650152575
You are receiving this because you are subscribed to this thread.

Message ID: 

[Github-comments] Re: [geany/geany] "persistent temp files" feature for saveactions plugin (sqashed PR) (PR #3911)

2024-06-23 Thread LiquidCake via Github-comments
@LiquidCake commented on this pull request.



> + const gchar *filename;
+
+   dir = g_dir_open(persistent_temp_files_target_dir, 0, );
+   if (dir == NULL)
+   {
+   dialogs_show_msgbox(GTK_MESSAGE_ERROR, _("Persistent temp files 
directory not found"));
+   return NULL;
+   }
+
+   static glong temp_file_name_prefix_len = 
strlen(PERSISTENT_TEMP_FILE_NAME_PREFIX);
+
+   max_temp_file_number = 0;
+
+   foreach_dir(filename, dir)
+   {
+   utf8_filename = utils_get_utf8_from_locale(filename);

removed

-- 
Reply to this email directly or view it on GitHub:
https://github.com/geany/geany/pull/3911#discussion_r1650151916
You are receiving this because you are subscribed to this thread.

Message ID: 

[Github-comments] Re: [geany/geany] "persistent temp files" feature for saveactions plugin (sqashed PR) (PR #3911)

2024-06-23 Thread LiquidCake via Github-comments
@LiquidCake commented on this pull request.



> + const gchar *filename;
+
+   dir = g_dir_open(persistent_temp_files_target_dir, 0, );
+   if (dir == NULL)
+   {
+   dialogs_show_msgbox(GTK_MESSAGE_ERROR, _("Persistent temp files 
directory not found"));
+   return NULL;
+   }
+
+   static glong temp_file_name_prefix_len = 
strlen(PERSISTENT_TEMP_FILE_NAME_PREFIX);
+
+   max_temp_file_number = 0;
+
+   foreach_dir(filename, dir)
+   {
+   utf8_filename = utils_get_utf8_from_locale(filename);

removed

-- 
Reply to this email directly or view it on GitHub:
https://github.com/geany/geany/pull/3911#discussion_r1650150726
You are receiving this because you are subscribed to this thread.

Message ID: 

[Github-comments] Re: [geany/geany] "persistent temp files" feature for saveactions plugin (sqashed PR) (PR #3911)

2024-06-23 Thread LiquidCake via Github-comments
@LiquidCake commented on this pull request.



> + GtkWidget *page_label = NULL;
+
+   get_current_tab_label(_label);
+
+   old_file_path = gtk_widget_get_tooltip_text(page_label);
+   new_file_path = DOC_FILENAME(doc);
+
+   if (old_file_path == NULL)
+   {
+   ui_set_statusbar(TRUE, _("plugin error: failed to 
delete initial temp file "
+   "('failed to get notebook tab label text')"));
+
+   return;
+   }
+
+   old_file_name = g_path_get_basename(old_file_path);

done

-- 
Reply to this email directly or view it on GitHub:
https://github.com/geany/geany/pull/3911#discussion_r1650149346
You are receiving this because you are subscribed to this thread.

Message ID: 

[Github-comments] Re: [geany/geany] "persistent temp files" feature for saveactions plugin (sqashed PR) (PR #3911)

2024-06-23 Thread LiquidCake via Github-comments
@LiquidCake commented on this pull request.



> + /* we have to store old/new filename pair inside 
> document data to be able to somehow
+   pass it to document-save callback that is called 
directly after this one */
+   plugin_set_document_data_full(geany_plugin, doc, 
new_file_path, g_strdup(old_file_path), g_free);
+   }
+
+   g_free(old_file_name);
+   }
+}
+
+
+static void persistent_temp_files_document_save_cb(GObject *obj, GeanyDocument 
*doc, gpointer user_data)
+{
+   gchar *new_file_path, *old_file_path;
+
+   new_file_path = DOC_FILENAME(doc);
+   old_file_path = plugin_get_document_data(geany_plugin, doc, 
new_file_path);

done

-- 
Reply to this email directly or view it on GitHub:
https://github.com/geany/geany/pull/3911#discussion_r1650149072
You are receiving this because you are subscribed to this thread.

Message ID: 

[Github-comments] Re: [geany/geany] "persistent temp files" feature for saveactions plugin (sqashed PR) (PR #3911)

2024-06-23 Thread LiquidCake via Github-comments
@LiquidCake commented on this pull request.



> +static gchar* create_new_temp_file_name(void)
+{
+   GDir *dir;
+   GError *error = NULL;
+   gchar *utf8_filename, *temp_file_number_str;
+   gint temp_file_number, max_temp_file_number;
+   const gchar *filename;
+
+   dir = g_dir_open(persistent_temp_files_target_dir, 0, );
+   if (dir == NULL)
+   {
+   dialogs_show_msgbox(GTK_MESSAGE_ERROR, _("Persistent temp files 
directory not found"));
+   return NULL;
+   }
+
+   static glong temp_file_name_prefix_len = 
strlen(PERSISTENT_TEMP_FILE_NAME_PREFIX);

fixed

-- 
Reply to this email directly or view it on GitHub:
https://github.com/geany/geany/pull/3911#discussion_r1650148859
You are receiving this because you are subscribed to this thread.

Message ID: 

[Github-comments] Re: [geany/geany] "persistent temp files" feature for saveactions plugin (sqashed PR) (PR #3911)

2024-06-23 Thread LiquidCake via Github-comments
@LiquidCake commented on this pull request.



> + temp_file_number = atoi(temp_file_number_str);
+
+   if (temp_file_number > max_temp_file_number)
+   {
+   max_temp_file_number = temp_file_number;
+   }
+
+   g_free(temp_file_number_str);
+   }
+
+   g_free(utf8_filename);
+   }
+
+   g_dir_close(dir);
+
+   return g_strdup_printf(_("%s%d"), PERSISTENT_TEMP_FILE_NAME_PREFIX, 
max_temp_file_number + 1);

done

-- 
Reply to this email directly or view it on GitHub:
https://github.com/geany/geany/pull/3911#discussion_r1650148786
You are receiving this because you are subscribed to this thread.

Message ID: 

[Github-comments] Re: [geany/geany] "persistent temp files" feature for saveactions plugin (sqashed PR) (PR #3911)

2024-06-23 Thread LiquidCake via Github-comments
@LiquidCake commented on this pull request.



> + }
+
+   static glong temp_file_name_prefix_len = 
strlen(PERSISTENT_TEMP_FILE_NAME_PREFIX);
+
+   max_temp_file_number = 0;
+
+   foreach_dir(filename, dir)
+   {
+   utf8_filename = utils_get_utf8_from_locale(filename);
+
+   if (is_temp_saved_file(utf8_filename))
+   {
+   temp_file_number_str = g_utf8_substring(utf8_filename, 
temp_file_name_prefix_len, -1);
+   temp_file_number = atoi(temp_file_number_str);
+
+   if (temp_file_number > max_temp_file_number)

done

-- 
Reply to this email directly or view it on GitHub:
https://github.com/geany/geany/pull/3911#discussion_r1650148695
You are receiving this because you are subscribed to this thread.

Message ID: 

[Github-comments] Re: [geany/geany] "persistent temp files" feature for saveactions plugin (sqashed PR) (PR #3911)

2024-06-23 Thread LiquidCake via Github-comments
@LiquidCake commented on this pull request.



> + }
+   else
+   {
+   g_remove(locale_file_path);
+
+   ui_set_statusbar(TRUE, _("Empty temp file %s 
was deleted"), short_filename);
+   }
+
+   g_free(short_filename);
+   g_free(locale_file_path);
+   }
+   }
+}
+
+
+static void persistent_temp_files_document_before_save_cb(GObject *obj, 
GeanyDocument *doc, gpointer user_data)

right, missed that, done

-- 
Reply to this email directly or view it on GitHub:
https://github.com/geany/geany/pull/3911#discussion_r1650148562
You are receiving this because you are subscribed to this thread.

Message ID: 

[Github-comments] Re: [geany/geany] "persistent temp files" feature for saveactions plugin (sqashed PR) (PR #3911)

2024-06-23 Thread LiquidCake via Github-comments
@LiquidCake pushed 1 commit.

583afefbbbe8d1135085cac8c05ac539406e9393  persistent-temp-files-plugin: code 
review 2 - fixes

-- 
View it on GitHub:
https://github.com/geany/geany/pull/3911/files/e8f7761e5bddf1ec4062a814f19a0d2ff879f604..583afefbbbe8d1135085cac8c05ac539406e9393
You are receiving this because you are subscribed to this thread.

Message ID: 



[Github-comments] Re: [geany/geany] "persistent temp files" feature for saveactions plugin (sqashed PR) (PR #3911)

2024-06-23 Thread Jiří Techet via Github-comments
@techee commented on this pull request.



> @@ -462,6 +462,18 @@ gboolean main_is_realized(void)
 }
 
 
+/**
+ *  Checks whether Geany is quitting completely right now.
+ *
+ *  @return @c TRUE if the Geany is exiting right now or @c FALSE otherwise.
+ **/
+GEANY_API_SYMBOL
+gboolean geany_is_quitting(void)

> about extending Instantsave - this was an initial idea i tried, but then i 
> decided to do a separate function since unification becomes too complicated 
> both in terms of code and in terms of usage - e.g. instantsave's target 
> directory has a bit different usecase then ours, and there are other 
> complications.

OK, I noticed this post only now, my previous post is a bit outdated then.

I agree the semantics of the target directory are a bit different so maybe not 
a good idea to merge these two. But I'd still try to unify the two features a 
bit. First, I think the "Instant save" tab naming is quite horrible (I had to 
look up in Geany's documentation what it really does). So I'd suggest calling 
it something like "Empty files" which would contain 2 radio buttons:
- Save on creation (which would serve for instant save settings) - this would 
contain the target directory
- Use as Scribble - it would contain the current temp files settings

The settings in each group would be grayed-out as necessary when the other 
feature is enabled, default filetype combo box could be below and be shared by 
both.

-- 
Reply to this email directly or view it on GitHub:
https://github.com/geany/geany/pull/3911#discussion_r1650098514
You are receiving this because you are subscribed to this thread.

Message ID: 

[Github-comments] Re: [geany/geany] "persistent temp files" feature for saveactions plugin (sqashed PR) (PR #3911)

2024-06-23 Thread Jiří Techet via Github-comments
@techee requested changes on this pull request.

See some more review comments.

> Maybe one more idea - wouldn't it be better to introduce this feature just as 
> a special mode of "Instant save"? Because I think that's what this feature 
> really is - it just picks the file names automatically, prevents some 
> accidental tab closing but it's instant save otherwise. It would also prevent 
> possible confusion why the Enable button in preferences gets disabled.
What I meant by this is that the whole "persistent temp files" tab in config 
could go away and the "Instant save" tab would be reused for this feature too. 
Te rationale about this is:

It reduces confusion because these features are mutually exclusive and enabling 
one disables the other and users don't see clearly why this happens.
I'm slightly worried that users won't get the "persistent temp files" naming 
and what this feature is good for (as usual, nobody will read the 
documentation). So what I would suggest is to have a checkbox with something 
like "Scribble mode" inside the "Instant save" tab enabling this feature. Users 
probably already know the Scribble tab in Geany's message window and kind of 
know what to expect. Also, the generated filenames could start with scribble_ 
making it consistent with existing Geany features.
If it's implemented this way, the code below would just go away, only the save 
interval would have to be added into "Instant save" (grayed out when "Scribble 
mode" not enabled) and the text explaining the persistence of the directory 
where the temp files are stored should be changed a little.

Now before implementing anything, I'd suggest waiting for others what they 
think about it - this would make sense to me but others may have a different 
opinion.

> + }
+
+   static glong temp_file_name_prefix_len = 
strlen(PERSISTENT_TEMP_FILE_NAME_PREFIX);
+
+   max_temp_file_number = 0;
+
+   foreach_dir(filename, dir)
+   {
+   utf8_filename = utils_get_utf8_from_locale(filename);
+
+   if (is_temp_saved_file(utf8_filename))
+   {
+   temp_file_number_str = g_utf8_substring(utf8_filename, 
temp_file_name_prefix_len, -1);
+   temp_file_number = atoi(temp_file_number_str);
+
+   if (temp_file_number > max_temp_file_number)

`max_temp_file_number = MAX(max_temp_file_number, temp_file_number)` would be a 
little simpler.

> + temp_file_number = atoi(temp_file_number_str);
+
+   if (temp_file_number > max_temp_file_number)
+   {
+   max_temp_file_number = temp_file_number;
+   }
+
+   g_free(temp_file_number_str);
+   }
+
+   g_free(utf8_filename);
+   }
+
+   g_dir_close(dir);
+
+   return g_strdup_printf(_("%s%d"), PERSISTENT_TEMP_FILE_NAME_PREFIX, 
max_temp_file_number + 1);

I don't think the returned file name should be translatable (i.e. remove `_()`).

> +static gchar* create_new_temp_file_name(void)
+{
+   GDir *dir;
+   GError *error = NULL;
+   gchar *utf8_filename, *temp_file_number_str;
+   gint temp_file_number, max_temp_file_number;
+   const gchar *filename;
+
+   dir = g_dir_open(persistent_temp_files_target_dir, 0, );
+   if (dir == NULL)
+   {
+   dialogs_show_msgbox(GTK_MESSAGE_ERROR, _("Persistent temp files 
directory not found"));
+   return NULL;
+   }
+
+   static glong temp_file_name_prefix_len = 
strlen(PERSISTENT_TEMP_FILE_NAME_PREFIX);

The Geany code style is to place declarations at the beginning of the block - 
i.e. `static glong temp_file_name_prefix_len;` would go to the beginning of the 
function and you'd just assign the variable here.

Similarly, some of the declarations at the beginning of the function could go 
at the block beginnings of `for` and `if` blocks below so they are closer to 
their actual usage. Possibly also in the rest of the code.

> +{
+   /* if total text length is 1 while line count is 2 - then the only 
character of whole text is a linebreak,
+   which is how completely empty document saved by Geany to disk looks 
like */
+   return sci_get_length(doc->editor->sci) == 0
+   || (sci_get_length(doc->editor->sci) == 1 && 
sci_get_line_count(doc->editor->sci) == 2);
+}
+
+
+/* Open document in idle - useful when trying to re-open document from 
'document-close' callback
+ *
+ * @param pointer to document path (locale-encoded)
+ *
+ * @return always FALSE = Just a one shot execution
+ *
+ */
+static gboolean open_document_once_idle(gpointer p_locale_file_path)

It's a bit unfortunate this is necessary - maybe Geany could add some signal 
allowing plugins to disallow document closing.

> + /* we have to store old/new filename pair inside 
> document data to be able to somehow
+

[Github-comments] Re: [geany/geany-plugins] help with plugin writing docs (Issue #1357)

2024-06-23 Thread BMaxV via Github-comments
Ok, that step worked, I will see what I can do now! Thanks for the help!

-- 
Reply to this email directly or view it on GitHub:
https://github.com/geany/geany-plugins/issues/1357#issuecomment-2185014209
You are receiving this because you are subscribed to this thread.

Message ID: 

[Github-comments] Re: [geany/geany-plugins] help with plugin writing docs (Issue #1357)

2024-06-23 Thread BMaxV via Github-comments
Closed #1357 as completed.

-- 
Reply to this email directly or view it on GitHub:
https://github.com/geany/geany-plugins/issues/1357#event-13255845581
You are receiving this because you are subscribed to this thread.

Message ID: 

[Github-comments] Re: [geany/geany-plugins] help with plugin writing docs (Issue #1357)

2024-06-23 Thread BMaxV via Github-comments
Ok. Exactly that command and exactly that file name produce this:
```
> gcc -c plugin.c -fPIC `pkg-config --cflags geany` 
gcc: error: unrecognized command-line option ‘--cflags’
```

-- 
Reply to this email directly or view it on GitHub:
https://github.com/geany/geany-plugins/issues/1357#issuecomment-2185011857
You are receiving this because you are subscribed to this thread.

Message ID: 

[Github-comments] Re: [geany/geany-plugins] help with plugin writing docs (Issue #1357)

2024-06-23 Thread elextr via Github-comments
Please use _exactly_ the commands given in the [Geany plugin 
howto](https://www.geany.org/manual/reference/howto.html) "Building" section, 
do not add stuff to the command, and then post errors if it does not work.

Make sure your plugin file is `plugin.c` and you execute the commands in that 
directory.

-- 
Reply to this email directly or view it on GitHub:
https://github.com/geany/geany-plugins/issues/1357#issuecomment-2185009294
You are receiving this because you are subscribed to this thread.

Message ID: 

[Github-comments] Re: [geany/geany-plugins] help with plugin writing docs (Issue #1357)

2024-06-23 Thread BMaxV via Github-comments
Ok, so I'm on ubuntu 22.04 and `/usr/include/geany/` exists.

If I try this command:

```
gcc -c plugin.c -fPIC `pkg-config --cflags geany -I /usr/include/geany/`
```
I get this error:
```
gcc: error: unrecognized command-line option ‘--cflags’
```
if I remove that, I get this:

```
gcc -c plugin.c -fPIC `pkg-config -I /usr/include/geany

cc1: fatal error: plugin.c: No such file or directory
compilation terminated.
```

My gcc version is `gcc (Ubuntu 11.4.0-1ubuntu1~22.04) 11.4.0` if that makes a 
difference

-- 
Reply to this email directly or view it on GitHub:
https://github.com/geany/geany-plugins/issues/1357#issuecomment-2185004374
You are receiving this because you are subscribed to this thread.

Message ID: 

[Github-comments] Re: [geany/geany] "persistent temp files" feature for saveactions plugin (sqashed PR) (PR #3911)

2024-06-23 Thread LiquidCake via Github-comments
@LiquidCake commented on this pull request.



> @@ -462,6 +462,18 @@ gboolean main_is_realized(void)
 }
 
 
+/**
+ *  Checks whether Geany is quitting completely right now.
+ *
+ *  @return @c TRUE if the Geany is exiting right now or @c FALSE otherwise.
+ **/
+GEANY_API_SYMBOL
+gboolean geany_is_quitting(void)

about extending Instantsave - this was an initial idea i tried, but then i 
decided to do a separate function since unification becomes too complicated 
both in terms of code and in terms of usage - e.g. instantsave's target 
directory has a bit different usecase then ours, and there are other 
complications.

Btw i changed mutual exclusion of instantsave vs temp_files from blocking one 
another's checkbox to just automatically de-activating one when another is 
activated. This seems a good-enough UX to me as newly created files start to 
look differently when you switch mode anyway 

-- 
Reply to this email directly or view it on GitHub:
https://github.com/geany/geany/pull/3911#discussion_r1650076239
You are receiving this because you are subscribed to this thread.

Message ID: 

[Github-comments] Re: [geany/geany] "persistent temp files" feature for saveactions plugin (sqashed PR) (PR #3911)

2024-06-23 Thread LiquidCake via Github-comments
@LiquidCake commented on this pull request.



> @@ -462,6 +462,18 @@ gboolean main_is_realized(void)
 }
 
 
+/**
+ *  Checks whether Geany is quitting completely right now.
+ *
+ *  @return @c TRUE if the Geany is exiting right now or @c FALSE otherwise.
+ **/
+GEANY_API_SYMBOL
+gboolean geany_is_quitting(void)

initial idea was to force all temp files to be open in Geany all the time, or 
at least open all of them on startup. Even ones created by concurrent Geany 
instances or manually on disk. 
Thats why we had that function "load all temp files" and why we used "is 
quitting" instead of "is closing all" - to force user saving or deleting temp 
files after clicking "close all" and avoid dialogs only when closing window.

Now after few changes (temp files are now properly numbered by integers and are 
properly readable in "recent files" menu) i guess we got a better solution and 
this idea of keeping all existing temp files open is probably not actual.
So i did as was suggested - switched to "closing all" status and started 
completely relying on session management mechanism to re-open those temp files 
which it finds appropriate.
This seems to work fine, including general session vs project sessions.

-- 
Reply to this email directly or view it on GitHub:
https://github.com/geany/geany/pull/3911#discussion_r1650075197
You are receiving this because you are subscribed to this thread.

Message ID: 

[Github-comments] Re: [geany/geany] "persistent temp files" feature for saveactions plugin (sqashed PR) (PR #3911)

2024-06-23 Thread LiquidCake via Github-comments
@LiquidCake commented on this pull request.



> + }
+}
+
+
+static void persistent_temp_files_document_close_cb(GObject *obj, 
GeanyDocument *doc, gpointer user_data)
+{
+   gchar *file_path, *locale_file_path, *short_filename;
+
+   file_path = doc->file_name;
+
+   if (enable_persistent_temp_files && file_path != NULL && ! 
geany_is_quitting())
+   {
+   if (is_temp_saved_file_doc(doc) && file_exists(doc->file_name))
+   {
+   short_filename = document_get_basename_for_display(doc, 
-1);
+   locale_file_path = 
utils_get_locale_from_utf8(file_path);

done

-- 
Reply to this email directly or view it on GitHub:
https://github.com/geany/geany/pull/3911#discussion_r1650072403
You are receiving this because you are subscribed to this thread.

Message ID: 

[Github-comments] Re: [geany/geany] "persistent temp files" feature for saveactions plugin (sqashed PR) (PR #3911)

2024-06-23 Thread LiquidCake via Github-comments
@LiquidCake commented on this pull request.



> + locale_file_path = g_build_path(G_DIR_SEPARATOR_S, path, 
> filename, NULL);
+
+   if (is_temp_saved_file(utf8_filename))
+   {
+   document_open_file(locale_file_path, FALSE, NULL, NULL);
+   }
+
+   g_free(utf8_filename);
+   g_free(locale_file_path);
+   }
+
+   g_dir_close(dir);
+}
+
+
+static gboolean file_exists(gchar *utf8_file_path)

done

-- 
Reply to this email directly or view it on GitHub:
https://github.com/geany/geany/pull/3911#discussion_r1650072276
You are receiving this because you are subscribed to this thread.

Message ID: 

[Github-comments] Re: [geany/geany] "persistent temp files" feature for saveactions plugin (sqashed PR) (PR #3911)

2024-06-23 Thread LiquidCake via Github-comments
@LiquidCake commented on this pull request.



> @@ -347,8 +706,13 @@ static gboolean on_document_focus_out(GObject *object, 
> GeanyEditor *editor,
 PluginCallback plugin_callbacks[] =
 {
{ "document-new", (GCallback) _document_new_cb, FALSE, NULL 
},
+   { "document-new", (GCallback) _temp_files_document_new_cb, 
FALSE, NULL },

done

-- 
Reply to this email directly or view it on GitHub:
https://github.com/geany/geany/pull/3911#discussion_r1650072257
You are receiving this because you are subscribed to this thread.

Message ID: 

[Github-comments] Re: [geany/geany] "persistent temp files" feature for saveactions plugin (sqashed PR) (PR #3911)

2024-06-23 Thread LiquidCake via Github-comments
@LiquidCake commented on this pull request.



> + }
+   else
+   {
+   g_remove(locale_file_path);
+
+   ui_set_statusbar(TRUE, _("Empty temp file %s 
was deleted"), short_filename);
+   }
+
+   g_free(short_filename);
+   g_free(locale_file_path);
+   }
+   }
+}
+
+
+static void persistent_temp_files_document_before_save_cb(GObject *obj, 
GeanyDocument *doc, gpointer user_data)

using before-save-as wont work because at the moment that event is fired we 
dont yet have "new" document name defined, and we need both "old" and "new"

-- 
Reply to this email directly or view it on GitHub:
https://github.com/geany/geany/pull/3911#discussion_r1650072218
You are receiving this because you are subscribed to this thread.

Message ID: 

[Github-comments] Re: [geany/geany] "persistent temp files" feature for saveactions plugin (sqashed PR) (PR #3911)

2024-06-23 Thread LiquidCake via Github-comments
@LiquidCake commented on this pull request.



> +
+   if (file_path == NULL)
+   {
+   return FALSE;
+   }
+
+   filename = g_path_get_basename(file_path);
+   matched = is_temp_saved_file(filename);
+
+   g_free(filename);
+
+   return matched;
+}
+
+
+static void load_all_temp_files_into_editor(const gchar *path)

removed, see comment about `is_quitting vs closing_all`

-- 
Reply to this email directly or view it on GitHub:
https://github.com/geany/geany/pull/3911#discussion_r1650072068
You are receiving this because you are subscribed to this thread.

Message ID: 

[Github-comments] Re: [geany/geany] "persistent temp files" feature for saveactions plugin (sqashed PR) (PR #3911)

2024-06-23 Thread LiquidCake via Github-comments
@LiquidCake commented on this pull request.



> + ui_set_statusbar(TRUE, "%s", message);
+   g_warning("%s", message);
+   g_free(message);
+   g_free(new_filename);
+   return;
+   }
+
+   close(fd); /* close the returned file descriptor as we only need the 
filename */
+
+   doc->file_name = new_filename;
+
+   if (ft != NULL && ft->id == GEANY_FILETYPES_NONE)
+   document_set_filetype(doc, 
filetypes_lookup_by_name(default_ft));
+
+   /* force saving the file to enable all the related actions(tab name, 
filetype, etc.) */
+   document_save_file(doc, TRUE);

this method was re-used from Instantsave, which seems to need arbitrary file 
type setting.
Anyway im not re-using this code anymore - switched to `document_save_file_as` 
as you suggested. So Instantsave's code is left intact

-- 
Reply to this email directly or view it on GitHub:
https://github.com/geany/geany/pull/3911#discussion_r1650071783
You are receiving this because you are subscribed to this thread.

Message ID: 

[Github-comments] Re: [geany/geany] "persistent temp files" feature for saveactions plugin (sqashed PR) (PR #3911)

2024-06-23 Thread LiquidCake via Github-comments
@LiquidCake commented on this pull request.



>   return;
}
 
-   close(fd); /* close the returned file descriptor as we only 
need the filename */
+   old_file_name = g_path_get_basename(old_file_path);
+
+   if (is_temp_saved_file(old_file_name) && ! 
g_str_equal(old_file_path, new_file_path))
+   {
+   /* we have to store old/new filename pair in a global 
hashtable to be able to somehow
+   pass it to document-save callback that is called 
directly after this one */
+   g_hash_table_insert(

done

-- 
Reply to this email directly or view it on GitHub:
https://github.com/geany/geany/pull/3911#discussion_r1650071263
You are receiving this because you are subscribed to this thread.

Message ID: 

[Github-comments] Re: [geany/geany] "persistent temp files" feature for saveactions plugin (sqashed PR) (PR #3911)

2024-06-23 Thread LiquidCake via Github-comments
@LiquidCake pushed 1 commit.

064011ad2e00ecb18e2b5177b2149c8908098027  persistent-temp-files-plugin: code 
review - fixes

-- 
View it on GitHub:
https://github.com/geany/geany/pull/3911/files/6616f7e1443a11d820666006be881c8616328b69..064011ad2e00ecb18e2b5177b2149c8908098027
You are receiving this because you are subscribed to this thread.

Message ID: 



[Github-comments] Re: [geany/geany] "persistent temp files" feature for saveactions plugin (sqashed PR) (PR #3911)

2024-06-23 Thread LiquidCake via Github-comments
@LiquidCake pushed 1 commit.

6616f7e1443a11d820666006be881c8616328b69  persistent-temp-files-plugin: code 
review - fixes

-- 
View it on GitHub:
https://github.com/geany/geany/pull/3911/files/7ef14a845f76aabcdf8917d6d419e41e4ac0be82..6616f7e1443a11d820666006be881c8616328b69
You are receiving this because you are subscribed to this thread.

Message ID: 



[Github-comments] Re: [geany/geany] "persistent temp files" feature for saveactions plugin (sqashed PR) (PR #3911)

2024-06-23 Thread LiquidCake via Github-comments
@LiquidCake pushed 1 commit.

7ef14a845f76aabcdf8917d6d419e41e4ac0be82  persistent-temp-files-plugin: code 
review - fixes

-- 
View it on GitHub:
https://github.com/geany/geany/pull/3911/files/a8c882687ff5fc633ba055c165dc7ae94c9daf9a..7ef14a845f76aabcdf8917d6d419e41e4ac0be82
You are receiving this because you are subscribed to this thread.

Message ID: 



[Github-comments] Re: [geany/geany] "persistent temp files" feature for saveactions plugin (sqashed PR) (PR #3911)

2024-06-23 Thread LiquidCake via Github-comments
@LiquidCake pushed 1 commit.

a8c882687ff5fc633ba055c165dc7ae94c9daf9a  persistent-temp-files-plugin: code 
review - fixes

-- 
View it on GitHub:
https://github.com/geany/geany/pull/3911/files/143fba118d64e4c8fba913638b389283627fd012..a8c882687ff5fc633ba055c165dc7ae94c9daf9a
You are receiving this because you are subscribed to this thread.

Message ID: 



[Github-comments] Re: [geany/geany] Support for remote files without gvfs-fuse or fuse (#1414)

2024-06-23 Thread Jiří Techet via Github-comments
Closed #1414.

-- 
Reply to this email directly or view it on GitHub:
https://github.com/geany/geany/pull/1414#event-13255567481
You are receiving this because you are subscribed to this thread.

Message ID: 

[Github-comments] Re: [geany/geany] Prefix generated scope field by the "scope:" prefix (PR #3592)

2024-06-23 Thread Jiří Techet via Github-comments
Closed #3592.

-- 
Reply to this email directly or view it on GitHub:
https://github.com/geany/geany/pull/3592#event-13255548575
You are receiving this because you are subscribed to this thread.

Message ID: 

[Github-comments] Re: [geany/geany] If project is open, use base_path as a search path in find in files (#454)

2024-06-23 Thread Jiří Techet via Github-comments
Closed #454.

-- 
Reply to this email directly or view it on GitHub:
https://github.com/geany/geany/pull/454#event-13255544867
You are receiving this because you are subscribed to this thread.

Message ID: 

[Github-comments] Re: [geany/geany] Open files session files after entering main loop (#924)

2024-06-23 Thread Jiří Techet via Github-comments
Closed #924.

-- 
Reply to this email directly or view it on GitHub:
https://github.com/geany/geany/pull/924#event-13255539863
You are receiving this because you are subscribed to this thread.

Message ID: 

[Github-comments] Re: [geany/geany] Only show recent file menu entries for files which exist (#364)

2024-06-23 Thread Jiří Techet via Github-comments
Closed #364.

-- 
Reply to this email directly or view it on GitHub:
https://github.com/geany/geany/pull/364#event-13255537690
You are receiving this because you are subscribed to this thread.

Message ID: 

[Github-comments] Re: [geany/geany] Set correct sidebar/message window positions before showing the… (#576)

2024-06-23 Thread Jiří Techet via Github-comments
Closed #576.

-- 
Reply to this email directly or view it on GitHub:
https://github.com/geany/geany/pull/576#event-13255536768
You are receiving this because you are subscribed to this thread.

Message ID: