mirror of
https://github.com/weechat/weechat.git
synced 2026-06-29 22:36:38 +02:00
spell: allow special dict value "-" to disable spell checking on a specific buffer (closes #1699)
This commit is contained in:
@@ -216,6 +216,7 @@ void
|
||||
spell_command_set_dict (struct t_gui_buffer *buffer, const char *value)
|
||||
{
|
||||
char *name;
|
||||
int disabled;
|
||||
|
||||
name = spell_build_option_name (buffer);
|
||||
if (!name)
|
||||
@@ -224,8 +225,16 @@ spell_command_set_dict (struct t_gui_buffer *buffer, const char *value)
|
||||
if (spell_config_set_dict (name, value) > 0)
|
||||
{
|
||||
if (value && value[0])
|
||||
weechat_printf (NULL, "%s: \"%s\" => %s",
|
||||
SPELL_PLUGIN_NAME, name, value);
|
||||
{
|
||||
disabled = (strcmp (value, "-") == 0);
|
||||
weechat_printf (NULL, "%s: \"%s\" => %s%s%s%s",
|
||||
SPELL_PLUGIN_NAME,
|
||||
name,
|
||||
value,
|
||||
(disabled) ? " (" : "",
|
||||
(disabled) ? _("spell checking disabled") : "",
|
||||
(disabled) ? ")" : "");
|
||||
}
|
||||
else
|
||||
weechat_printf (NULL, _("%s: \"%s\" removed"),
|
||||
SPELL_PLUGIN_NAME, name);
|
||||
@@ -472,7 +481,7 @@ spell_command_init ()
|
||||
N_("spell plugin configuration"),
|
||||
N_("enable|disable|toggle"
|
||||
" || listdict"
|
||||
" || setdict <dict>[,<dict>...]"
|
||||
" || setdict -|<dict>[,<dict>...]"
|
||||
" || deldict"
|
||||
" || addword [<dict>] <word>"),
|
||||
N_(" enable: enable spell checker\n"
|
||||
@@ -480,7 +489,8 @@ spell_command_init ()
|
||||
" toggle: toggle spell checker\n"
|
||||
"listdict: show installed dictionaries\n"
|
||||
" setdict: set dictionary for current buffer (multiple dictionaries "
|
||||
"can be separated by a comma)\n"
|
||||
"can be separated by a comma, the special value \"-\" disables "
|
||||
"spell checking on current buffer)\n"
|
||||
" deldict: delete dictionary used on current buffer\n"
|
||||
" addword: add a word in personal dictionary\n"
|
||||
"\n"
|
||||
|
||||
@@ -116,6 +116,9 @@ spell_completion_dicts_cb (const void *pointer, void *data,
|
||||
0, WEECHAT_LIST_POS_SORT);
|
||||
}
|
||||
|
||||
weechat_completion_list_add (completion, "-",
|
||||
0, WEECHAT_LIST_POS_BEGINNING);
|
||||
|
||||
delete_aspell_dict_info_enumeration (elements);
|
||||
delete_aspell_config (config);
|
||||
#endif /* USE_ENCHANT */
|
||||
|
||||
@@ -255,7 +255,9 @@ spell_config_dict_create_option (const void *pointer, void *data,
|
||||
ptr_option = weechat_config_new_option (
|
||||
config_file, section,
|
||||
option_name, "string",
|
||||
_("comma separated list of dictionaries to use on this buffer"),
|
||||
_("comma separated list of dictionaries to use on this "
|
||||
"buffer (special value \"-\" disables spell checking "
|
||||
"on this buffer)"),
|
||||
NULL, 0, 0, "", value, 0,
|
||||
NULL, NULL, NULL,
|
||||
&spell_config_dict_change, NULL, NULL,
|
||||
|
||||
@@ -97,6 +97,13 @@ spell_speller_check_dictionaries (const char *dict_list)
|
||||
char **argv;
|
||||
int argc, i;
|
||||
|
||||
if (!dict_list)
|
||||
return;
|
||||
|
||||
/* special value "-" is used to disable spell checking on a buffer */
|
||||
if (strcmp (dict_list, "-") == 0)
|
||||
return;
|
||||
|
||||
if (dict_list)
|
||||
{
|
||||
argv = weechat_string_split (dict_list, ",", NULL,
|
||||
@@ -381,7 +388,7 @@ spell_speller_buffer_new (struct t_gui_buffer *buffer)
|
||||
new_speller_buffer->modifier_result = NULL;
|
||||
|
||||
buffer_dicts = spell_get_dict (buffer);
|
||||
if (buffer_dicts)
|
||||
if (buffer_dicts && (strcmp (buffer_dicts, "-") != 0))
|
||||
{
|
||||
dicts = weechat_string_split (buffer_dicts, ",", NULL,
|
||||
WEECHAT_STRING_SPLIT_STRIP_LEFT
|
||||
|
||||
Reference in New Issue
Block a user