summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorPatrick Totzke <patricktotzke@gmail.com>2018-06-23 23:08:49 +0100
committerGitHub <noreply@github.com>2018-06-23 23:08:49 +0100
commit34bc46fd07f355df9b7a07c4f1dcab469a0a2346 (patch)
tree4bbc68de2452572e1652d3063375ece0ab65188f
parent1482bf87794a9422f0ff383820f6693b2bfe094f (diff)
parent0a1840b3940db108277de1c113a5c29dd74d7d33 (diff)
Merge pull request #1222 from mjg/thread-retagprompt
provide retagprompt command in thread mode
-rw-r--r--alot/commands/common.py28
-rw-r--r--alot/commands/search.py19
-rw-r--r--alot/commands/thread.py4
-rw-r--r--docs/source/usage/modes/search.rst2
-rw-r--r--docs/source/usage/modes/thread.rst7
5 files changed, 42 insertions, 18 deletions
diff --git a/alot/commands/common.py b/alot/commands/common.py
new file mode 100644
index 00000000..71280d38
--- /dev/null
+++ b/alot/commands/common.py
@@ -0,0 +1,28 @@
+# Copyright (C) 2011-2012 Patrick Totzke <patricktotzke@gmail.com>
+# This file is released under the GNU GPL, version 3 or a later revision.
+# For further details see the COPYING file
+
+from . import Command
+
+from .globals import PromptCommand
+
+
+class RetagPromptCommand(Command):
+
+ """prompt to retag selected thread's or message's tags"""
+ def apply(self, ui):
+ 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 item.get_tags():
+ if ' ' in tag:
+ tags.append('"%s"' % tag)
+ # skip empty tags
+ elif tag:
+ tags.append(tag)
+ initial_tagstring = ','.join(sorted(tags)) + ','
+ return ui.apply_command(PromptCommand('retag ' + initial_tagstring))
diff --git a/alot/commands/search.py b/alot/commands/search.py
index 946749ec..3e172dd5 100644
--- a/alot/commands/search.py
+++ b/alot/commands/search.py
@@ -7,6 +7,7 @@ import logging
from . import Command, registerCommand
from .globals import PromptCommand
from .globals import MoveCommand
+from .common import RetagPromptCommand
from .. import commands
from .. import buffers
@@ -91,23 +92,7 @@ class RefinePromptCommand(Command):
return ui.apply_command(PromptCommand('refine ' + oldquery))
-@registerCommand(MODE, 'retagprompt')
-class RetagPromptCommand(Command):
-
- """prompt to retag selected threads\' tags"""
- def apply(self, ui):
- thread = ui.current_buffer.get_selected_thread()
- if not thread:
- return
- tags = []
- for tag in thread.get_tags():
- if ' ' in tag:
- tags.append('"%s"' % tag)
- # skip empty tags
- elif tag:
- tags.append(tag)
- initial_tagstring = ','.join(sorted(tags)) + ','
- return ui.apply_command(PromptCommand('retag ' + initial_tagstring))
+RetagPromptCommand = registerCommand(MODE, 'retagprompt')(RetagPromptCommand)
@registerCommand(
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