summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authormathieui <mathieui@mathieui.net>2012-05-23 16:23:26 +0200
committermathieui <mathieui@mathieui.net>2012-05-23 16:25:53 +0200
commit12bd9b589ca3ebc6ce6c9ae269006850a30afbaa (patch)
treed391653b985d6ccc4f4bf2c12d8b54ed4069f697
parente1c7f63a3a186f802b91101513a839bb2b864c61 (diff)
downloadpoezio-12bd9b589ca3ebc6ce6c9ae269006850a30afbaa.tar.gz
poezio-12bd9b589ca3ebc6ce6c9ae269006850a30afbaa.tar.bz2
poezio-12bd9b589ca3ebc6ce6c9ae269006850a30afbaa.tar.xz
poezio-12bd9b589ca3ebc6ce6c9ae269006850a30afbaa.zip
Add personal words completion - Fixes #1723
This commits adds a “words” variable to the configuration file. This variable must contain a list of words, separated by colons (:). Those words will then be completed upon tab completion in the chatrooms, private conversations, and direct conversations.
-rw-r--r--data/default_config.cfg5
-rw-r--r--doc/en/configure.txt7
-rw-r--r--src/tabs.py23
3 files changed, 34 insertions, 1 deletions
diff --git a/data/default_config.cfg b/data/default_config.cfg
index f109e394..46c9f3b2 100644
--- a/data/default_config.cfg
+++ b/data/default_config.cfg
@@ -99,6 +99,11 @@ after_completion = ,
# conversation window.
max_nick_length = 25
+# Words that you want to complete on normal completion, separated by a colon
+# (:).
+# e.g. words = "anticonstitutionellement:I protest:I like bananas:"
+words =
+
# a list of words (separated by a colon (:)) that will be
# highlighted if said by someone on a room
highlight_on =
diff --git a/doc/en/configure.txt b/doc/en/configure.txt
index 81bb8198..a2262c90 100644
--- a/doc/en/configure.txt
+++ b/doc/en/configure.txt
@@ -132,6 +132,13 @@ section of this documentation.
what will be put after the name, when using autocompletion
a SPACE will always be added after that
+*words*:: [empty]
+
+ Personal dictionary of the words you use often, that you want to complete
+ through tab completion. They must be separated bu a colon (:). That
+ completion will work in chatrooms, private conversations, and direct
+ conversations.
+
*highlight_on*:: [empty]
a list of words (separated by a colon (:)) that will be
diff --git a/src/tabs.py b/src/tabs.py
index 72e4dbda..2bf0c216 100644
--- a/src/tabs.py
+++ b/src/tabs.py
@@ -1129,6 +1129,9 @@ class MucTab(ChatTab):
compare_users = lambda x: x.last_talked
word_list = [user.nick for user in sorted(self.users, key=compare_users, reverse=True)\
if user.nick != self.own_nick]
+ word_list.extend(config.get('words', '').split(':'))
+ if '' in word_list:
+ word_list.remove('')
after = config.get('after_completion', ',')+" "
input_pos = self.input.pos + self.input.line_pos
if ' ' not in self.input.get_text()[:input_pos] or (self.input.last_completion and\
@@ -1583,6 +1586,9 @@ class PrivateTab(ChatTab):
compare_users = lambda x: x.last_talked
word_list = [user.nick for user in sorted(self.parent_muc.users, key=compare_users, reverse=True)\
if user.nick != self.own_nick]
+ word_list.extend(config.get('words', '').split(':'))
+ if '' in word_list:
+ word_list.remove('')
after = config.get('after_completion', ',')+" "
input_pos = self.input.pos + self.input.line_pos
if ' ' not in self.input.get_text()[:input_pos] or (self.input.last_completion and\
@@ -2498,7 +2504,22 @@ class ConversationTab(ChatTab):
del ConversationTab.additional_informations[plugin_name]
def completion(self):
- self.complete_commands(self.input)
+ if self.complete_commands(self.input):
+ return
+
+ word_list = config.get('words', '').split(':')
+ if '' in word_list:
+ word_list.remove('')
+ after = config.get('after_completion', ',')+" "
+ input_pos = self.input.pos + self.input.line_pos
+ if ' ' not in self.input.get_text()[:input_pos] or (self.input.last_completion and\
+ self.input.get_text()[:input_pos] == self.input.last_completion + after):
+ add_after = after
+ else:
+ add_after = ''
+ self.input.auto_completion(word_list, add_after, quotify=False)
+ empty_after = self.input.get_text() == '' or (self.input.get_text().startswith('/') and not self.input.get_text().startswith('//'))
+ self.send_composing_chat_state(empty_after)
def command_say(self, line, attention=False):
msg = self.core.xmpp.make_message(self.get_name())