Remove delays with 0

This commit is contained in:
Felix Van der Jeugt 2020-08-20 11:54:15 +02:00
parent e071340930
commit a93d6b56ba
No known key found for this signature in database
GPG Key ID: 58B209295023754D
3 changed files with 30 additions and 10 deletions

View File

@ -4,6 +4,7 @@ periodic_hook_frequency = 60
edit_headers_blacklist = Content-Type, MIME-Version edit_headers_blacklist = Content-Type, MIME-Version
attachment_prefix = /data/temporary attachment_prefix = /data/temporary
prefer_plaintext = True prefer_plaintext = True
thread_authors_replace_me = False
editor_cmd = st -e vis editor_cmd = st -e vis
@ -93,6 +94,7 @@ theme = "mutt"
7 = call hooks.delay(ui,7) 7 = call hooks.delay(ui,7)
8 = call hooks.delay(ui,8) 8 = call hooks.delay(ui,8)
9 = call hooks.delay(ui,9) 9 = call hooks.delay(ui,9)
0 = call hooks.delay(ui,0)
i = call hooks.spam(ui) i = call hooks.spam(ui)
[[thread]] [[thread]]
@ -110,6 +112,7 @@ theme = "mutt"
7 = call hooks.delay(ui,7) 7 = call hooks.delay(ui,7)
8 = call hooks.delay(ui,8) 8 = call hooks.delay(ui,8)
9 = call hooks.delay(ui,9) 9 = call hooks.delay(ui,9)
0 = call hooks.delay(ui,0)
i = call hooks.spam(ui) i = call hooks.spam(ui)
[tags] [tags]

View File

@ -1,17 +1,34 @@
#!/usr/bin/env python3 #!/usr/bin/env python3
from datetime import date, timedelta
from alot.buffers import EnvelopeBuffer
from alot.db.envelope import Envelope
from alot.settings.const import settings
async def delay(ui, days): async def delay(ui, days):
from datetime import date, timedelta datetag = 'delay/' + str(date.today() + timedelta(days=days))
datestr = str(date.today() + timedelta(days=days))
await ui.apply_commandline(f'toggletags inbox,delay,delay/{datestr}') if ui.current_buffer.modename == 'search':
messages = ui.current_buffer.get_selected_thread().get_messages().keys()
elif ui.current_buffer.modename == 'thread':
messages = [ ui.current_buffer.get_selected_message() ]
if days != 0:
for message in messages:
if 'inbox' in message.get_tags():
message.add_tags(['delay', datetag])
await ui.apply_commandline('untag inbox,unread')
else:
for message in messages:
if 'delay' in message.get_tags():
message.remove_tags([t for t in message.get_tags() if t.startswith('delay')])
message.add_tags(['inbox'])
await ui.apply_commandline('untag delay,delay/*')
async def spam(ui): async def spam(ui):
from alot.buffers import EnvelopeBuffer
from alot.db.envelope import Envelope
from alot.settings.const import settings
message = ui.current_buffer.get_selected_message() message = ui.current_buffer.get_selected_message()
message.add_tags(['spam']) message.add_tags(['spam'])
message.remove_tags(['unread']) message.remove_tags(['unread', 'inbox'])
if 'ugent' in message.get_tags(): if 'ugent' in message.get_tags():
envelope = Envelope( envelope = Envelope(
headers=dict( headers=dict(

View File

@ -1,6 +1,6 @@
#!/usr/bin/python3 #!/usr/bin/python3
# EASY-INSTALL-ENTRY-SCRIPT: 'alot==0.9','console_scripts','alot' # EASY-INSTALL-ENTRY-SCRIPT: 'alot==0.9.1','console_scripts','alot'
__requires__ = 'alot==0.9' __requires__ = 'alot==0.9.1'
import re import re
import sys import sys
from pkg_resources import load_entry_point from pkg_resources import load_entry_point
@ -8,5 +8,5 @@ from pkg_resources import load_entry_point
if __name__ == '__main__': if __name__ == '__main__':
sys.argv[0] = re.sub(r'(-script\.pyw?|\.exe)?$', '', sys.argv[0]) sys.argv[0] = re.sub(r'(-script\.pyw?|\.exe)?$', '', sys.argv[0])
sys.exit( sys.exit(
load_entry_point('alot==0.9', 'console_scripts', 'alot')() load_entry_point('alot==0.9.1', 'console_scripts', 'alot')()
) )