|
From: Martin R. <ru...@us...> - 2004-08-07 08:04:49
|
Update of /cvsroot/foo/fooelk/lib/readline In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv10503 Modified Files: completion.c Log Message: complete filenames instead of symbols inside strings. switch completion on/off via scheme functions, initial state determined by ELK_READLINE_COMPLETION environment var Index: completion.c =================================================================== RCS file: /cvsroot/foo/fooelk/lib/readline/completion.c,v retrieving revision 1.1.1.1 retrieving revision 1.2 diff -C2 -d -r1.1.1.1 -r1.2 *** completion.c 6 Aug 2004 20:56:43 -0000 1.1.1.1 --- completion.c 7 Aug 2004 08:04:40 -0000 1.2 *************** *** 30,35 **** --- 30,38 ---- #include "readline.h" + #include <stdlib.h> + #include <string.h> static int _erl_maxcompl; + static int _do_completion; static char **_erl_completions; *************** *** 70,74 **** static char * ! erl_complete (char *text, int state) { if (! state) --- 73,77 ---- static char * ! erl_symbol_complete (char *text, int state) { if (! state) *************** *** 81,90 **** void elk_init_readline_completion (void) { ! _erl_maxcompl = 256; _erl_completions = (char **)malloc(_erl_maxcompl * sizeof(char *)); ! rl_completion_entry_function = (void *)erl_complete; } --- 84,147 ---- + static char ** + erl_guess_completion (const char *text, int start, int end) + { + char **matches; + + if (! _do_completion) + { + rl_attempted_completion_over = 1; + return NULL; + } + + matches = (char **)NULL; + + /* complete symbols if not in string */ + if (rl_line_buffer[start - 1] != '"') + { + matches = rl_completion_matches(text, erl_symbol_complete); + } + + return matches; + } + + + static Object + P_Readline_Completion (Object enable) + { + Check_Type(enable, T_Boolean); + + if (Truep(enable)) + { + _do_completion = 1; + } + else + { + _do_completion = 0; + } + + return True; + } + + void elk_init_readline_completion (void) { ! char *completion; ! ! if ((completion = getenv("ELK_READLINE_COMPLETION")) && strlen(completion)) ! { ! _do_completion = 1; ! } ! else ! { ! _do_completion = 0; ! } ! _erl_maxcompl = 512; _erl_completions = (char **)malloc(_erl_maxcompl * sizeof(char *)); ! rl_readline_name = "fooelk"; ! rl_attempted_completion_function = erl_guess_completion; ! ! Def_Prim(P_Readline_Completion, "readline-completion", 1, 1, EVAL); } |