From mboxrd@z Thu Jan 1 00:00:00 1970 From: Friedrich Delgado Friedrichs Subject: Re: Mairix & Mutt Date: Sat, 27 Sep 2008 13:18:17 +0200 Message-ID: <20080927111817.GA15675@taupan.ath.cx> References: <20080921045854.GA24656@thinkpad.adamsinfoserv.com> Reply-To: friedel@nomaden.org Mime-Version: 1.0 Content-Type: multipart/mixed; boundary="===============1902311499==" Return-path: Received: from mailman by lists.gnu.org with tmda-scanned (Exim 4.43) id 1KjXmn-0008Kb-Ld for emacs-orgmode@gnu.org; Sat, 27 Sep 2008 07:16:29 -0400 Received: from exim by lists.gnu.org with spam-scanned (Exim 4.43) id 1KjXml-0008K4-Ou for emacs-orgmode@gnu.org; Sat, 27 Sep 2008 07:16:28 -0400 Received: from [199.232.76.173] (port=56867 helo=monty-python.gnu.org) by lists.gnu.org with esmtp (Exim 4.43) id 1KjXml-0008Jy-Gg for emacs-orgmode@gnu.org; Sat, 27 Sep 2008 07:16:27 -0400 Received: from dudelab.org ([212.12.33.202]:19025 helo=mail.dudelab.org) by monty-python.gnu.org with esmtps (TLS-1.0:DHE_RSA_AES_256_CBC_SHA1:32) (Exim 4.60) (envelope-from ) id 1KjXmk-0006Ya-T6 for emacs-orgmode@gnu.org; Sat, 27 Sep 2008 07:16:27 -0400 Received: from abrasax.taupan.ath.cx (p5B10EBE2.dip.t-dialin.net [91.16.235.226]) (using TLSv1 with cipher DHE-RSA-AES256-SHA (256/256 bits)) (Client CN "Friedrich Delgado Friedrichs", Issuer "User CA" (verified OK)) by mail.dudelab.org (Postfix) with ESMTP id 1E4E5228148 for ; Sat, 27 Sep 2008 13:15:28 +0200 (CEST) In-Reply-To: <20080921045854.GA24656@thinkpad.adamsinfoserv.com> List-Id: "General discussions about Org-mode." List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Sender: emacs-orgmode-bounces+geo-emacs-orgmode=m.gmane.org@gnu.org Errors-To: emacs-orgmode-bounces+geo-emacs-orgmode=m.gmane.org@gnu.org To: emacs-orgmode@gnu.org --===============1902311499== Content-Type: multipart/signed; micalg=pgp-sha1; protocol="application/pgp-signature"; boundary="IrhDeMKUP4DT/M7F" Content-Disposition: inline --IrhDeMKUP4DT/M7F Content-Type: multipart/mixed; boundary="SLDf9lqlvOQaIe6s" Content-Disposition: inline --SLDf9lqlvOQaIe6s Content-Type: text/plain; charset=us-ascii Content-Disposition: inline Content-Transfer-Encoding: quoted-printable Hi! I was thinking about how to interface mutt and org-mode for quite some time now but didn't really get around to it. I've tried to use many emacs MUAs for this purpose (mh-e, wanderlust, mew and finally the great scary GNUs) but they're not quite to my taste. Your proposal gave me the necessary hacktivation energy to come up with my version of this prototype. I also borrowed some of your code, but backported it to perl 5.8. Russell Adams schrieb: > The workflow goes like this: > > - Reading email in Mutt, in index or pager > - Trigger script via M-o in Mutt > - Middle-click into my org-mode buffer pasting the link > - Later visit the link and execute mairix to find message by ID > - In current Mutt session, use M-` to jump to search folder and read > message ---Zitatende--- Those are a few steps too many for me. I wanted to press t in the index or pager and then pop up an emacs window with remember. As org-annotation-helper.el does this already, I decided to use it. Also mutt is able to search its own mailboxes, not as flexible as mairix, because it can only search a single folder, but I only really want to link back to a certain mail for now. I also had a long conversation with pdmef on channel #mutt on freenode.net, who gave me the two crucial ideas how to configure this in mutt. The main idea is to use the path-type variable record to get the name of the current folder and store it in the two keyboard macros. The keyboard macros change every time you change a folder in mutt. This is a rough prototype still. I'd like to get rid of the (y/n) prompt and therefore I'd like to have a link-type "mutt:" in org, which means some of the functionality of the perl-script would have to get implemented in emacs-lisp. But that would give me the benefit of a customisable terminal and maybe get everything a bit less hairy... You'll notice that calling mutt with a mail is not very straight forward. In theory, mutt -f $mailbox -e "push ~i$msgid" should be sufficient. However if it's started via xterm -e, the keystrokes don't arrive, maybe because xterm does some terminal initialisations after mutt has started (or my window manager sends a resize signal a bit too late, something like that). That's why I'm writing the keystrokes to a temporary file. Not elegant, but does the job. Maybe we get the next guy inspired to hack on this now :) --=20 Friedrich Delgado Friedrichs Laziness led to the invention of the most useful tools. --SLDf9lqlvOQaIe6s Content-Type: text/x-perl; charset=us-ascii Content-Disposition: attachment; filename="mutt2remember.pl" #!/usr/bin/perl # $Id: mutt2remember.pl,v 1.4 2008/09/27 11:15:04 friedel Exp $ # Variations on a theme given by Russell Adams http://lists.gnu.org/archive/html/emacs-orgmode/2008-09/msg00300.html my $terminal="xterm -e"; # Install: # ======== # 1.) put the following in your muttrc: my $muttrc_snippet = <t \"set pipe_decode=no;set wait_key=nomutt2remember.pl remember \$recordset wait_key=\$my_wait_key ;set pipe_decode=\$my_pipe_decode\" \"remember mail in emacs\"; \ macro index,pager n \"set pipe_decode=no;set wait_key=nomutt2remember.pl annotation \$recordset wait_key=\$my_wait_key ;set pipe_decode=\$my_pipe_decode\" \"copy url to mail in emacs\"; \ set record=\$my_record;" END # 2) put this file into your $HOME/bin and make it executable. # 3) make sure org-annotation-helper.el is loaded in your org config # 4) optionally: set $terminal above to something you prefer. # 5) press n in the pager or index to annotate a mail url, # press t to *remember* it # 6) follow the generated link in emacs to open the mail in mutt. use strict; use warnings; use URI::Escape qw/ uri_escape /; use File::Temp qw/ mkstemp /; my $action=$ARGV[0]; my $folder=$ARGV[1]; if ($action eq "remember" or $action eq "annotation") { my ( $Subject , $From , $MID ); while () { chomp; if (/^Subject: /) { ( $Subject ) = $_ =~ m/^Subject: (.*)$/; } if (/^From: /) { ( $From ) = $_ =~ m/^From: (.*)$/; } if (/^Message-ID:\s*/) { ( $MID ) = $_ =~ m/^Message-ID:\s*<(.*)>\s*$/; } if (/^$/) { last; # Header ends on first blank line } } $From = uri_escape($From); $Subject = uri_escape($Subject); $folder =~ tr/=/+/; my $uri = "shell:" . $terminal . " mutt2remember.pl open " . $folder . " " . $MID; $uri = uri_escape($uri); my $Link = $action . ":" . $uri . "::remember::Mail From $From: $Subject"; system ("emacsclient", "--eval", "(progn (bzg/org-annotation-helper \"$Link\") nil)"); } elsif ($action eq "open") { my $msgid=$ARGV[2]; my ($tmp, $tmpfile) = mkstemp(($ENV{TMP} or "/tmp") . "/mutt2rememberXXXXXXXX"); printf $tmp "push \"~i$msgid\""; system("mutt", "-f", $folder, "-e", "source $tmpfile"); close $tmp; unlink $tmpfile; } --SLDf9lqlvOQaIe6s-- --IrhDeMKUP4DT/M7F Content-Type: application/pgp-signature; name="signature.asc" Content-Description: Digital signature Content-Disposition: inline -----BEGIN PGP SIGNATURE----- Version: GnuPG v1.4.9 (GNU/Linux) iEYEARECAAYFAkjeFnkACgkQCTmCEtF2zEB0zwCglDuv7V8Nyw6DeUeyD1hQgl72 yD8AoKPD8hVwZ9ChBrl17FHlxn1/Fjsc =v5Bg -----END PGP SIGNATURE----- --IrhDeMKUP4DT/M7F-- --===============1902311499== Content-Type: text/plain; charset="us-ascii" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit Content-Disposition: inline _______________________________________________ Emacs-orgmode mailing list Remember: use `Reply All' to send replies to the list. Emacs-orgmode@gnu.org http://lists.gnu.org/mailman/listinfo/emacs-orgmode --===============1902311499==--