summaryrefslogtreecommitdiffstats
path: root/Modules
diff options
context:
space:
mode:
authorMartin v. Löwis <martin@v.loewis.de>2003-09-20 16:08:33 (GMT)
committerMartin v. Löwis <martin@v.loewis.de>2003-09-20 16:08:33 (GMT)
commite7a9796a0f83bd2e5e2b1d35ad8f0a2a96ec5e3f (patch)
treeffe4c8f50a81591e0fb8a9e7354b2d6b2678ea31 /Modules
parentc6bb6c0f8c90f5f14d933b974db4c3ce2c7b296f (diff)
downloadcpython-e7a9796a0f83bd2e5e2b1d35ad8f0a2a96ec5e3f.zip
cpython-e7a9796a0f83bd2e5e2b1d35ad8f0a2a96ec5e3f.tar.gz
cpython-e7a9796a0f83bd2e5e2b1d35ad8f0a2a96ec5e3f.tar.bz2
Patch #800697: Add readline.clear_history.
Diffstat (limited to 'Modules')
-rw-r--r--Modules/readline.c21
1 files changed, 21 insertions, 0 deletions
diff --git a/Modules/readline.c b/Modules/readline.c
index 64935c6..5053d1c 100644
--- a/Modules/readline.c
+++ b/Modules/readline.c
@@ -412,6 +412,24 @@ PyDoc_STRVAR(doc_get_line_buffer,
return the current contents of the line buffer.");
+#ifdef HAVE_RL_COMPLETION_APPEND_CHARACTER
+
+/* Exported function to clear the current history */
+
+static PyObject *
+py_clear_history(PyObject *self, PyObject *noarg)
+{
+ clear_history();
+ Py_INCREF(Py_None);
+ return Py_None;
+}
+
+PyDoc_STRVAR(doc_clear_history,
+"clear_history() -> None\n\
+Clear the current readline history.");
+#endif
+
+
/* Exported function to insert text into the line buffer */
static PyObject *
@@ -484,6 +502,9 @@ static struct PyMethodDef readline_methods[] =
{"set_pre_input_hook", set_pre_input_hook,
METH_VARARGS, doc_set_pre_input_hook},
#endif
+#ifdef HAVE_RL_COMPLETION_APPEND_CHARACTER
+ {"clear_history", py_clear_history, METH_NOARGS, doc_clear_history},
+#endif
{0, 0}
};