From mboxrd@z Thu Jan 1 00:00:00 1970 From: Friedrich Delgado Friedrichs Subject: Re: integration between Org, remember, and Mutt Date: Wed, 11 Nov 2009 19:53:12 +0100 Message-ID: <20091111185312.GA23184@taupan.ath.cx> References: <20091031171257.GA31830@usha.takhisis.invalid> <20091101152335.GA22730@taupan.ath.cx> <20091101161414.GA25912@usha.takhisis.invalid> <20091101165430.GA26622@taupan.ath.cx> <20091101174155.GA10572@usha.takhisis.invalid> Reply-To: friedel@nomaden.org Mime-Version: 1.0 Content-Type: text/plain; charset=us-ascii Return-path: Received: from mailman by lists.gnu.org with tmda-scanned (Exim 4.43) id 1N8IJl-0002JN-E6 for emacs-orgmode@gnu.org; Wed, 11 Nov 2009 13:53:21 -0500 Received: from exim by lists.gnu.org with spam-scanned (Exim 4.43) id 1N8IJg-0002Ck-NK for emacs-orgmode@gnu.org; Wed, 11 Nov 2009 13:53:20 -0500 Received: from [199.232.76.173] (port=53659 helo=monty-python.gnu.org) by lists.gnu.org with esmtp (Exim 4.43) id 1N8IJg-0002CJ-FW for emacs-orgmode@gnu.org; Wed, 11 Nov 2009 13:53:16 -0500 Received: from dudelab.org ([212.12.33.202]:17027 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 1N8IJf-00079q-Mh for emacs-orgmode@gnu.org; Wed, 11 Nov 2009 13:53:16 -0500 Received: from abrasax.taupan.ath.cx (p5DE89263.dip.t-dialin.net [93.232.146.99]) (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 A6D8E228148 for ; Wed, 11 Nov 2009 19:53:41 +0100 (CET) Content-Disposition: inline In-Reply-To: <20091101174155.GA10572@usha.takhisis.invalid> 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 Hi, again! Ok, today I took some time to reconsider my integration of mutt with org-mode. One move was to put my archive of private mail onto an imap server (with regular mirrors to my local harddisk via rsync, in case the network breaks down), and the relevant steps in my mutt configuration. The other side of this is that I simplified my mail links with the 'mutt:' link type. This is what I use (you probably won't like this, but it serves to illustrate my approach). In mutt, I use the following keys: ,---- # Save EVERYTHING in +Archive, thanks Merlin Mann! :) save-hook . +Archive set my_pipe_decode=$pipe_decode; set my_wait_key=$wait_key; macro index,pager r "set pipe_decode=no;set wait_key=nomutt2remember.pl remember +Archiveset 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 store-link +Archiveset wait_key=\$my_wait_key ;set pipe_decode=\$my_pipe_decode" "copy url to mail in emacs"; # How do I search for message with same Message-ID in another folder? That would be handy for the following macro: macro index,pager a "+Archive" `---- I used to have a more complicated setup, which also figured out the current folder with some clever hooks and lots of trickery, however this was annoying, since I had to - save the mail - go to the new folder, find that mail again - then press my hotkey This way (with just a single archive folder) I can just press n and then save the mail, and I don't have to find the mail again, just to get the proper link. It seems like this isn't fully scriptable in mutt, at least I didn't manage to come up with a macro that does all of the following in one go: - save mail to folder, allowing the user to specify any folder - then somehow save the name of *that* folder and use it to generate the link for emacs Then I have a perl script mutt2remember.pl which handles both directions, adapted from a proposal by Russell Adams: ,----[ mutt2remember.pl ] #!/usr/bin/perl # $Id: mutt2remember.pl,v 1.5 2008/09/27 11:25:41 friedel Exp friedel $ # Variations on a theme given by Russell Adams http://lists.gnu.org/archive/html/emacs-orgmode/2008-09/msg00300.html $ENV{TMPDIR} = $ENV{TMP}; # 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 store-link \$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-protocol.el is loaded in your org config # 4) press n in the pager or index to annotate a mail url, # press t to *remember* it # 5) follow the generated link in emacs to open the mail in mutt. use strict; use warnings; use URI::Escape qw/ uri_escape uri_escape_utf8 /; use File::Temp qw/ mkstemp /; use Encode qw/encode decode/; my $action=$ARGV[0]; my $folder=$ARGV[1]; if ($action eq "remember" or $action eq "store-link") { my ( $Subject , $From , $MID ); while () { chomp; if (/^Subject: /i) { ( $Subject ) = $_ =~ m/^Subject: (.*)$/; } if (/^From: /i) { ( $From ) = $_ =~ m/^From: (.*)$/; } if (/^Message-ID:\s*/i) { ( $MID ) = $_ =~ m/^Message-ID:\s*<(.*)>\s*$/i; } if (/^$/) { last; # Header ends on first blank line } } $From = uri_escape_utf8(decode('MIME-Header', $From)); $Subject = uri_escape_utf8(decode('MIME-Header', $Subject)); $folder =~ tr/=/+/; my $uri = "mutt:" . $folder . " " . $MID; $uri = uri_escape_utf8($uri); my $Link = "org-protocol://" . $action . "://" . $uri . "/Mail From $From: $Subject"; system ("emacsclient", $Link); } 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; } `---- And finally the relevant parts of my org-mode config (thanks to you): ,---- (defcustom org-mutt-link-terminal-emulator "xterm -e" "Terminal emulator to use for opening running mutt" :group 'org-config :type 'string) (org-add-link-type "mutt" 'open-mail-in-mutt) (defun open-mail-in-mutt (folder+message-id) (message folder+message-id) (save-window-excursion (save-excursion (shell-command (concat (format "%s mutt2remember.pl open %s &" org-mutt-link-terminal-emulator folder+message-id)))))) `---- I think you will find this lacking since it doesn't support searching, but only links to specific mails in specific folders, which are hardwired. It's good enough for me, and I think I won't need to improve this for the next few years now! ;) Maybe this gives you an idea. Stefano Zacchiroli schrieb: > Fair enough. > However, to go forward, we need to establish some kind of goal. > > In particular, what do you consider lacking in the solution I proposed? > Similarly, what your solution has that mine lacks? I believe it is time > to find a merger between the various available solutions ... ---Zitatende--- -- Friedrich Delgado Friedrichs TauPan on Ircnet and Freenode ;)