Ryan Wilcox avatar Ryan Wilcox committed 7bf9066

script so I can reference mail messages from my diary

Comments (0)

Files changed (2)

bin/mutt_construct_notmuch_reference_query.py

+#!/usr/bin/env python
+
+import sys
+import email.parser
+
+def parse_message(raw):
+	 message = email.parser.Parser().parsestr(raw, headersonly=True)
+	 return message.get("Message-ID")[1:-1], message.get("Subject")
+
+raw = sys.stdin.read()
+message_id, subject = parse_message(raw)
+
+print """> Subject: %s
+> REFERENCE: notmuch search --output=files id:%s""" % (subject, message_id)
 
 macro index,pager g0 "<change-folder>=INBOX<enter>" "Go to inbox"
 macro index,pager ,e "<enter-command>unset wait_key<enter><pipe-message>bbedit -t 'message.mutt' --view-top --clean<enter><enter-command>set wait_key<enter>"
+macro index,pager ,m "<enter-command>unset wait_key<enter><pipe-message>python ~/bin/mutt_construct_notmuch_reference_query.py | pbcopy<enter><enter-command>set wait_key<enter>"
 macro index,pager ,h "<enter-command>unset wait_key<enter><pipe-message>python ~/bin/mutt_view_html.py<enter><enter-command>set wait_key<enter>"
 macro index,pager gt "<change-folder>=[Gmail]/Sent Mail<enter>" "Go to sent mail"
 
 
 
 # ################################ LABELS ##############################################
-set my_editor="~/bin/bb" 
+set my_editor="~/bin/bb"
 
 macro index y "<enter-command>set editor=\"~/bin/editlabel.pl edit\"\n\
 <tag-prefix><edit><next-undeleted>\
 <enter-command>set editor=\"$my_editor\"\n" "Clean labels"
 
 macro index YL "<enter-command>set editor=\"~/bin/editlabel.pl list\"\n\
-<tag-prefix><edit>\ <enter-command>set editor=\"$my_editor\"\n" "List labels" 
+<tag-prefix><edit>\ <enter-command>set editor=\"$my_editor\"\n" "List labels"
 
 macro index YQ "<limit>~y " "Limit view to label"
-macro index YY "<limit>all<enter>" "View all messages"
+macro index YY "<limit>all<enter>" "View all messages"
Tip: Filter by directory path e.g. /media app.js to search for public/media/app.js.
Tip: Use camelCasing e.g. ProjME to search for ProjectModifiedEvent.java.
Tip: Filter by extension type e.g. /repo .js to search for all .js files in the /repo directory.
Tip: Separate your search with spaces e.g. /ssh pom.xml to search for src/ssh/pom.xml.
Tip: Use ↑ and ↓ arrow keys to navigate and return to view the file.
Tip: You can also navigate files with Ctrl+j (next) and Ctrl+k (previous) and view the file with Ctrl+o.
Tip: You can also navigate files with Alt+j (next) and Alt+k (previous) and view the file with Alt+o.