summaryrefslogtreecommitdiff
path: root/src/core/wee-command.c
diff options
context:
space:
mode:
authorSébastien Helleu <flashcode@flashtux.org>2020-12-19 17:07:52 +0100
committerSébastien Helleu <flashcode@flashtux.org>2020-12-19 20:59:38 +0100
commit7e2396ade81d6778e87ef50698efce5adfb4032e (patch)
tree5ff7e2ccbed94e3434afb6ccc495efc05887d34f /src/core/wee-command.c
parent1526f58d7a9142a96ffbcc133893fbab07fd6007 (diff)
downloadweechat-7e2396ade81d6778e87ef50698efce5adfb4032e.zip
core: add options "setvar" and "delvar" in command /buffer, rename option "localvar" to "listvar"
The option "localvar" (introduced long time ago, in WeeChat 0.3.0) is still recognized by WeeChat, to stay compatible with any extension/script calling it (or referencing it in the documentation). It is deprecated and will be removed in a future release.
Diffstat (limited to 'src/core/wee-command.c')
-rw-r--r--src/core/wee-command.c53
1 files changed, 47 insertions, 6 deletions
diff --git a/src/core/wee-command.c b/src/core/wee-command.c
index 3798979da..0d9648990 100644
--- a/src/core/wee-command.c
+++ b/src/core/wee-command.c
@@ -1136,8 +1136,15 @@ COMMAND_CALLBACK(buffer)
return WEECHAT_RC_OK;
}
- /* display local variables on buffer */
- if (string_strcasecmp (argv[1], "localvar") == 0)
+ /*
+ * display buffer local variables
+ *
+ * (note: option "localvar" has been replaced by "listvar" in WeeChat 3.1
+ * but is still accepted for compatibility with WeeChat ≤ 3.0;
+ * it is now deprecated and will be removed in a future version)
+ */
+ if ((string_strcasecmp (argv[1], "listvar") == 0)
+ || (string_strcasecmp (argv[1], "localvar") == 0))
{
if (argc > 2)
ptr_buffer = gui_buffer_search_by_number_or_name (argv[2]);
@@ -1168,6 +1175,34 @@ COMMAND_CALLBACK(buffer)
return WEECHAT_RC_OK;
}
+ /* set a local variable in buffer */
+ if (string_strcasecmp (argv[1], "setvar") == 0)
+ {
+ COMMAND_MIN_ARGS(3, "setvar");
+ if (argc == 3)
+ {
+ gui_buffer_local_var_add (buffer, argv[2], "");
+ }
+ else
+ {
+ value = string_remove_quotes (argv_eol[3], "'\"");
+ gui_buffer_local_var_add (buffer,
+ argv[2],
+ (value) ? value : argv_eol[3]);
+ if (value)
+ free (value);
+ }
+ return WEECHAT_RC_OK;
+ }
+
+ /* delete a local variable from a buffer */
+ if (string_strcasecmp (argv[1], "delvar") == 0)
+ {
+ COMMAND_MIN_ARGS(3, "delvar");
+ gui_buffer_local_var_remove (buffer, argv[2]);
+ return WEECHAT_RC_OK;
+ }
+
/* set a property on buffer */
if (string_strcasecmp (argv[1], "set") == 0)
{
@@ -7178,7 +7213,9 @@ command_init ()
" || renumber [<number1> [<number2> [<start>]]]"
" || close [<n1>[-<n2>]|<name>...]"
" || notify [<level>]"
- " || localvar [<number>|<name>]"
+ " || listvar [<number>|<name>]"
+ " || setvar <name> [<value>]"
+ " || delvar <name>"
" || set <property> [<value>]"
" || get <property>"
" || <number>|-|+|<name>"),
@@ -7209,8 +7246,10 @@ command_init ()
" message: for messages from users + highlights\n"
" all: all messages\n"
" reset: reset to default value (all)\n"
- "localvar: display local variables for the buffer\n"
- " set: set a property for current buffer\n"
+ " listvar: display local variables in a buffer\n"
+ " setvar: set a local variable in the current buffer\n"
+ " delvar: delete a local variable from the current buffer\n"
+ " set: set a property in the current buffer\n"
" get: display a property of current buffer\n"
" number: jump to buffer by number, possible prefix:\n"
" '+': relative jump, add number to current\n"
@@ -7265,7 +7304,9 @@ command_init ()
" || close %(buffers_plugins_names)|%*"
" || list"
" || notify reset|none|highlight|message|all"
- " || localvar %(buffers_numbers)|%(buffers_plugins_names)"
+ " || listvar %(buffers_numbers)|%(buffers_plugins_names)"
+ " || setvar %(buffer_local_variables) %(buffer_local_variable_value)"
+ " || delvar %(buffer_local_variables)"
" || set %(buffer_properties_set)"
" || get %(buffer_properties_get)"
" || %(buffers_plugins_names)|%(buffers_names)|%(irc_channels)|"