diff options
author | Michael J Gruber <github@grubix.eu> | 2018-03-08 09:20:20 +0100 |
---|---|---|
committer | Michael J Gruber <github@grubix.eu> | 2018-06-22 11:32:15 +0200 |
commit | 0a1840b3940db108277de1c113a5c29dd74d7d33 (patch) | |
tree | 297b9bb2db06b2223cc5301e661bd153cc98721f | |
parent | 35ef660f7883428da3ba0ad27d267725293a65a9 (diff) |
provide retagprompt command in thread mode
retagprompt in search mode allows to retag a whole thread. The new
thread mode version allows to do the same for each selected message.
The common command infers its mode from the UI object that it is passed
when applied. Therefore, the docstring (and everything else) is
mode-agnostic.
When this command command is registered for the wrong mode and applied
it raises a KeyError (on purpose).
-rw-r--r-- | alot/commands/common.py | 11 | ||||
-rw-r--r-- | alot/commands/thread.py | 4 | ||||
-rw-r--r-- | docs/source/usage/modes/search.rst | 2 | ||||
-rw-r--r-- | docs/source/usage/modes/thread.rst | 7 |
4 files changed, 19 insertions, 5 deletions
diff --git a/alot/commands/common.py b/alot/commands/common.py index 64e68d49..71280d38 100644 --- a/alot/commands/common.py +++ b/alot/commands/common.py @@ -9,13 +9,16 @@ from .globals import PromptCommand class RetagPromptCommand(Command): - """prompt to retag selected threads\' tags""" + """prompt to retag selected thread's or message's tags""" def apply(self, ui): - thread = ui.current_buffer.get_selected_thread() - if not thread: + get_selected_item = getattr(ui.current_buffer, { + 'search': 'get_selected_thread', + 'thread': 'get_selected_message'}[ui.mode]) + item = get_selected_item() + if not item: return tags = [] - for tag in thread.get_tags(): + for tag in item.get_tags(): if ' ' in tag: tags.append('"%s"' % tag) # skip empty tags diff --git a/alot/commands/thread.py b/alot/commands/thread.py index 05f73d6a..b6eee44f 100644 --- a/alot/commands/thread.py +++ b/alot/commands/thread.py @@ -21,6 +21,7 @@ from .globals import FlushCommand from .globals import ComposeCommand from .globals import MoveCommand from .globals import CommandCanceled +from .common import RetagPromptCommand from .envelope import SendCommand from ..completion import ContactsCompleter, PathCompleter from ..db.utils import decode_header @@ -1080,6 +1081,9 @@ class ThreadSelectCommand(Command): ui.apply_command(ChangeDisplaymodeCommand(visible='toggle')) +RetagPromptCommand = registerCommand(MODE, 'retagprompt')(RetagPromptCommand) + + @registerCommand( MODE, 'tag', forced={'action': 'add'}, arguments=[ diff --git a/docs/source/usage/modes/search.rst b/docs/source/usage/modes/search.rst index c95d1a01..bdfeb48b 100644 --- a/docs/source/usage/modes/search.rst +++ b/docs/source/usage/modes/search.rst @@ -51,7 +51,7 @@ The following commands are available in search mode .. describe:: retagprompt - prompt to retag selected threads' tags + prompt to retag selected thread's or message's tags .. _cmd.search.select: diff --git a/docs/source/usage/modes/thread.rst b/docs/source/usage/modes/thread.rst index 447e543a..1520e3cc 100644 --- a/docs/source/usage/modes/thread.rst +++ b/docs/source/usage/modes/thread.rst @@ -125,6 +125,13 @@ The following commands are available in thread mode :---all: tag all messages in thread. :---no-flush: postpone a writeout to the index (Defaults to: 'True'). +.. _cmd.thread.retagprompt: + +.. describe:: retagprompt + + prompt to retag selected thread's or message's tags + + .. _cmd.thread.save: .. describe:: save |