summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--Doc/lib/libreadline.tex4
-rw-r--r--Modules/readline.c18
2 files changed, 22 insertions, 0 deletions
diff --git a/Doc/lib/libreadline.tex b/Doc/lib/libreadline.tex
index 7350845..3988052 100644
--- a/Doc/lib/libreadline.tex
+++ b/Doc/lib/libreadline.tex
@@ -96,6 +96,10 @@ Set the readline word delimiters for tab-completion.
Get the readline word delimiters for tab-completion.
\end{funcdesc}
+\begin{funcdesc}{add_history}{line}
+Append a line to the history buffer, as if it was the last line typed.
+\end{funcdesc}
+
\begin{seealso}
\seemodule{rlcompleter}{Completion of Python identifiers at the
diff --git a/Modules/readline.c b/Modules/readline.c
index 49839c4..aa29a61 100644
--- a/Modules/readline.c
+++ b/Modules/readline.c
@@ -287,6 +287,23 @@ static char doc_set_completer_delims[] = "\
set_completer_delims(string) -> None\n\
set the readline word delimiters for tab-completion";
+static PyObject *
+py_add_history(PyObject *self, PyObject *args)
+{
+ char *line;
+
+ if(!PyArg_ParseTuple(args, "s:add_history", &line)) {
+ return NULL;
+ }
+ add_history(line);
+ Py_INCREF(Py_None);
+ return Py_None;
+}
+
+static char doc_add_history[] = "\
+add_history(string) -> None\n\
+add a line to the history buffer";
+
/* get the tab-completion word-delimiters that readline uses */
@@ -375,6 +392,7 @@ static struct PyMethodDef readline_methods[] =
{"set_completer_delims", set_completer_delims,
METH_VARARGS, doc_set_completer_delims},
+ {"add_history", py_add_history, METH_VARARGS, doc_add_history},
{"get_completer_delims", get_completer_delims,
METH_OLDARGS, doc_get_completer_delims},