summaryrefslogtreecommitdiff
path: root/src/core/wee-config.c
diff options
context:
space:
mode:
Diffstat (limited to 'src/core/wee-config.c')
-rw-r--r--src/core/wee-config.c134
1 files changed, 117 insertions, 17 deletions
diff --git a/src/core/wee-config.c b/src/core/wee-config.c
index 3589a042a..a44e0b80f 100644
--- a/src/core/wee-config.c
+++ b/src/core/wee-config.c
@@ -1,7 +1,7 @@
/*
* wee-config.c - WeeChat configuration options (file weechat.conf)
*
- * Copyright (C) 2003-2017 Sébastien Helleu <flashcode@flashtux.org>
+ * Copyright (C) 2003-2018 Sébastien Helleu <flashcode@flashtux.org>
* Copyright (C) 2005-2006 Emmanuel Bouthenot <kolter@openics.org>
*
* This file is part of WeeChat, the extensible chat client.
@@ -178,6 +178,7 @@ struct t_config_option *config_look_read_marker;
struct t_config_option *config_look_read_marker_always_show;
struct t_config_option *config_look_read_marker_string;
struct t_config_option *config_look_save_config_on_exit;
+struct t_config_option *config_look_save_config_with_fsync;
struct t_config_option *config_look_save_layout_on_exit;
struct t_config_option *config_look_scroll_amount;
struct t_config_option *config_look_scroll_bottom_after_switch;
@@ -272,6 +273,7 @@ struct t_config_option *config_completion_partial_completion_command;
struct t_config_option *config_completion_partial_completion_command_arg;
struct t_config_option *config_completion_partial_completion_count;
struct t_config_option *config_completion_partial_completion_other;
+struct t_config_option *config_completion_partial_completion_templates;
/* config, history section */
@@ -317,6 +319,7 @@ char **config_nick_colors = NULL;
int config_num_nick_colors = 0;
struct t_hashtable *config_hashtable_nick_color_force = NULL;
char *config_item_time_evaluated = NULL;
+struct t_hashtable *config_hashtable_completion_partial_templates = NULL;
/*
@@ -994,9 +997,10 @@ config_get_item_time (char *text_time, int max_length)
date = time (NULL);
local_time = localtime (&date);
- strftime (text_time, max_length,
- config_item_time_evaluated,
- local_time);
+ if (strftime (text_time, max_length,
+ config_item_time_evaluated,
+ local_time) == 0)
+ text_time[0] = '\0';
}
/*
@@ -1173,6 +1177,51 @@ config_change_nick_colors (const void *pointer, void *data,
}
/*
+ * Callback for changes on option
+ * "weechat.completion.partial_completion_templates".
+ */
+
+void
+config_change_completion_partial_completion_templates (const void *pointer,
+ void *data,
+ struct t_config_option *option)
+{
+ char **items;
+ int num_items, i;
+
+ /* make C compiler happy */
+ (void) pointer;
+ (void) data;
+ (void) option;
+
+ if (!config_hashtable_completion_partial_templates)
+ {
+ config_hashtable_completion_partial_templates = hashtable_new (
+ 32,
+ WEECHAT_HASHTABLE_STRING,
+ WEECHAT_HASHTABLE_POINTER,
+ NULL, NULL);
+ }
+ else
+ {
+ hashtable_remove_all (config_hashtable_completion_partial_templates);
+ }
+
+ items = string_split (
+ CONFIG_STRING(config_completion_partial_completion_templates),
+ ",", 0, 0, &num_items);
+ if (items)
+ {
+ for (i = 0; i < num_items; i++)
+ {
+ hashtable_set (config_hashtable_completion_partial_templates,
+ items[i], NULL);
+ }
+ string_free_split (items);
+ }
+}
+
+/*
* Callback for changes on option "weechat.network.gnutls_ca_file".
*/
@@ -1281,7 +1330,8 @@ config_day_change_timer_cb (const void *pointer, void *data,
}
/* send signal "day_changed" */
- strftime (str_time, sizeof (str_time), "%Y-%m-%d", local_time);
+ if (strftime (str_time, sizeof (str_time), "%Y-%m-%d", local_time) == 0)
+ str_time[0] = '\0';
(void) hook_signal_send ("day_changed",
WEECHAT_HOOK_SIGNAL_STRING, str_time);
}
@@ -1466,7 +1516,7 @@ config_weechat_debug_create_option_cb (const void *pointer, void *data,
rc = config_file_option_set (ptr_option, value, 1);
else
{
- config_file_option_free (ptr_option);
+ config_file_option_free (ptr_option, 1);
rc = WEECHAT_CONFIG_OPTION_SET_OK_SAME_VALUE;
}
}
@@ -1512,7 +1562,7 @@ config_weechat_debug_delete_option_cb (const void *pointer, void *data,
(void) config_file;
(void) section;
- config_file_option_free (option);
+ config_file_option_free (option, 1);
config_weechat_debug_set_all ();
@@ -1592,7 +1642,7 @@ config_weechat_palette_create_option_cb (const void *pointer, void *data,
rc = config_file_option_set (ptr_option, value, 1);
else
{
- config_file_option_free (ptr_option);
+ config_file_option_free (ptr_option, 1);
rc = WEECHAT_CONFIG_OPTION_SET_OK_SAME_VALUE;
}
}
@@ -1652,7 +1702,7 @@ config_weechat_palette_delete_option_cb (const void *pointer, void *data,
if (error && !error[0])
gui_color_palette_remove (number);
- config_file_option_free (option);
+ config_file_option_free (option, 1);
return WEECHAT_CONFIG_OPTION_UNSET_OK_REMOVED;
}
@@ -2088,7 +2138,7 @@ config_weechat_notify_create_option_cb (const void *pointer, void *data,
rc = config_file_option_set (ptr_option, value, 1);
else
{
- config_file_option_free (ptr_option);
+ config_file_option_free (ptr_option, 1);
rc = WEECHAT_CONFIG_OPTION_SET_OK_SAME_VALUE;
}
}
@@ -2134,7 +2184,7 @@ config_weechat_notify_delete_option_cb (const void *pointer, void *data,
(void) config_file;
(void) section;
- config_file_option_free (option);
+ config_file_option_free (option, 1);
gui_buffer_notify_set_all ();
@@ -2376,6 +2426,7 @@ config_weechat_init_options ()
if (!ptr_section)
{
config_file_free (weechat_config_file);
+ weechat_config_file = NULL;
return 0;
}
@@ -2392,6 +2443,7 @@ config_weechat_init_options ()
if (!ptr_section)
{
config_file_free (weechat_config_file);
+ weechat_config_file = NULL;
return 0;
}
@@ -2446,6 +2498,7 @@ config_weechat_init_options ()
if (!ptr_section)
{
config_file_free (weechat_config_file);
+ weechat_config_file = NULL;
return 0;
}
@@ -2831,8 +2884,10 @@ config_weechat_init_options ()
config_look_hotlist_count_max = config_file_new_option (
weechat_config_file, ptr_section,
"hotlist_count_max", "integer",
- N_("max number of messages count to display in hotlist for a buffer "
- "(0 = never display messages count)"),
+ N_("max number of messages count to display in hotlist for a buffer: "
+ "0 = never display messages count, "
+ "other number = display max N messages count (from the highest to "
+ "lowest priority)"),
NULL, 0, GUI_HOTLIST_NUM_PRIORITIES, "2", NULL, 0,
NULL, NULL, NULL,
&config_change_buffer_content, NULL, NULL,
@@ -3139,7 +3194,9 @@ config_weechat_init_options ()
weechat_config_file, ptr_section,
"paste_max_lines", "integer",
N_("max number of lines for paste without asking user "
- "(-1 = disable this feature)"),
+ "(-1 = disable this feature); this option is used only if the bar "
+ "item \"input_paste\" is used in at least one bar (by default it "
+ "is used in \"input\" bar)"),
NULL, -1, INT_MAX, "1", NULL, 0,
NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL);
config_look_prefix[GUI_CHAT_PREFIX_ERROR] = config_file_new_option (
@@ -3343,6 +3400,17 @@ config_weechat_init_options ()
NULL, NULL, NULL,
&config_change_save_config_on_exit, NULL, NULL,
NULL, NULL, NULL);
+ config_look_save_config_with_fsync = config_file_new_option (
+ weechat_config_file, ptr_section,
+ "save_config_with_fsync", "boolean",
+ N_("use fsync to synchronize the configuration file with the storage "
+ "device (see man fsync); this is slower but should prevent any "
+ "data loss in case of power failure during the save of "
+ "configuration file"),
+ NULL, 0, 0, "off", NULL, 0,
+ NULL, NULL, NULL,
+ &config_change_save_config_on_exit, NULL, NULL,
+ NULL, NULL, NULL);
config_look_save_layout_on_exit = config_file_new_option (
weechat_config_file, ptr_section,
"save_layout_on_exit", "integer",
@@ -3446,8 +3514,9 @@ config_weechat_init_options ()
"window_title", "string",
N_("title for window (terminal for Curses GUI), set on startup; "
"an empty string will keep title unchanged "
- "(note: content is evaluated, see /help eval)"),
- NULL, 0, 0, "WeeChat ${info:version}", NULL, 0,
+ "(note: content is evaluated, see /help eval); example: "
+ "\"WeeChat ${info:version}\""),
+ NULL, 0, 0, "", NULL, 0,
NULL, NULL, NULL,
&config_change_window_title, NULL, NULL,
NULL, NULL, NULL);
@@ -3496,6 +3565,7 @@ config_weechat_init_options ()
if (!ptr_section)
{
config_file_free (weechat_config_file);
+ weechat_config_file = NULL;
return 0;
}
@@ -3510,6 +3580,7 @@ config_weechat_init_options ()
if (!ptr_section)
{
config_file_free (weechat_config_file);
+ weechat_config_file = NULL;
return 0;
}
@@ -4070,6 +4141,7 @@ config_weechat_init_options ()
if (!ptr_section)
{
config_file_free (weechat_config_file);
+ weechat_config_file = NULL;
return 0;
}
@@ -4133,7 +4205,7 @@ config_weechat_init_options ()
config_completion_partial_completion_alert = config_file_new_option (
weechat_config_file, ptr_section,
"partial_completion_alert", "boolean",
- N_("alert user when a partial completion occurs"),
+ N_("send alert (BEL) when a partial completion occurs"),
NULL, 0, 0, "on", NULL, 0,
NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL);
config_completion_partial_completion_command = config_file_new_option (
@@ -4163,6 +4235,17 @@ config_weechat_init_options ()
"begin with same letters)"),
NULL, 0, 0, "off", NULL, 0,
NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL);
+ config_completion_partial_completion_templates = config_file_new_option (
+ weechat_config_file, ptr_section,
+ "partial_completion_templates", "string",
+ N_("comma-separated list of templates for which partial completion is "
+ "enabled by default (with Tab key instead of shift-Tab); "
+ "the list of templates is in documentation: plugin API reference, "
+ "function \"weechat_hook_command\""),
+ NULL, 0, 0, "config_options", NULL, 0,
+ NULL, NULL, NULL,
+ &config_change_completion_partial_completion_templates, NULL, NULL,
+ NULL, NULL, NULL);
/* history */
ptr_section = config_file_new_section (weechat_config_file, "history",
@@ -4175,6 +4258,7 @@ config_weechat_init_options ()
if (!ptr_section)
{
config_file_free (weechat_config_file);
+ weechat_config_file = NULL;
return 0;
}
@@ -4228,6 +4312,7 @@ config_weechat_init_options ()
if (!ptr_section)
{
config_file_free (weechat_config_file);
+ weechat_config_file = NULL;
return 0;
}
@@ -4244,6 +4329,7 @@ config_weechat_init_options ()
if (!ptr_section)
{
config_file_free (weechat_config_file);
+ weechat_config_file = NULL;
return 0;
}
@@ -4291,6 +4377,7 @@ config_weechat_init_options ()
if (!ptr_section)
{
config_file_free (weechat_config_file);
+ weechat_config_file = NULL;
return 0;
}
@@ -4345,6 +4432,7 @@ config_weechat_init_options ()
if (!ptr_section)
{
config_file_free (weechat_config_file);
+ weechat_config_file = NULL;
return 0;
}
@@ -4362,6 +4450,7 @@ config_weechat_init_options ()
if (!ptr_section)
{
config_file_free (weechat_config_file);
+ weechat_config_file = NULL;
return 0;
}
@@ -4377,6 +4466,7 @@ config_weechat_init_options ()
if (!ptr_section)
{
config_file_free (weechat_config_file);
+ weechat_config_file = NULL;
return 0;
}
@@ -4394,6 +4484,7 @@ config_weechat_init_options ()
if (!ptr_section)
{
config_file_free (weechat_config_file);
+ weechat_config_file = NULL;
return 0;
}
@@ -4415,6 +4506,7 @@ config_weechat_init_options ()
if (!ptr_section)
{
config_file_free (weechat_config_file);
+ weechat_config_file = NULL;
return 0;
}
}
@@ -4472,6 +4564,8 @@ config_weechat_init ()
config_change_word_chars_highlight (NULL, NULL, NULL);
if (!config_word_chars_input)
config_change_word_chars_input (NULL, NULL, NULL);
+ if (!config_hashtable_completion_partial_templates)
+ config_change_completion_partial_completion_templates (NULL, NULL, NULL);
return rc;
}
@@ -4580,4 +4674,10 @@ config_weechat_free ()
free (config_item_time_evaluated);
config_item_time_evaluated = NULL;
}
+
+ if (config_hashtable_completion_partial_templates)
+ {
+ hashtable_free (config_hashtable_completion_partial_templates);
+ config_hashtable_completion_partial_templates = NULL;
+ }
}