]> granicus.if.org Git - python/commitdiff
Patch #800697: Add readline.clear_history.
authorMartin v. Löwis <martin@v.loewis.de>
Sat, 20 Sep 2003 16:08:33 +0000 (16:08 +0000)
committerMartin v. Löwis <martin@v.loewis.de>
Sat, 20 Sep 2003 16:08:33 +0000 (16:08 +0000)
Doc/lib/libreadline.tex
Misc/NEWS
Modules/readline.c

index d428594973f5d2af46a76dcb6d5f3a3400e3c68a..17b48c521bd9fa44405e181a8c79bfd0a66cedcb 100644 (file)
@@ -42,6 +42,12 @@ Save a readline history file.
 The default filename is \file{\~{}/.history}.
 \end{funcdesc}
 
+\begin{funcdesc}{clear_history}{}
+Clear the current history.  (Note: this function is not available if
+the installed version of GNU readline doesn't support it.)
+\versionadded{2.4}
+\end{funcdesc}
+
 \begin{funcdesc}{get_history_length}{}
 Return the desired length of the history file.  Negative values imply
 unlimited history file size.
index 2f0aec87a317ed8cfd6d8d01b4cb1c71d9b7d11b..9bfd738a1ffe144f822c75c90dc2dfa8d7ea480b 100644 (file)
--- a/Misc/NEWS
+++ b/Misc/NEWS
@@ -29,6 +29,8 @@ Core and builtins
 Extension modules
 -----------------
 
+- readline.clear_history was added.
+
 - select.select() now accepts sequences for its first three arguments.
 
 - cStringIO now supports the f.closed attribute.
index 64935c6efef7684c28938cfb45c13d50ee3bf506..5053d1cc71625866b84978ab7e28211a90baaa2f 100644 (file)
@@ -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 *
@@ -483,6 +501,9 @@ static struct PyMethodDef readline_methods[] =
 #ifdef HAVE_RL_PRE_INPUT_HOOK
        {"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}
 };