diff options
-rw-r--r-- | alot/commands/globals.py | 11 | ||||
-rw-r--r-- | alot/commands/thread.py | 3 | ||||
-rw-r--r-- | alot/ui.py | 29 |
3 files changed, 33 insertions, 10 deletions
diff --git a/alot/commands/globals.py b/alot/commands/globals.py index eede876a..4626b3e2 100644 --- a/alot/commands/globals.py +++ b/alot/commands/globals.py @@ -765,10 +765,11 @@ class ComposeCommand(Command): else: cmpl = AccountCompleter() fromaddress = yield ui.prompt('From', completer=cmpl, - tab=1) + tab=1, history=ui.senderhistory) if fromaddress is None: raise CommandCanceled() + ui.senderhistory.append(fromaddress) self.envelope.add('From', fromaddress) # find out the right account @@ -819,12 +820,14 @@ class ComposeCommand(Command): append_remaining=allbooks) logging.debug(abooks) completer = ContactsCompleter(abooks) - to = yield ui.prompt('To', - completer=completer) + to = yield ui.prompt('To', completer=completer, + history=ui.recipienthistory) if to is None: raise CommandCanceled() - self.envelope.add('To', to.strip(' \t\n,')) + to = to.strip(' \t\n,') + ui.recipienthistory.append(to) + self.envelope.add('To', to) if settings.get('ask_subject') and \ 'Subject' not in self.envelope.headers: diff --git a/alot/commands/thread.py b/alot/commands/thread.py index ad7110ed..2f7e674c 100644 --- a/alot/commands/thread.py +++ b/alot/commands/thread.py @@ -437,7 +437,8 @@ class BounceMailCommand(Command): completer = ContactsCompleter(abooks) else: completer = None - to = yield ui.prompt('To', completer=completer) + to = yield ui.prompt('To', completer=completer, + history=ui.recipienthistory) if to is None: raise CommandCanceled() @@ -48,6 +48,10 @@ class UI(object): """interface mode identifier - type of current buffer""" self.commandprompthistory = [] """history of the command line prompt""" + self.senderhistory = [] + """history of the sender prompt""" + self.recipienthistory = [] + """history of the recipients prompt""" self.input_queue = [] """stores partial keyboard input""" self.last_commandline = None @@ -75,12 +79,20 @@ class UI(object): signal.signal(signal.SIGINT, self.handle_signal) signal.signal(signal.SIGUSR1, self.handle_signal) - # load command history + # load histories self._cache = os.path.join( os.environ.get('XDG_CACHE_HOME', os.path.expanduser('~/.cache')), - 'alot', 'commandhistory') + 'alot', 'history') + self._cmd_hist_file = os.path.join(self._cache, 'commands') + self._sender_hist_file = os.path.join(self._cache, 'senders') + self._recipients_hist_file = os.path.join(self._cache, 'recipients') + size = settings.get('history_size') self.commandprompthistory = self._load_history_from_file( - self._cache, size=settings.get('history_size')) + self._cmd_hist_file, size=size) + self.senderhistory = self._load_history_from_file( + self._sender_hist_file, size=size) + self.recipienthistory = self._load_history_from_file( + self._recipients_hist_file, size=size) # set up main loop self.mainloop = urwid.MainLoop(self.root_widget, @@ -676,8 +688,13 @@ class UI(object): def cleanup(self): """Do the final clean up before shutting down.""" - self._save_history_to_file(self.commandprompthistory, self._cache, - size=settings.get('history_size')) + size = settings.get('history_size') + self._save_history_to_file(self.commandprompthistory, + self._cmd_hist_file, size=size) + self._save_history_to_file(self.senderhistory, self._sender_hist_file, + size=size) + self._save_history_to_file(self.recipienthistory, + self._recipients_hist_file, size=size) @staticmethod def _load_history_from_file(path, size=-1): @@ -699,6 +716,8 @@ class UI(object): if size > 0: lines = lines[-size:] return lines + else: + return [] @staticmethod def _save_history_to_file(history, path, size=-1): |