From 0bb6c0234fa369df3eab8362783de99b5f18ab56 Mon Sep 17 00:00:00 2001 From: Benno Schulenberg Date: Tue, 9 Jan 2018 12:38:12 +0100 Subject: [PATCH] tweaks: condense the conditional compilation of shortcut reassignments These three functions are needed only when both linter and speller are available. --- src/global.c | 26 ++++++++++---------------- src/winio.c | 2 +- 2 files changed, 11 insertions(+), 17 deletions(-) diff --git a/src/global.c b/src/global.c index 8417aa59..ff74a4fb 100644 --- a/src/global.c +++ b/src/global.c @@ -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) { diff --git a/src/winio.c b/src/winio.c index 6fdd17f0..35e68ce9 100644 --- a/src/winio.c +++ b/src/winio.c @@ -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();