Commit 0bb6c023 authored by Benno Schulenberg's avatar Benno Schulenberg
Browse files

tweaks: condense the conditional compilation of shortcut reassignments

These three functions are needed only when both linter and speller
are available.
No related merge requests found
Showing with 11 additions and 17 deletions
+11 -17
......@@ -379,16 +379,6 @@ void add_to_sclist(int menus, const char *scstring, const int keycode,
#endif
}
/* Assign one function's shortcuts to another function. */
void replace_scs_for(void (*oldfunc)(void), void (*newfunc)(void))
{
sc *s;
for (s = sclist; s != NULL; s = s->next)
if (s->scfunc == oldfunc)
s->scfunc = newfunc;
}
/* Return the first shortcut in the list of shortcuts that
* matches the given func in the given menu. */
const sc *first_sc_for(int menu, void (*func)(void))
......@@ -1363,10 +1353,17 @@ void shortcut_init(void)
#endif
}
#ifdef ENABLE_COLOR
#if defined(ENABLE_COLOR) && defined(ENABLE_SPELLER)
/* Assign one function's shortcuts to another function. */
void replace_scs_for(void (*oldfunc)(void), void (*newfunc)(void))
{
for (sc *s = sclist; s != NULL; s = s->next)
if (s->scfunc == oldfunc)
s->scfunc = newfunc;
}
void set_lint_or_format_shortcuts(void)
{
#ifdef ENABLE_SPELLER
if (openfile->syntax->formatter) {
replace_scs_for(do_spell, do_formatter);
replace_scs_for(do_linter, do_formatter);
......@@ -1374,17 +1371,14 @@ void set_lint_or_format_shortcuts(void)
replace_scs_for(do_spell, do_linter);
replace_scs_for(do_formatter, do_linter);
}
#endif
}
void set_spell_shortcuts(void)
{
#ifdef ENABLE_SPELLER
replace_scs_for(do_formatter, do_spell);
replace_scs_for(do_linter, do_spell);
#endif
}
#endif /* ENABLE_COLOR */
#endif /* ENABLE_COLOR && ENABLE_SPELLER */
const subnfunc *sctofunc(const sc *s)
{
......
......@@ -3339,7 +3339,7 @@ void total_refresh(void)
* portion of the window. */
void display_main_list(void)
{
#ifdef ENABLE_COLOR
#if defined(ENABLE_COLOR) && defined(ENABLE_SPELLER)
if (openfile->syntax &&
(openfile->syntax->formatter || openfile->syntax->linter))
set_lint_or_format_shortcuts();
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment