aboutsummaryrefslogtreecommitdiff
path: root/bin/mutt-remember-mail
blob: 6113e7a52f3d72dc81efdd57b7bc034c3a80fcde (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
#!/usr/bin/env python3

import sys
import email
import subprocess
import urllib.parse

# Parse the email from standard input
message_bytes = sys.stdin.buffer.read()
message = email.message_from_bytes(message_bytes)

# Grab the relevant message headers
message_id = urllib.parse.quote(message['message-id'][1:-1])
subject = message['subject']
h_from = message['from']

# Ask emacsclient to save a link to the message
subprocess.Popen([
    'emacsclient', '-c',
    f'org-protocol://capture?template=m&url=message://id:{message_id}&title={subject} from {h_from}'
])
nihil fit ex nihilo