diff options
author | Anton Khirnov <anton@khirnov.net> | 2020-05-24 14:23:34 +0200 |
---|---|---|
committer | Anton Khirnov <anton@khirnov.net> | 2020-05-24 14:47:35 +0200 |
commit | 1bceeca953cda102923bb67dfbc8488bae5d35cc (patch) | |
tree | 2798579f7e97adccc4cdc302775db912a16b0bb0 /alot/commands/common.py | |
parent | c8f3d99eab089d337e5fdcb8ff39efd6ab1aa5e9 (diff) |
Allow designating certain tags as "property" tags.
Those are tags like attachment, signed, sent, etc., which are set
automatically based on message properties and are typically not changed
manually.
Such designated tags are not affected by the retag operation.
Diffstat (limited to 'alot/commands/common.py')
-rw-r--r-- | alot/commands/common.py | 18 |
1 files changed, 10 insertions, 8 deletions
diff --git a/alot/commands/common.py b/alot/commands/common.py index 8280a5c0..4914933c 100644 --- a/alot/commands/common.py +++ b/alot/commands/common.py @@ -7,6 +7,7 @@ from . import Command from .globals import PromptCommand +from ..settings.const import settings class RetagPromptCommand(Command): @@ -18,13 +19,14 @@ class RetagPromptCommand(Command): item = get_selected_item() if not item: return - tags = [] - for tag in item.get_tags(): - if ' ' in tag: - tags.append('"%s"' % tag) - # skip empty tags - elif tag: - tags.append(tag) - initial_tagstring = ','.join(sorted(tags)) + ',' + + exclude_tags = frozenset(settings.get('property_tags')) + tags = map(lambda x: ("%s" % x) if ' ' in x else x, + item.get_tags() - exclude_tags) + + initial_tagstring = ','.join(sorted(tags)) + if initial_tagstring: + initial_tagstring += ',' + r = await ui.apply_command(PromptCommand('retag ' + initial_tagstring)) return r |