Index: Doc/library/readline.rst =================================================================== --- Doc/library/readline.rst (révision 82082) +++ Doc/library/readline.rst (copie de travail) @@ -177,6 +177,21 @@ Get the readline word delimiters for tab-completion. +.. function:: set_completer_quote_delims() + + Set the list of characters which can be used to quote a substring of + the line. Completion occurs on the entire substring, and within the + substring. + + .. versionadded:: 2.7 + +.. function:: get_completer_quote_delims() + + Get the list of characters which can be used to quote a substring of + the line. + + .. versionadded:: 2.7 + .. function:: set_completion_display_matches_hook([function]) Set or remove the completion display function. If *function* is Index: Lib/test/test_readline.py =================================================================== --- Lib/test/test_readline.py (révision 82082) +++ Lib/test/test_readline.py (copie de travail) @@ -35,9 +35,15 @@ self.assertEqual(readline.get_current_history_length(), 1) +class TestCompleter(unittest.TestCase): + def testCompleterQuote(self): + self.assertEqual(readline.get_completer_quote_delims(), "") + self.assertEqual(readline.set_completer_quote_delims("\\"), None) + self.assertEqual(readline.get_completer_quote_delims(), "\\") + def test_main(): - run_unittest(TestHistoryManipulation) + run_unittest(*(TestHistoryManipulation, TestCompleter)) if __name__ == "__main__": test_main() Index: Modules/readline.c =================================================================== --- Modules/readline.c (révision 82082) +++ Modules/readline.c (copie de travail) @@ -356,7 +356,30 @@ "set_completer_delims(string) -> None\n\ set the readline word delimiters for tab-completion"); +/* Set the list of characters which can be used to quote a substring of the line */ + static PyObject * +set_completer_quote_delims(PyObject *self, PyObject *args) +{ + char *break_chars; + + if(!PyArg_ParseTuple(args, "s:set_completer_quote_delims", &break_chars)) { + return NULL; + } + if (rl_completer_quote_characters != NULL) { + free((void*)rl_completer_quote_characters); + } + rl_completer_quote_characters = strdup(break_chars); + Py_INCREF(Py_None); + return Py_None; +} + +PyDoc_STRVAR(doc_set_completer_quote_delims, +"set_completer_quote_delims(string) -> None\n\ +Set the list of characters which can be used to quote a substring of the line"); + + +static PyObject * py_remove_history(PyObject *self, PyObject *args) { int entry_number; @@ -458,7 +481,20 @@ "get_completer_delims() -> string\n\ get the readline word delimiters for tab-completion"); +static PyObject * +get_completer_quote_delims(PyObject *self, PyObject *noarg) +{ + if (rl_completer_quote_characters == NULL) { + return PyString_FromString(""); + } else { + return PyString_FromString(rl_completer_quote_characters); + } +} +PyDoc_STRVAR(doc_get_completer_quote_delims, +"get_completer_quote_delims() -> string\n\ +get the list of characters which can be used to quote a substring of the line"); + /* Set the completer function */ static PyObject * @@ -643,11 +679,15 @@ {"set_completer_delims", set_completer_delims, METH_VARARGS, doc_set_completer_delims}, + {"set_completer_quote_delims", set_completer_quote_delims, + METH_VARARGS, doc_set_completer_quote_delims}, {"add_history", py_add_history, METH_VARARGS, doc_add_history}, {"remove_history_item", py_remove_history, METH_VARARGS, doc_remove_history}, {"replace_history_item", py_replace_history, METH_VARARGS, doc_replace_history}, {"get_completer_delims", get_completer_delims, METH_NOARGS, doc_get_completer_delims}, + {"get_completer_quote_delims", get_completer_quote_delims, + METH_NOARGS, doc_get_completer_quote_delims}, {"set_completion_display_matches_hook", set_completion_display_matches_hook, METH_VARARGS, doc_set_completion_display_matches_hook},