summaryrefslogtreecommitdiff
path: root/src/core/completions.py
diff options
context:
space:
mode:
Diffstat (limited to 'src/core/completions.py')
-rw-r--r--src/core/completions.py35
1 files changed, 25 insertions, 10 deletions
diff --git a/src/core/completions.py b/src/core/completions.py
index 7d95321b..f17e916c 100644
--- a/src/core/completions.py
+++ b/src/core/completions.py
@@ -8,7 +8,6 @@ log = logging.getLogger(__name__)
import os
from functools import reduce
-import bookmark
import common
import pep
import tabs
@@ -57,7 +56,7 @@ def completion_theme(self, the_input):
except OSError as e:
log.error('Completion for /theme failed', exc_info=True)
return
- theme_files = [name[:-3] for name in names if name.endswith('.py')]
+ theme_files = [name[:-3] for name in names if name.endswith('.py') and name != '__init__.py']
if not 'default' in theme_files:
theme_files.append('default')
return the_input.new_completion(theme_files, 1, '', quotify=False)
@@ -96,7 +95,7 @@ def completion_join(self, the_input):
relevant_rooms = []
relevant_rooms.extend(sorted(self.pending_invites.keys()))
- bookmarks = {str(elem.jid): False for elem in bookmark.bookmarks}
+ bookmarks = {str(elem.jid): False for elem in self.bookmarks}
for tab in self.get_tabs(tabs.MucTab):
name = tab.name
if name in bookmarks and not tab.joined:
@@ -119,7 +118,6 @@ def completion_join(self, the_input):
return the_input.new_completion(['/%s' % self.own_nick], 1, quotify=True)
else:
return the_input.new_completion(relevant_rooms, 1, quotify=True)
- return True
def completion_version(self, the_input):
@@ -192,7 +190,7 @@ def completion_bookmark(self, the_input):
def completion_remove_bookmark(self, the_input):
"""Completion for /remove_bookmark"""
- return the_input.new_completion([bm.jid for bm in bookmark.bookmarks], 1, quotify=False)
+ return the_input.new_completion([bm.jid for bm in self.bookmarks], 1, quotify=False)
def completion_decline(self, the_input):
@@ -214,9 +212,6 @@ def completion_bind(self, the_input):
return the_input.new_completion(args, n, '', quotify=False)
- return the_input
-
-
def completion_message(self, the_input):
"""Completion for /message"""
n = the_input.get_argument_position(quoted=True)
@@ -304,14 +299,21 @@ def completion_set(self, the_input):
plugin = self.plugin_manager.plugins[plugin_name]
end_list = ['%s|%s' % (plugin_name, section) for section in plugin.config.sections()]
else:
- end_list = config.options('Poezio')
+ end_list = set(config.options('Poezio'))
+ end_list.update(config.default.get('Poezio', {}))
+ end_list = list(end_list)
+ end_list.sort()
elif n == 2:
if '|' in args[1]:
plugin_name, section = args[1].split('|')[:2]
if not plugin_name in self.plugin_manager.plugins:
return the_input.new_completion([''], n, quotify=True)
plugin = self.plugin_manager.plugins[plugin_name]
- end_list = plugin.config.options(section or plugin_name)
+ end_list = set(plugin.config.options(section or plugin_name))
+ if plugin.config.default:
+ end_list.update(plugin.config.default.get(section or plugin_name, {}))
+ end_list = list(end_list)
+ end_list.sort()
elif not config.has_option('Poezio', args[1]):
if config.has_section(args[1]):
end_list = config.options(args[1])
@@ -336,6 +338,19 @@ def completion_set(self, the_input):
return
return the_input.new_completion(end_list, n, quotify=True)
+
+def completion_set_default(self, the_input):
+ """ Completion for /set_default
+ """
+ args = common.shell_split(the_input.text)
+ n = the_input.get_argument_position(quoted=True)
+ if n >= len(args):
+ args.append('')
+ if n == 1 or (n == 2 and config.has_section(args[1])):
+ return self.completion_set(the_input)
+ return []
+
+
def completion_toggle(self, the_input):
"Completion for /toggle"
return the_input.new_completion(config.options('Poezio'), 1, quotify=False)