Skip to content

Commit

Permalink
Ticket #2914 (disable annoying aspell warnings about spelling language)
Browse files Browse the repository at this point in the history
    Added the aspell param 'spell_language' in ini-file.
    This allow set spelling language. spell_language=NONE - disable aspell support.

Signed-off-by: Ilia Maslakov <[email protected]>
  • Loading branch information
ilia-maslakov committed Dec 24, 2012
1 parent 9f797a4 commit 4861d06
Show file tree
Hide file tree
Showing 4 changed files with 49 additions and 8 deletions.
19 changes: 11 additions & 8 deletions src/editor/editmenu.c
Original file line number Diff line number Diff line change
Expand Up @@ -176,14 +176,17 @@ create_command_menu (void)
menu_entry_create (_("Record/Repeat &actions"), CK_RepeatStartStopRecord));
entries = g_list_prepend (entries, menu_separator_create ());
#ifdef HAVE_ASPELL
entries = g_list_prepend (entries, menu_entry_create (_("S&pell check"), CK_SpellCheck));
entries =
g_list_prepend (entries, menu_entry_create (_("C&heck word"), CK_SpellCheckCurrentWord));
entries =
g_list_prepend (entries,
menu_entry_create (_("Change spelling &language..."),
CK_SpellCheckSelectLang));
entries = g_list_prepend (entries, menu_separator_create ());
if (strcmp (spell_language, "NONE") != 0)
{
entries = g_list_prepend (entries, menu_entry_create (_("S&pell check"), CK_SpellCheck));
entries =
g_list_prepend (entries, menu_entry_create (_("C&heck word"), CK_SpellCheckCurrentWord));
entries =
g_list_prepend (entries,
menu_entry_create (_("Change spelling &language..."),
CK_SpellCheckSelectLang));
entries = g_list_prepend (entries, menu_separator_create ());
}
#endif /* HAVE_ASPELL */
entries = g_list_prepend (entries, menu_entry_create (_("&Mail..."), CK_Mail));

Expand Down
15 changes: 15 additions & 0 deletions src/editor/spell.c
Original file line number Diff line number Diff line change
Expand Up @@ -35,6 +35,8 @@
#endif
#include "lib/strutil.h"

#include "src/setup.h"

#include "edit-impl.h"
#include "spell.h"

Expand Down Expand Up @@ -284,6 +286,9 @@ aspell_init (void)
{
AspellCanHaveError *error = NULL;

if (strcmp (spell_language, "NONE") == 0)
return;

if (global_speller != NULL)
return;

Expand All @@ -301,6 +306,13 @@ aspell_init (void)
global_speller->config = mc_new_aspell_config ();
global_speller->speller = NULL;

if (spell_language != NULL)
{
int res;

res = mc_aspell_config_replace (global_speller->config, "lang", spell_language);
}

error = mc_new_aspell_speller (global_speller->config);

if (mc_aspell_error_number (error) == 0)
Expand Down Expand Up @@ -435,6 +447,9 @@ aspell_set_lang (const char *lang)
AspellCanHaveError *error;
const char *spell_codeset;

g_free (spell_language);
spell_language = g_strdup (lang);

#ifdef HAVE_CHARSET
if (mc_global.source_codepage > 0)
spell_codeset = get_codepage_id (mc_global.source_codepage);
Expand Down
19 changes: 19 additions & 0 deletions src/setup.c
Original file line number Diff line number Diff line change
Expand Up @@ -187,6 +187,10 @@ char *autodetect_codeset = NULL;
gboolean is_autodetect_codeset_enabled = FALSE;
#endif /* !HAVE_CHARSET */

#ifdef HAVE_ASPELL
char *spell_language = NULL;
#endif

/* If set, then print to the given file the last directory we were at */
char *last_wd_string = NULL;

Expand Down Expand Up @@ -1049,6 +1053,11 @@ load_setup (void)
mc_global.utf8_display = str_isutf8 (buffer);
#endif /* HAVE_CHARSET */

#ifdef HAVE_ASPELL
spell_language =
mc_config_get_string (mc_main_config, CONFIG_MISC_SECTION, "spell_language", "en");
#endif /* HAVE_ASPELL */

clipboard_store_path =
mc_config_get_string (mc_main_config, CONFIG_MISC_SECTION, "clipboard_store", "");
clipboard_paste_path =
Expand Down Expand Up @@ -1095,6 +1104,12 @@ save_setup (gboolean save_options, gboolean save_panel_options)
mc_config_set_string (mc_main_config, CONFIG_MISC_SECTION, "autodetect_codeset",
autodetect_codeset);
#endif /* HAVE_CHARSET */

#ifdef HAVE_ASPELL
mc_config_set_string (mc_main_config, CONFIG_MISC_SECTION, "spell_language",
spell_language);
#endif /* HAVE_ASPELL */

mc_config_set_string (mc_main_config, CONFIG_MISC_SECTION, "clipboard_store",
clipboard_store_path);
mc_config_set_string (mc_main_config, CONFIG_MISC_SECTION, "clipboard_paste",
Expand Down Expand Up @@ -1142,6 +1157,10 @@ done_setup (void)
g_free (autodetect_codeset);
free_codepages_list ();
#endif

#ifdef HAVE_ASPELL
g_free (spell_language);
#endif /* HAVE_ASPELL */
}

/* --------------------------------------------------------------------------------------------- */
Expand Down
4 changes: 4 additions & 0 deletions src/setup.h
Original file line number Diff line number Diff line change
Expand Up @@ -113,6 +113,10 @@ extern char *autodetect_codeset;
extern gboolean is_autodetect_codeset_enabled;
#endif /* !HAVE_CHARSET */

#ifdef HAVE_ASPELL
extern char *spell_language;
#endif

/* If set, then print to the given file the last directory we were at */
extern char *last_wd_string;

Expand Down

0 comments on commit 4861d06

Please sign in to comment.