diff options
author | Justus Winter <4winter@informatik.uni-hamburg.de> | 2011-09-29 16:08:00 +0200 |
---|---|---|
committer | Justus Winter <4winter@informatik.uni-hamburg.de> | 2011-09-30 17:30:39 +0200 |
commit | 1e5ef0c16b9b328ab7282f33fdf38a3a3b7e864f (patch) | |
tree | 8af751453682c02d977caaf32732908e460c12fb /alot | |
parent | 4cad0180e3b5e24dd4c2e5c043ae55fe0d1e9637 (diff) |
Enable toggletag to toggle a list of tags
Diffstat (limited to 'alot')
-rw-r--r-- | alot/command.py | 15 |
1 files changed, 6 insertions, 9 deletions
diff --git a/alot/command.py b/alot/command.py index 903036f5..5c689a55 100644 --- a/alot/command.py +++ b/alot/command.py @@ -317,10 +317,10 @@ class FlushCommand(Command): class ToggleThreadTagCommand(Command): """toggles tag in given or currently selected thread""" - def __init__(self, tag, thread=None, **kwargs): - assert tag + def __init__(self, tags, thread=None, **kwargs): + assert tags self.thread = thread - self.tag = tag + self.tags = set(tags) Command.__init__(self, **kwargs) def apply(self, ui): @@ -329,10 +329,7 @@ class ToggleThreadTagCommand(Command): if not self.thread: return try: - if self.tag in self.thread.get_tags(): - self.thread.remove_tags([self.tag]) - else: - self.thread.add_tags([self.tag]) + self.thread.set_tags(set(self.thread.get_tags()) ^ self.tags) except DatabaseROError: ui.notify('index in read-only mode', priority='error') return @@ -1071,7 +1068,7 @@ COMMANDS = { 'refine': (RefineCommand, {}), 'refineprompt': (RefinePromptCommand, {}), 'openthread': (OpenThreadCommand, {}), - 'toggletag': (ToggleThreadTagCommand, {'tag': 'inbox'}), + 'toggletag': (ToggleThreadTagCommand, {'tags': ['inbox']}), 'retag': (RetagCommand, {}), 'retagprompt': (RetagPromptCommand, {}), }, @@ -1192,7 +1189,7 @@ def interpret_commandline(cmdline, mode): elif cmd == 'to': return commandfactory(cmd, mode=mode, key='To', value=params) elif cmd == 'toggletag': - return commandfactory(cmd, mode=mode, tag=params) + return commandfactory(cmd, mode=mode, tags=params.split()) elif cmd == 'fold': return commandfactory(cmd, mode=mode, all=(params == '--all')) elif cmd == 'unfold': |