#!/usr/bin/perl -w # # Helper for mutt to remember mails in Emacs' Org mode # # Copyright: © 2009-2010 Stefano Zacchiroli # License: GNU General Public License (GPL), version 3 or above # # Example of mutt macro to invoke this hitting ESC-R (to be put in ~/.muttrc): # macro index \eR "|~/bin/remember-mail\n" use strict; use Mail::Internet; use URI::Escape; my $msg = Mail::Internet->new(\*STDIN); $msg->head->get('message-id') =~ /^<(.*)>$/; my $mid = $1; my $subject = $msg->head->get('subject') || ""; my $from = $msg->head->get('from') || ""; chomp ($subject, $from); my $note_body = uri_escape(" Subject: $subject\n From: $from"); my @EMACS_OPTS; if (defined $ENV{DISPLAY} and length($ENV{DISPLAY})) { @EMACS_OPTS = qw(-c) } else { @EMACS_OPTS = qw(-t) } exec "emacsclient", @EMACS_OPTS, "org-protocol://capture?template=m&url=mutt:$mid&title=mail&body=$note_body";