nano

nano with my custom patches
git clone git://bsandro.tech/nano
Log | Files | Refs | README | LICENSE

commit 6243831dfbcb87e4de200e70a2b7b95a86948035
parent 4f9abb52a46a30cee505ab8521653bf7172fc4d3
Author: Benno Schulenberg <bensberg@telfort.nl>
Date:   Sun, 28 Aug 2022 16:31:04 +0200

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.

Diffstat:
Mconfigure.ac | 54+++++++++++++++++++++++++++++++++++++++++++++++++++---
Msrc/global.c | 18++++++++++++------
Msrc/nano.c | 14+++++++++++++-
Msrc/prototypes.h | 4+++-
Msrc/rcfile.c | 4+++-
Msrc/text.c | 12++++++++----
6 files changed, 90 insertions(+), 16 deletions(-)

diff --git a/configure.ac b/configure.ac @@ -153,6 +153,30 @@ if test "x$enable_extra" != xno; then AC_DEFINE(ENABLE_EXTRA, 1, [Define this to have an Easter egg.]) 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, AS_HELP_STRING([--disable-help], [Disable the built-in help texts])) 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_color" != xyes; then 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 if test "x$enable_color" = xno; then @@ -215,6 +239,30 @@ if test "x$enable_libmagic" = xyes; then 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, AS_HELP_STRING([--disable-linenumbers], [Disable line numbering])) if test "x$enable_tiny" = xyes; then @@ -272,14 +320,14 @@ if test "x$enable_operatingdir" != xno; then fi 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_speller" != xyes; then enable_speller=no fi fi 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 AC_ARG_ENABLE(tabcomp, diff --git a/src/global.c b/src/global.c @@ -689,10 +689,12 @@ void shortcut_init(void) const char *browserrefresh_gist = N_("Refresh the file list"); const char *gotodir_gist = N_("Go to directory"); #endif -#ifdef ENABLE_COLOR +#ifdef ENABLE_LINTER const char *lint_gist = N_("Invoke the linter, if available"); const char *prevlint_gist = N_("Go to previous linter msg"); const char *nextlint_gist = N_("Go to next linter msg"); +#endif +#ifdef ENABLE_FORMATTER const char *formatter_gist = N_("Invoke a program to format/arrange/manipulate the buffer"); #endif @@ -1013,9 +1015,11 @@ void shortcut_init(void) add_to_funcs(do_spell, MMAIN, N_("Spell Check"), WHENHELP(spell_gist), TOGETHER); #endif -#ifdef ENABLE_COLOR +#ifdef ENABLE_LINTER add_to_funcs(do_linter, MMAIN, N_("Linter"), WHENHELP(lint_gist), TOGETHER); +#endif +#ifdef ENABLE_FORMATTER add_to_funcs(do_formatter, MMAIN, N_("Formatter"), WHENHELP(formatter_gist), BLANKAFTER); #endif @@ -1055,7 +1059,7 @@ void shortcut_init(void) add_to_funcs(do_spell, MEXECUTE, N_("Spell Check"), WHENHELP(spell_gist), TOGETHER); #endif -#ifdef ENABLE_COLOR +#ifdef ENABLE_LINTER add_to_funcs(do_linter, MEXECUTE, N_("Linter"), WHENHELP(lint_gist), BLANKAFTER); #endif @@ -1063,7 +1067,7 @@ void shortcut_init(void) add_to_funcs(do_full_justify, MEXECUTE, N_("Full Justify"), WHENHELP(fulljustify_gist), TOGETHER); #endif -#ifdef ENABLE_COLOR +#ifdef ENABLE_FORMATTER add_to_funcs(do_formatter, MEXECUTE, N_("Formatter"), WHENHELP(formatter_gist), BLANKAFTER); #endif @@ -1143,7 +1147,7 @@ void shortcut_init(void) add_to_funcs(discard_buffer, MWRITEFILE, N_("Discard buffer"), WHENHELP(discardbuffer_gist), BLANKAFTER); -#ifdef ENABLE_COLOR +#ifdef ENABLE_LINTER add_to_funcs(do_page_up, MLINTER, /* TRANSLATORS: The next two strings may be up to 37 characters each. */ N_("Previous Linter message"), WHENHELP(prevlint_gist), TOGETHER); @@ -1197,9 +1201,11 @@ void shortcut_init(void) #ifdef ENABLE_JUSTIFY add_to_sclist(MMAIN, "^J", '\n', do_justify, 0); #endif -#ifdef ENABLE_COLOR +#ifdef ENABLE_LINTER add_to_sclist(MMAIN, "M-B", 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(MEXECUTE, "^O", 0, do_formatter, 0); #endif diff --git a/src/nano.c b/src/nano.c @@ -688,6 +688,9 @@ void version(void) #ifdef ENABLE_EXTRA printf(" --enable-extra"); #endif +#ifdef ENABLE_FORMATTER + printf(" --enable-formatter"); +#endif #ifdef ENABLE_HELP printf(" --enable-help"); #endif @@ -703,6 +706,9 @@ void version(void) #ifdef ENABLE_LINENUMBERS printf(" --enable-linenumbers"); #endif +#ifdef ENABLE_LINTER + printf(" --enable-linter"); +#endif #ifdef ENABLE_MOUSE printf(" --enable-mouse"); #endif @@ -737,6 +743,9 @@ void version(void) #ifndef ENABLE_EXTRA printf(" --disable-extra"); #endif +#ifndef ENABLE_FORMATTER + printf(" --disable-formatter"); +#endif #ifndef ENABLE_HELP printf(" --disable-help"); #endif @@ -752,6 +761,9 @@ void version(void) #ifndef ENABLE_LINENUMBERS printf(" --disable-linenumbers"); #endif +#ifndef ENABLE_LINTER + printf(" --disable-linter"); +#endif #ifndef ENABLE_MOUSE printf(" --disable-mouse"); #endif @@ -1392,7 +1404,7 @@ bool changes_something(const void *f) #ifdef ENABLE_SPELLER f == do_spell || #endif -#ifdef ENABLE_COLOR +#ifdef ENABLE_FORMATTER f == do_formatter || #endif #ifdef ENABLE_WORDCOMPLETION diff --git a/src/prototypes.h b/src/prototypes.h @@ -520,8 +520,10 @@ void do_full_justify(void); #ifdef ENABLE_SPELLER void do_spell(void); #endif -#ifdef ENABLE_COLOR +#ifdef ENABLE_LINTER void do_linter(void); +#endif +#ifdef ENABLE_FORMATTER void do_formatter(void); #endif #ifndef NANO_TINY diff --git a/src/rcfile.c b/src/rcfile.c @@ -276,9 +276,11 @@ keystruct *strtosc(const char *input) !strcmp(input, "speller")) s->func = do_spell; #endif -#ifdef ENABLE_COLOR +#ifdef ENABLE_LINTER else if (!strcmp(input, "linter")) s->func = do_linter; +#endif +#ifdef ENABLE_FORMATTER else if (!strcmp(input, "formatter")) s->func = do_formatter; #endif diff --git a/src/text.c b/src/text.c @@ -2024,7 +2024,7 @@ void do_full_justify(void) } #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. */ 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 - 1] = NULL; } +#endif +#if defined(ENABLE_SPELLER) || defined (ENABLE_FORMATTER) /* 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. */ 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")); #endif } -#endif /* ENABLE_SPELLER || ENABLE_COLOR */ +#endif /* ENABLE_SPELLER || ENABLE_FORMATTER */ #ifdef ENABLE_SPELLER /* Let the user edit the misspelled word. Return FALSE if the user cancels. */ @@ -2564,7 +2566,7 @@ void do_spell(void) } #endif /* ENABLE_SPELLER */ -#ifdef ENABLE_COLOR +#ifdef ENABLE_LINTER /* Run a linting program on the current buffer. */ void do_linter(void) { @@ -2910,7 +2912,9 @@ void do_linter(void) titlebar(NULL); #endif } +#endif /* ENABLE_LINTER */ +#ifdef ENABLE_FORMATTER /* Run a manipulation program on the contents of the buffer. */ void do_formatter(void) { @@ -2945,7 +2949,7 @@ void do_formatter(void) unlink(temp_name); free(temp_name); } -#endif /* ENABLE_COLOR */ +#endif /* ENABLE_FORMATTER */ #ifndef NANO_TINY /* Our own version of "wc". Note that the character count is in