build: add options --disable-formatter and --disable-linter to configure

This makes more sense than letting the formatter and the linter depend
on ENABLE_COLOR (which maybe should have been named ENABLE_SYNTAX).

This fulfills https://savannah.gnu.org/bugs/?50080.
This commit is contained in:
Benno Schulenberg 2022-08-28 16:31:04 +02:00
parent 4f9abb52a4
commit 6243831dfb
6 changed files with 90 additions and 16 deletions

View File

@ -153,6 +153,30 @@ if test "x$enable_extra" != xno; then
AC_DEFINE(ENABLE_EXTRA, 1, [Define this to have an Easter egg.]) AC_DEFINE(ENABLE_EXTRA, 1, [Define this to have an Easter egg.])
fi fi
AC_ARG_ENABLE(formatter,
AS_HELP_STRING([--disable-formatter], [Disable the formatting tool]))
if test "x$enable_tiny" = xyes; then
if test "x$enable_formatter" = xyes; then
if test "x$enable_color" != xyes; then
AC_MSG_ERROR([
*** --enable-formatter needs both --enable-color and --enable-nanorc to work])
fi
else
enable_formatter=no
fi
fi
if test "x$enable_color" = xno; then
if test "x$enable_formatter" = xyes; then
AC_MSG_ERROR([
*** --enable-formatter cannot work with --disable-color nor --disable-nanorc])
else
enable_formatter=no
fi
fi
if test "x$enable_formatter" != xno; then
AC_DEFINE(ENABLE_FORMATTER, 1, [Define this to have access to a formatter.])
fi
AC_ARG_ENABLE(help, AC_ARG_ENABLE(help,
AS_HELP_STRING([--disable-help], [Disable the built-in help texts])) AS_HELP_STRING([--disable-help], [Disable the built-in help texts]))
if test "x$enable_tiny" = xyes; then if test "x$enable_tiny" = xyes; then
@ -206,7 +230,7 @@ if test "x$enable_libmagic" = xyes; then
if test "x$enable_tiny" = xyes; then if test "x$enable_tiny" = xyes; then
if test "x$enable_color" != xyes; then if test "x$enable_color" != xyes; then
AC_MSG_ERROR([ AC_MSG_ERROR([
*** --enable-libmagic needs --enable-color and --enable-nanorc to work]) *** --enable-libmagic needs both --enable-color and --enable-nanorc to work])
fi fi
fi fi
if test "x$enable_color" = xno; then if test "x$enable_color" = xno; then
@ -215,6 +239,30 @@ if test "x$enable_libmagic" = xyes; then
fi fi
fi fi
AC_ARG_ENABLE(linter,
AS_HELP_STRING([--disable-linter], [Disable the linting tool]))
if test "x$enable_tiny" = xyes; then
if test "x$enable_linter" = xyes; then
if test "x$enable_color" != xyes; then
AC_MSG_ERROR([
*** --enable-linter needs both --enable-color and --enable-nanorc to work])
fi
else
enable_linter=no
fi
fi
if test "x$enable_color" = xno; then
if test "x$enable_linter" = xyes; then
AC_MSG_ERROR([
*** --enable-linter cannot work with --disable-color nor --disable-nanorc])
else
enable_linter=no
fi
fi
if test "x$enable_linter" != xno; then
AC_DEFINE(ENABLE_LINTER, 1, [Define this to have access to a linter.])
fi
AC_ARG_ENABLE(linenumbers, AC_ARG_ENABLE(linenumbers,
AS_HELP_STRING([--disable-linenumbers], [Disable line numbering])) AS_HELP_STRING([--disable-linenumbers], [Disable line numbering]))
if test "x$enable_tiny" = xyes; then if test "x$enable_tiny" = xyes; then
@ -272,14 +320,14 @@ if test "x$enable_operatingdir" != xno; then
fi fi
AC_ARG_ENABLE(speller, AC_ARG_ENABLE(speller,
AS_HELP_STRING([--disable-speller], [Disable the spell-checker functions])) AS_HELP_STRING([--disable-speller], [Disable the spell-checking tool]))
if test "x$enable_tiny" = xyes; then if test "x$enable_tiny" = xyes; then
if test "x$enable_speller" != xyes; then if test "x$enable_speller" != xyes; then
enable_speller=no enable_speller=no
fi fi
fi fi
if test "x$enable_speller" != xno; then if test "x$enable_speller" != xno; then
AC_DEFINE(ENABLE_SPELLER, 1, [Define this to have the spell-checker functions.]) AC_DEFINE(ENABLE_SPELLER, 1, [Define this to have access to a spell checker.])
fi fi
AC_ARG_ENABLE(tabcomp, AC_ARG_ENABLE(tabcomp,

View File

@ -689,10 +689,12 @@ void shortcut_init(void)
const char *browserrefresh_gist = N_("Refresh the file list"); const char *browserrefresh_gist = N_("Refresh the file list");
const char *gotodir_gist = N_("Go to directory"); const char *gotodir_gist = N_("Go to directory");
#endif #endif
#ifdef ENABLE_COLOR #ifdef ENABLE_LINTER
const char *lint_gist = N_("Invoke the linter, if available"); const char *lint_gist = N_("Invoke the linter, if available");
const char *prevlint_gist = N_("Go to previous linter msg"); const char *prevlint_gist = N_("Go to previous linter msg");
const char *nextlint_gist = N_("Go to next linter msg"); const char *nextlint_gist = N_("Go to next linter msg");
#endif
#ifdef ENABLE_FORMATTER
const char *formatter_gist = const char *formatter_gist =
N_("Invoke a program to format/arrange/manipulate the buffer"); N_("Invoke a program to format/arrange/manipulate the buffer");
#endif #endif
@ -1013,9 +1015,11 @@ void shortcut_init(void)
add_to_funcs(do_spell, MMAIN, add_to_funcs(do_spell, MMAIN,
N_("Spell Check"), WHENHELP(spell_gist), TOGETHER); N_("Spell Check"), WHENHELP(spell_gist), TOGETHER);
#endif #endif
#ifdef ENABLE_COLOR #ifdef ENABLE_LINTER
add_to_funcs(do_linter, MMAIN, add_to_funcs(do_linter, MMAIN,
N_("Linter"), WHENHELP(lint_gist), TOGETHER); N_("Linter"), WHENHELP(lint_gist), TOGETHER);
#endif
#ifdef ENABLE_FORMATTER
add_to_funcs(do_formatter, MMAIN, add_to_funcs(do_formatter, MMAIN,
N_("Formatter"), WHENHELP(formatter_gist), BLANKAFTER); N_("Formatter"), WHENHELP(formatter_gist), BLANKAFTER);
#endif #endif
@ -1055,7 +1059,7 @@ void shortcut_init(void)
add_to_funcs(do_spell, MEXECUTE, add_to_funcs(do_spell, MEXECUTE,
N_("Spell Check"), WHENHELP(spell_gist), TOGETHER); N_("Spell Check"), WHENHELP(spell_gist), TOGETHER);
#endif #endif
#ifdef ENABLE_COLOR #ifdef ENABLE_LINTER
add_to_funcs(do_linter, MEXECUTE, add_to_funcs(do_linter, MEXECUTE,
N_("Linter"), WHENHELP(lint_gist), BLANKAFTER); N_("Linter"), WHENHELP(lint_gist), BLANKAFTER);
#endif #endif
@ -1063,7 +1067,7 @@ void shortcut_init(void)
add_to_funcs(do_full_justify, MEXECUTE, add_to_funcs(do_full_justify, MEXECUTE,
N_("Full Justify"), WHENHELP(fulljustify_gist), TOGETHER); N_("Full Justify"), WHENHELP(fulljustify_gist), TOGETHER);
#endif #endif
#ifdef ENABLE_COLOR #ifdef ENABLE_FORMATTER
add_to_funcs(do_formatter, MEXECUTE, add_to_funcs(do_formatter, MEXECUTE,
N_("Formatter"), WHENHELP(formatter_gist), BLANKAFTER); N_("Formatter"), WHENHELP(formatter_gist), BLANKAFTER);
#endif #endif
@ -1143,7 +1147,7 @@ void shortcut_init(void)
add_to_funcs(discard_buffer, MWRITEFILE, add_to_funcs(discard_buffer, MWRITEFILE,
N_("Discard buffer"), WHENHELP(discardbuffer_gist), BLANKAFTER); N_("Discard buffer"), WHENHELP(discardbuffer_gist), BLANKAFTER);
#ifdef ENABLE_COLOR #ifdef ENABLE_LINTER
add_to_funcs(do_page_up, MLINTER, add_to_funcs(do_page_up, MLINTER,
/* TRANSLATORS: The next two strings may be up to 37 characters each. */ /* TRANSLATORS: The next two strings may be up to 37 characters each. */
N_("Previous Linter message"), WHENHELP(prevlint_gist), TOGETHER); N_("Previous Linter message"), WHENHELP(prevlint_gist), TOGETHER);
@ -1197,9 +1201,11 @@ void shortcut_init(void)
#ifdef ENABLE_JUSTIFY #ifdef ENABLE_JUSTIFY
add_to_sclist(MMAIN, "^J", '\n', do_justify, 0); add_to_sclist(MMAIN, "^J", '\n', do_justify, 0);
#endif #endif
#ifdef ENABLE_COLOR #ifdef ENABLE_LINTER
add_to_sclist(MMAIN, "M-B", 0, do_linter, 0); add_to_sclist(MMAIN, "M-B", 0, do_linter, 0);
add_to_sclist(MEXECUTE, "^Y", 0, do_linter, 0); add_to_sclist(MEXECUTE, "^Y", 0, do_linter, 0);
#endif
#ifdef ENABLE_FORMATTER
add_to_sclist(MMAIN, "M-F", 0, do_formatter, 0); add_to_sclist(MMAIN, "M-F", 0, do_formatter, 0);
add_to_sclist(MEXECUTE, "^O", 0, do_formatter, 0); add_to_sclist(MEXECUTE, "^O", 0, do_formatter, 0);
#endif #endif

View File

@ -688,6 +688,9 @@ void version(void)
#ifdef ENABLE_EXTRA #ifdef ENABLE_EXTRA
printf(" --enable-extra"); printf(" --enable-extra");
#endif #endif
#ifdef ENABLE_FORMATTER
printf(" --enable-formatter");
#endif
#ifdef ENABLE_HELP #ifdef ENABLE_HELP
printf(" --enable-help"); printf(" --enable-help");
#endif #endif
@ -703,6 +706,9 @@ void version(void)
#ifdef ENABLE_LINENUMBERS #ifdef ENABLE_LINENUMBERS
printf(" --enable-linenumbers"); printf(" --enable-linenumbers");
#endif #endif
#ifdef ENABLE_LINTER
printf(" --enable-linter");
#endif
#ifdef ENABLE_MOUSE #ifdef ENABLE_MOUSE
printf(" --enable-mouse"); printf(" --enable-mouse");
#endif #endif
@ -737,6 +743,9 @@ void version(void)
#ifndef ENABLE_EXTRA #ifndef ENABLE_EXTRA
printf(" --disable-extra"); printf(" --disable-extra");
#endif #endif
#ifndef ENABLE_FORMATTER
printf(" --disable-formatter");
#endif
#ifndef ENABLE_HELP #ifndef ENABLE_HELP
printf(" --disable-help"); printf(" --disable-help");
#endif #endif
@ -752,6 +761,9 @@ void version(void)
#ifndef ENABLE_LINENUMBERS #ifndef ENABLE_LINENUMBERS
printf(" --disable-linenumbers"); printf(" --disable-linenumbers");
#endif #endif
#ifndef ENABLE_LINTER
printf(" --disable-linter");
#endif
#ifndef ENABLE_MOUSE #ifndef ENABLE_MOUSE
printf(" --disable-mouse"); printf(" --disable-mouse");
#endif #endif
@ -1392,7 +1404,7 @@ bool changes_something(const void *f)
#ifdef ENABLE_SPELLER #ifdef ENABLE_SPELLER
f == do_spell || f == do_spell ||
#endif #endif
#ifdef ENABLE_COLOR #ifdef ENABLE_FORMATTER
f == do_formatter || f == do_formatter ||
#endif #endif
#ifdef ENABLE_WORDCOMPLETION #ifdef ENABLE_WORDCOMPLETION

View File

@ -520,8 +520,10 @@ void do_full_justify(void);
#ifdef ENABLE_SPELLER #ifdef ENABLE_SPELLER
void do_spell(void); void do_spell(void);
#endif #endif
#ifdef ENABLE_COLOR #ifdef ENABLE_LINTER
void do_linter(void); void do_linter(void);
#endif
#ifdef ENABLE_FORMATTER
void do_formatter(void); void do_formatter(void);
#endif #endif
#ifndef NANO_TINY #ifndef NANO_TINY

View File

@ -276,9 +276,11 @@ keystruct *strtosc(const char *input)
!strcmp(input, "speller")) !strcmp(input, "speller"))
s->func = do_spell; s->func = do_spell;
#endif #endif
#ifdef ENABLE_COLOR #ifdef ENABLE_LINTER
else if (!strcmp(input, "linter")) else if (!strcmp(input, "linter"))
s->func = do_linter; s->func = do_linter;
#endif
#ifdef ENABLE_FORMATTER
else if (!strcmp(input, "formatter")) else if (!strcmp(input, "formatter"))
s->func = do_formatter; s->func = do_formatter;
#endif #endif

View File

@ -2024,7 +2024,7 @@ void do_full_justify(void)
} }
#endif /* ENABLE_JUSTIFY */ #endif /* ENABLE_JUSTIFY */
#if defined(ENABLE_SPELLER) || defined (ENABLE_COLOR) #if defined(ENABLE_SPELLER) || defined (ENABLE_LINTER) || defined (ENABLE_FORMATTER)
/* Set up an argument list for executing the given command. */ /* Set up an argument list for executing the given command. */
void construct_argument_list(char ***arguments, char *command, char *filename) void construct_argument_list(char ***arguments, char *command, char *filename)
{ {
@ -2041,7 +2041,9 @@ void construct_argument_list(char ***arguments, char *command, char *filename)
(*arguments)[count - 2] = filename; (*arguments)[count - 2] = filename;
(*arguments)[count - 1] = NULL; (*arguments)[count - 1] = NULL;
} }
#endif
#if defined(ENABLE_SPELLER) || defined (ENABLE_FORMATTER)
/* Open the specified file, and if that succeeds, remove the text of the marked /* Open the specified file, and if that succeeds, remove the text of the marked
* region or of the entire buffer and read the file contents into its place. */ * region or of the entire buffer and read the file contents into its place. */
bool replace_buffer(const char *filename, undo_type action, const char *operation) bool replace_buffer(const char *filename, undo_type action, const char *operation)
@ -2219,7 +2221,7 @@ void treat(char *tempfile_name, char *theprogram, bool spelling)
statusline(REMARK, _("Buffer has been processed")); statusline(REMARK, _("Buffer has been processed"));
#endif #endif
} }
#endif /* ENABLE_SPELLER || ENABLE_COLOR */ #endif /* ENABLE_SPELLER || ENABLE_FORMATTER */
#ifdef ENABLE_SPELLER #ifdef ENABLE_SPELLER
/* Let the user edit the misspelled word. Return FALSE if the user cancels. */ /* Let the user edit the misspelled word. Return FALSE if the user cancels. */
@ -2564,7 +2566,7 @@ void do_spell(void)
} }
#endif /* ENABLE_SPELLER */ #endif /* ENABLE_SPELLER */
#ifdef ENABLE_COLOR #ifdef ENABLE_LINTER
/* Run a linting program on the current buffer. */ /* Run a linting program on the current buffer. */
void do_linter(void) void do_linter(void)
{ {
@ -2910,7 +2912,9 @@ void do_linter(void)
titlebar(NULL); titlebar(NULL);
#endif #endif
} }
#endif /* ENABLE_LINTER */
#ifdef ENABLE_FORMATTER
/* Run a manipulation program on the contents of the buffer. */ /* Run a manipulation program on the contents of the buffer. */
void do_formatter(void) void do_formatter(void)
{ {
@ -2945,7 +2949,7 @@ void do_formatter(void)
unlink(temp_name); unlink(temp_name);
free(temp_name); free(temp_name);
} }
#endif /* ENABLE_COLOR */ #endif /* ENABLE_FORMATTER */
#ifndef NANO_TINY #ifndef NANO_TINY
/* Our own version of "wc". Note that the character count is in /* Our own version of "wc". Note that the character count is in