diff options
author | Sébastien Helleu <flashcode@flashtux.org> | 2022-10-12 21:29:38 +0200 |
---|---|---|
committer | Sébastien Helleu <flashcode@flashtux.org> | 2022-10-12 21:29:38 +0200 |
commit | 7d2e8b9143f060411edbf98aab8dd4158784d6d3 (patch) | |
tree | 1d3677a9a1fc053de77a37bab52182f190ae6297 | |
parent | f97b74cae8a079807c4048eb20ee0c23415c34ce (diff) | |
download | weechat-7d2e8b9143f060411edbf98aab8dd4158784d6d3.zip |
core: allow command `/toggle` to create option before setting the value, if allowed in the section (closes #1837)
-rw-r--r-- | ChangeLog.adoc | 4 | ||||
-rw-r--r-- | src/core/wee-command.c | 21 |
2 files changed, 20 insertions, 5 deletions
diff --git a/ChangeLog.adoc b/ChangeLog.adoc index 76322b25e..f36379689 100644 --- a/ChangeLog.adoc +++ b/ChangeLog.adoc @@ -18,6 +18,10 @@ https://weechat.org/files/releasenotes/ReleaseNotes-devel.html[release notes] [[v3.8]] == Version 3.8 (under dev) +New features:: + + * core: allow command `/toggle` to create option before setting the value, if allowed in the section (issue #1837) + Bug fixes:: * core: fix context info in buffers with free content (issue #1832) diff --git a/src/core/wee-command.c b/src/core/wee-command.c index b4d5cd82f..5994ebbe7 100644 --- a/src/core/wee-command.c +++ b/src/core/wee-command.c @@ -6314,11 +6314,22 @@ COMMAND_CALLBACK(toggle) config_file_search_with_string (argv[1], NULL, NULL, &ptr_option, NULL); if (!ptr_option) { - gui_chat_printf (NULL, - _("%sOption \"%s\" not found"), - gui_chat_prefix[GUI_CHAT_PREFIX_ERROR], - argv[1]); - return WEECHAT_RC_OK; + /* try to create option with empty value if not existing */ + rc = config_file_option_set_with_string (argv[1], ""); + if ((rc == WEECHAT_CONFIG_OPTION_SET_OK_CHANGED) || + (rc == WEECHAT_CONFIG_OPTION_SET_OK_SAME_VALUE)) + { + config_file_search_with_string (argv[1], NULL, NULL, &ptr_option, + NULL); + } + if (!ptr_option) + { + gui_chat_printf (NULL, + _("%sOption \"%s\" not found"), + gui_chat_prefix[GUI_CHAT_PREFIX_ERROR], + argv[1]); + return WEECHAT_RC_OK; + } } if ((ptr_option->type != CONFIG_OPTION_TYPE_BOOLEAN) |