diff options
author | Patrick Totzke <patricktotzke@gmail.com> | 2011-09-30 08:57:56 -0700 |
---|---|---|
committer | Patrick Totzke <patricktotzke@gmail.com> | 2011-09-30 08:57:56 -0700 |
commit | 04feeb96a2b5d6eeabc8dfa4eecb4c3d99120ac2 (patch) | |
tree | 8af751453682c02d977caaf32732908e460c12fb | |
parent | 4cad0180e3b5e24dd4c2e5c043ae55fe0d1e9637 (diff) | |
parent | 1e5ef0c16b9b328ab7282f33fdf38a3a3b7e864f (diff) |
Merge pull request #73 from teythoon/toggle_tags
Enable toggletag to toggle a list of tags
-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': |