From 0e0108098326c182a292527046cc8ccb6eb2035e Mon Sep 17 00:00:00 2001
From: Benno Schulenberg <bensberg@justemail.net>
Date: Wed, 7 Dec 2016 13:20:36 +0100
Subject: [PATCH] binding: allow to rebind the word-completion function, and
 document it

---
 doc/man/nanorc.5      | 4 ++++
 doc/texinfo/nano.texi | 4 ++++
 src/global.c          | 4 ++++
 3 files changed, 12 insertions(+)

diff --git a/doc/man/nanorc.5 b/doc/man/nanorc.5
index e04f5e6d..f90019c9 100644
--- a/doc/man/nanorc.5
+++ b/doc/man/nanorc.5
@@ -489,6 +489,10 @@ Unindents (shifts to the left) the currently marked text.
 Comments or uncomments the current line or marked lines, using the comment
 style specified in the active syntax.
 .TP
+.B complete
+Completes the fragment before the cursor to a full word found elsewhere
+in the current buffer.
+.TP
 .B left
 Goes left one position (in the editor or browser).
 .TP
diff --git a/doc/texinfo/nano.texi b/doc/texinfo/nano.texi
index 877fee17..22fde0b1 100644
--- a/doc/texinfo/nano.texi
+++ b/doc/texinfo/nano.texi
@@ -1091,6 +1091,10 @@ Unindents (shifts to the left) the currently marked text.
 Comments or uncomments the current line or marked lines, using the comment
 style specified in the active syntax.
 
+@item complete
+Completes the fragment before the cursor to a full word found elsewhere
+in the current buffer.
+
 @item left
 Goes left one position (in the editor or browser).
 
diff --git a/src/global.c b/src/global.c
index 488b7fc4..499c15ff 100644
--- a/src/global.c
+++ b/src/global.c
@@ -1456,6 +1456,10 @@ sc *strtosc(const char *input)
     else if (!strcasecmp(input, "comment"))
 	s->scfunc = do_comment;
 #endif
+#ifdef ENABLE_WORDCOMPLETION
+    else if (!strcasecmp(input, "complete"))
+	s->scfunc = complete_a_word;
+#endif
 #ifndef NANO_TINY
     else if (!strcasecmp(input, "indent"))
 	s->scfunc = do_indent_void;
-- 
GitLab