]> git.donarmstrong.com Git - bin.git/blob - remember_mail
add reset usb bus command
[bin.git] / remember_mail
1 #!/usr/bin/perl -w
2 #
3 # Helper for mutt to remember mails in Emacs' Org mode
4 #
5 # Copyright: © 2009-2010 Stefano Zacchiroli <zack@upsilon.cc> 
6 # License: GNU General Public License (GPL), version 3 or above
7 #
8 # Example of mutt macro to invoke this hitting ESC-R (to be put in ~/.muttrc):
9 #  macro index \eR "|~/bin/remember-mail\n"
10
11 use strict;
12 use Mail::Internet;
13 use URI::Escape;
14
15 my $msg = Mail::Internet->new(\*STDIN);
16 $msg->head->get('message-id') =~ /^<(.*)>$/;
17 my $mid = $1;
18 my $subject = $msg->head->get('subject') || "";
19 my $from = $msg->head->get('from') || "";
20 chomp ($subject, $from);
21 my $note_body = uri_escape("  Subject: $subject\n    From: $from");
22
23 my @EMACS_OPTS;
24 if (defined $ENV{DISPLAY} and length($ENV{DISPLAY})) {
25     @EMACS_OPTS = qw(-c)
26 } else {
27     @EMACS_OPTS = qw(-t)
28 }
29 exec "emacsclient", @EMACS_OPTS, "org-protocol://capture?template=m&url=mutt:$mid&title=mail&body=$note_body";