1
0
mirror of https://github.com/weechat/weechat.git synced 2026-06-12 14:14:48 +02:00

api: change default value of existing key options with function key_bind

With this fix, fset buffer shows the key as modified only if the user actually
changed the command bound to the key.
This commit is contained in:
Sébastien Helleu
2023-03-04 14:30:50 +01:00
parent 55d9989b85
commit a686fa6407
+17 -1
View File
@@ -1527,6 +1527,7 @@ gui_key_bind_plugin_hashtable_map_cb (void *data,
{
int *user_data;
struct t_gui_key *ptr_key;
struct t_config_option *ptr_option;
/* make C compiler happy */
(void) hashtable;
@@ -1540,8 +1541,23 @@ gui_key_bind_plugin_hashtable_map_cb (void *data,
return;
ptr_key = gui_key_search (gui_keys[user_data[0]], key);
if (!ptr_key)
if (ptr_key)
{
/*
* adjust default value (command) of key option in config, so that
* fset buffer shows the key as modified only if the user actually
* changed the command bound to the key
*/
ptr_option = config_file_search_option (
weechat_config_file,
weechat_config_section_key[user_data[0]],
key);
if (ptr_option)
config_file_option_set_default (ptr_option, value, 1);
}
else
{
/* create key */
if (gui_key_new (NULL, user_data[0], key, value, 1))
user_data[1]++;
}