new libedit: add rl_completion_word_break_hook functionality
authorJohn Marino <draco@marino.st>
Thu, 10 May 2012 00:45:00 +0000 (02:45 +0200)
committerJohn Marino <draco@marino.st>
Thu, 10 May 2012 21:39:01 +0000 (23:39 +0200)
Recreates commit:
e2624a299cd1858e0a04301d42b946851c336c37

"This follows roughly what is described in the readline manual.
 rl_completion_word_break_hook is needed by gdb-7."

contrib/libedit/src/editline/readline.h
contrib/libedit/src/readline.c

index 4c4d65a..a199b3f 100644 (file)
@@ -109,6 +109,7 @@ extern char         *rl_basic_word_break_characters;
 extern char            *rl_completer_word_break_characters;
 extern char            *rl_completer_quote_characters;
 extern Function                *rl_completion_entry_function;
+extern char            *(* rl_completion_word_break_hook)(void);
 extern CPPFunction     *rl_attempted_completion_function;
 extern int              rl_attempted_completion_over;
 extern int             rl_completion_type;
index c0a6a0c..d041824 100644 (file)
@@ -103,6 +103,7 @@ int rl_attempted_completion_over = 0;
 char *rl_basic_word_break_characters = break_chars;
 char *rl_completer_word_break_characters = NULL;
 char *rl_completer_quote_characters = NULL;
+char *(* rl_completion_word_break_hook)(void) = NULL;
 Function *rl_completion_entry_function = NULL;
 CPPFunction *rl_attempted_completion_function = NULL;
 Function *rl_pre_input_hook = NULL;
@@ -1752,6 +1753,7 @@ rl_complete(int ignore __attribute__((__unused__)), int invoking_key)
 #ifdef WIDECHAR
        static ct_buffer_t wbreak_conv, sprefix_conv;
 #endif
+       char *breakchars = NULL;
 
        if (h == NULL || e == NULL)
                rl_initialize();
@@ -1764,11 +1766,16 @@ rl_complete(int ignore __attribute__((__unused__)), int invoking_key)
                return CC_REFRESH;
        }
 
+       if (rl_completion_word_break_hook != NULL)
+               breakchars = rl_completion_word_break_hook();
+       if (breakchars == NULL)
+               breakchars = rl_basic_word_break_characters;
+
        /* Just look at how many global variables modify this operation! */
        return fn_complete(e,
            (CPFunction *)rl_completion_entry_function,
            rl_attempted_completion_function,
-           ct_decode_string(rl_basic_word_break_characters, &wbreak_conv),
+           ct_decode_string(breakchars, &wbreak_conv),
            ct_decode_string(rl_special_prefixes, &sprefix_conv),
            _rl_completion_append_character_function,
            (size_t)rl_completion_query_items,