This allows plugins to reload keybindings later during their execution. For more info see the comment in the commit.
---
I'm working on a plugin which is a more universal version of the current GeanyMiniscript plugins - users will be able to write custom scripts which will be executed and depending on the configuration the output will replace current document or selection or be inserted at current position or shown in new window etc. Users will be able to create new scripts (and remove existing). Each script will be keybindingable and since scripts can be removed or added, keybindings have to reload which isn't currently possible because keybindings_load_keyfile() isn't public and because of #1426.
(The plugin is in a VERY early stage of development and will likely not come out soon.) You can view, comment on, or merge this pull request online at:
https://github.com/geany/geany/pull/1430
-- Commit Summary --
* Export keybindings_load_keyfile() for plugins
-- File Changes --
M src/keybindings.c (9) M src/keybindings.h (4) M src/plugindata.h (2)
-- Patch Links --
https://github.com/geany/geany/pull/1430.patch https://github.com/geany/geany/pull/1430.diff
kugel- requested changes on this pull request.
@@ -824,6 +824,15 @@ static void apply_kb_accel(GeanyKeyGroup *group, GeanyKeyBinding *kb, gpointer u
}
+/** Reloads keybinding settings from configuration file. Normally plugins do + * not need to call this function as it is called automatically when a the + * plugin is activated. However, plugins which need to create keybindings + * dynamically and reload them when needed should call this function after + * all keybindings have been updated with plugin_set_key_group() and + * keybindings_set_item() calls - this makes sure that the corresponding user + * keybinding shortcuts are applied. + * @since 1.31. */
Recently we used "@since X.YY (API ZZZ)" (with api version, without trailing dot). The API version tends to be more interesting for plugin developers. Please change this accordingly.
@@ -824,6 +824,15 @@ static void apply_kb_accel(GeanyKeyGroup *group, GeanyKeyBinding *kb, gpointer u
}
+/** Reloads keybinding settings from configuration file. Normally plugins do
The first sentence should be separate, doxygen generates a brief one-liner for this.
kugel- requested changes on this pull request.
@@ -59,7 +59,7 @@ G_BEGIN_DECLS
* @warning You should not test for values below 200 as previously * @c GEANY_API_VERSION was defined as an enum value, not a macro. */ -#define GEANY_API_VERSION 230 +#define GEANY_API_VERSION 231
master is at 231 now
@kugel- Thanks for the review - I'll update the API version and docstring but only after it's clear when/if it's going to be merged - otherwise the numbers will be outdated.
@techee can't you make the scripting plugin a proxy and the scripts sub-plugins? IIUC @kugel- made it possible for proxies to manipulate keybindings.
@techee can't you make the scripting plugin a proxy and the scripts sub-plugins? IIUC @kugel- made it possible for proxies to manipulate keybindings.
Ah, no, the plugin does something different. The main feature is that the scripts can be written in ANY language and don't require ANY knowledge of GTK or Geany API. They only behave as filters so they do the following transformation:
``` input -> script -> output ```
where `input` becomes stdin of the script and the script writes `output` to stdout. Now both `input` and `output` will be configurable so for instance, `input` can be configured in a separate config file to be:
- current document - selection in current document - none (no input at all)
and output to:
- replace current document - insert at cursor position - replace selection - opened in a new document - written to the messages window
Also before the script is run, some values will be exported through environment variables so the script can e.g. use $CURRENT_DOCUMENT to get the name of current document.
So for instance a shell script containing only
``` git blame $CURRENT_DOCUMENT ```
and configuration
input: none output: new document
will open a new document with `git blame` of current document (you can easily imagine how one could re-create GeanyVC with single-line scripts like this).
@techee I'm not sure how your description differs from the Python proxy plugin running Python scripts, but ok.
@elextr I dont think you'd want one item per script in the Plugin Manager and one group in the keybindings.
sub-plugins are real plugins that must be activated separately and have their own keybindings. Seems not appropriate when you want just a collection of tiny scripts that can be mapped to keys.
@elextr @codebrainz @b4n how to proceed with this? @techee is waiting for confirmation that this is going to be merged before making the final adjustments. From my perspective the change looks OK.
Well, if @techee makes the changes I don't see why it can't be merged after the release.
Closed #1430 via 745f424b7752e1f181e0ef82b1d00ed99d6c69a7.
github-comments@lists.geany.org