build: add configure option --disable-wordcomp to disable word completion

(The variable 'pletion_line' is not conditionalized with this option, as
it would become messy.  The compiler will probably be able to elide it.)

When using --enable-tiny, it is not possible to use --enable-wordcomp,
because the word completion function uses the undo system.
master
Benno Schulenberg 2016-12-07 13:10:40 +01:00
parent dca4ab5d8f
commit 68a0314500
7 changed files with 42 additions and 24 deletions

View File

@ -176,6 +176,21 @@ if test "x$enable_tabcomp" = xno; then
AC_DEFINE(DISABLE_TABCOMP, 1, [Define this to disable the tab completion functions for files and search strings.])
fi
AC_ARG_ENABLE(wordcomp,
AS_HELP_STRING([--disable-wordcomp], [Disable the word completion function]))
if test "x$enable_tiny" = xyes; then
if test "x$enable_wordcomp" = xyes; then
AC_MSG_ERROR([--enable-wordcomp cannot work with --enable-tiny])
else
enable_wordcomp=no
fi
fi
if test "x$disable_wordcomp" != xyes; then
if test "x$enable_wordcomp" != xno; then
AC_DEFINE(ENABLE_WORDCOMPLETION, 1, [Define this to enable the word completion function.])
fi
fi
AC_ARG_ENABLE(wrapping,
AS_HELP_STRING([--disable-wrapping], [Disable all wrapping of text (and -w flag)]))
if test "x$enable_wrapping" = xno; then

View File

@ -1501,18 +1501,21 @@ Disable use of the spell checker. This also eliminates the @code{-s}
command-line option, which allows specifying an alternate spell checker.
@item --disable-tabcomp
Disable the tab completion code when reading or writing files.
Disable tab completion (when nano asks for a filename or a search string).
@item --disable-wordcomp
Disable word completion.
@item --disable-wrapping
Disable all hard-wrapping of overlong lines. This also eliminates the
@code{-w} command-line option, which switches long-line wrapping off.
@item --enable-tiny
This option disables all the above. It also disables some of the larger
internals of the editor, like the marking code and the cut-to-end-of-line
code. It also disables the function toggles. By using the enabling
This option implies all of the above. It also disables some other
internals of the editor, like the marking code, the cut-to-end-of-line
code, and the function toggles. By using the enabling
counterpart of the above options together with @code{--enable-tiny},
specific features can be switched back on.
specific features can be switched back on --- but a few cannot.
@item --enable-debug
Enable support for runtime debug output. This can get pretty messy, so

View File

@ -59,10 +59,8 @@ int last_line_y;
message_type lastmessage = HUSH;
/* Messages of type HUSH should not overwrite type MILD nor ALERT. */
#ifndef NANO_TINY
filestruct *pletion_line = NULL;
/* The line where the last completion was found, if any. */
#endif
int controlleft, controlright, controlup, controldown;
#ifndef NANO_TINY
@ -541,7 +539,6 @@ void shortcut_init(void)
#endif
const char *nano_undo_msg = N_("Undo the last operation");
const char *nano_redo_msg = N_("Redo the last undone operation");
const char *nano_completion_msg = N_("Try and complete the current word");
#endif
const char *nano_back_msg = N_("Go back one character");
const char *nano_forward_msg = N_("Go forward one character");
@ -597,6 +594,9 @@ void shortcut_init(void)
N_("Refresh (redraw) the current screen");
const char *nano_suspend_msg =
N_("Suspend the editor (if suspension is enabled)");
#ifdef ENABLE_WORDCOMPLETION
const char *nano_completion_msg = N_("Try and complete the current word");
#endif
#ifndef NANO_TINY
const char *nano_savefile_msg = N_("Save file without prompting");
const char *nano_findprev_msg = N_("Search next occurrence backward");
@ -819,9 +819,6 @@ void shortcut_init(void)
N_("Undo"), IFSCHELP(nano_undo_msg), TOGETHER, NOVIEW);
add_to_funcs(do_redo, MMAIN,
N_("Redo"), IFSCHELP(nano_redo_msg), BLANKAFTER, NOVIEW);
add_to_funcs(complete_a_word, MMAIN,
N_("Complete"), IFSCHELP(nano_completion_msg), BLANKAFTER, NOVIEW);
#endif /* !NANO_TINY */
add_to_funcs(do_left, MMAIN,
@ -934,6 +931,10 @@ void shortcut_init(void)
add_to_funcs(do_suspend_void, MMAIN,
N_("Suspend"), IFSCHELP(nano_suspend_msg), BLANKAFTER, VIEW);
#ifdef ENABLE_WORDCOMPLETION
add_to_funcs(complete_a_word, MMAIN,
N_("Complete"), IFSCHELP(nano_completion_msg), TOGETHER, NOVIEW);
#endif
#ifdef ENABLE_COMMENT
add_to_funcs(do_comment, MMAIN,
N_("Comment Lines"), IFSCHELP(nano_comment_msg), BLANKAFTER, NOVIEW);
@ -1104,6 +1105,8 @@ void shortcut_init(void)
add_to_sclist(MMAIN, "M-{", 0, do_unindent, 0);
add_to_sclist(MMAIN, "M-U", 0, do_undo, 0);
add_to_sclist(MMAIN, "M-E", 0, do_redo, 0);
#endif
#ifdef ENABLE_WORDCOMPLETION
add_to_sclist(MMAIN, "^]", 0, complete_a_word, 0);
#endif
#ifdef ENABLE_COMMENT

View File

@ -1654,7 +1654,9 @@ int do_input(bool allow_funcs)
}
}
if (have_shortcut) {
if (!have_shortcut)
pletion_line = NULL;
else {
const subnfunc *f = sctofunc(s);
if (ISSET(VIEW_MODE) && f && !f->viewok) {
@ -1671,10 +1673,11 @@ int do_input(bool allow_funcs)
)
preserve = TRUE;
#ifndef NANO_TINY
#ifdef ENABLE_WORDCOMPLETION
if (s->scfunc != complete_a_word)
pletion_line = NULL;
#endif
#ifndef NANO_TINY
if (s->scfunc == do_toggle_void) {
do_toggle(s->toggle);
if (s->toggle != CUT_TO_END)
@ -1710,10 +1713,6 @@ int do_input(bool allow_funcs)
update_line(openfile->current, openfile->current_x);
}
}
#ifndef NANO_TINY
else
pletion_line = NULL;
#endif
/* If we aren't cutting or copying text, and the key wasn't a toggle,
* blow away the text in the cutbuffer upon the next cutting action. */

View File

@ -484,7 +484,7 @@ typedef struct subnfunc {
/* Next item in the list. */
} subnfunc;
#ifndef NANO_TINY
#ifdef ENABLE_WORDCOMPLETION
typedef struct completion_word {
char *word;
struct completion_word *next;

View File

@ -47,9 +47,7 @@ extern int last_line_y;
extern message_type lastmessage;
#ifndef NANO_TINY
extern filestruct *pletion_line;
#endif
extern int controlleft;
extern int controlright;

View File

@ -48,7 +48,7 @@ static filestruct *jusbottom = NULL;
/* A pointer to the end of the buffer with unjustified text. */
#endif
#ifndef NANO_TINY
#ifdef ENABLE_WORDCOMPLETION
static int pletion_x = 0;
/* The x position in pletion_line of the last found completion. */
static completion_word *list_of_completions;
@ -3684,7 +3684,7 @@ void do_verbatim_input(void)
free(output);
}
#ifndef NANO_TINY
#ifdef ENABLE_WORDCOMPLETION
/* Copy the found completion candidate. */
char *copy_completion(char *check_line, int start)
{
@ -3854,4 +3854,4 @@ void complete_a_word(void)
free(shard);
}
#endif
#endif /* ENABLE_WORDCOMPLETION */