From a686fa6407706b73748f74c1613feabe304f6cef Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?S=C3=A9bastien=20Helleu?= Date: Sat, 4 Mar 2023 14:30:50 +0100 Subject: [PATCH] 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. --- src/gui/gui-key.c | 18 +++++++++++++++++- 1 file changed, 17 insertions(+), 1 deletion(-) diff --git a/src/gui/gui-key.c b/src/gui/gui-key.c index c801b2323..ccb957730 100644 --- a/src/gui/gui-key.c +++ b/src/gui/gui-key.c @@ -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]++; }