On Mon, May 20, 2002 at 09:36:04AM +0100, Bruno Postle wrote: > On Mon 20-May-2002 at 05:50:38 +1000, Iain Truskett wrote: > > * Anthony Towns ([EMAIL PROTECTED]) [20 May 2002 17:38]: > > > First, has anyone done this before? Is there a FAQ or HOWTO I could > > > be reading? > > Examine the 'limit' command (bound by default to 'l' in the index > > screen). > The limit command is perfect for this, but it only works on one mailbox > and mailboxes don't scale too well - Ok for five thousand messages, > _not_ so ok for a million.
It's not that okay with five thousand messages, and it takes minutes to open up a folder that's something like half my archive. It's not really the way I'd rather work either: I'd rather tell it what I want, wait if necessary, then see the messages, rather than wait while it shows me all the messages I might want, then tell it what I'm looking for. Limit's nice, but it's not what I'm looking for. On Mon, May 20, 2002 at 11:47:59AM -0400, Adam Shostack wrote: > On Mon, May 20, 2002 at 06:39:58AM -0500, Patrick wrote: > > Look at grepmail, grepmail.sourceforge.net. Grepmail doesn't seem to support Maildir, which I'm inclined to stick with. I'm really more interested in making something-like-grepmail more comfortable to use with mutt, too: I'm pretty sure I can write something-like-grepmail myself to my satisfaction. > One important difference is that vfolders are built around pre-built > indexes, making them more efficient than grepping hundreds of megs of > mail. Having watched people use vfolders, it makes me seriously > consider switching over to evolution. Right. The main thing is that as well as the straight out mbox/Maildir, there's a nice binary index of all the messages that's quick to look up. > However, I can't find a decent technical overview of the system, other > than the source. Likewise. file(1) couldn't work out what format the index was in either, so I gave up. :) Bruno Postle pointed out some similar stuff for mutt, though. Apparently Michael Elkins has a patch that adds "header caching support for Maildir folders", which is a start. It's at: http://www.cs.hmc.edu/~me/mutt/patch-1.5.0.me.hcache.8 Bruno's posted a "grep" script which makes use of this stuff too (back in January), which is at: http://groups.yahoo.com/group/mutt-users/message/27023 On Mon, May 20, 2002 at 08:23:11AM -0500, David T-G wrote: > % thinking that vFolders might be the answer. So, I've been trying to figure > % out some way of doing the same sort of thing in mutt. > Interesting concept... Since I have no interest in installing Evo, can > you point me somewhere to learn more about their concept and > implementation? The concept is basically the same as the "limit" stuff, although the interface allows you to make a "mailbox" that's a vfolder -- so you can just change to it rather than having to change to the big folder, then limit it by hand. You can give them names and such too, which is nice if you do this sort of thing regularly, and makes it worthwhile to have queries like "All unread messages to mailing lists in the past hour", if that's what you're into. There arn't any technical docs about the implementation afaik, but it's basically "make all accesses to the mail really fast by using indexes", then have at it. It's not clear what the indexes are, but I figure I can fake that with some scripts well enough for my own purposes. Apparently one of the nicer ways to use it is for incoming mail, but that's probably a lot tougher to adapt mutt for, and not really what I'm interested in, personally. > I do know, though, that I've been itching for a real RDBMS back-end > for mailboxes [...] I want to keep mine in the filesystem: my other annoyance is that I want to be able to handle my mail without any stress on either of two computers which aren't always connected to each other. I've tried this before, and I tend to have problems when I read some mail on one machine, and archive it; then read it on the other and archive it again. I think Maildir will be a part of my solution when I find one though. > I had been tinkering with an idea for approaching that by having one > single, potentially huge, canonical Maildir containing every message, > and then "virtual Maildirs" (which, BTW, need only the cur/ subdir) > with symlinks that point into the canonical dir. Right, this is more or less what I'm planning on doing, except that my virtual Maildirs will be created on demand, and cleaned up when they're not used. Also, I found mutt just ignored symlinks, so I used hardlinks instead. > % What I can't figure out is how to run that script and make mutt look at > % the output in a reasonably effective way. What I'd _like_ is to be able > % to write a macro that asks me: > % "What email address:" > % then runs <change-folder>`/home/aj/mail/bin/query-by-addr "$result"`. > Why not just fire off a subprocess? Because then I'll end up with fifty mutts one on top of the other as I refine my query, which will annoy me to no end, especially when I decide to quit mutt (or when I want to look back at one of the folders I was in before I tried my query and find that I haven't saved where I'm up to). So, since there doesn't seem to be an easy way of doing what I want, I've tried hacking mutt a little, along the lines of my original post. My .muttrc (on the machine I *don't* use for mail :) now contains the lines: set uservar_1="`~/mail/bin/create_vfolder`" macro index Q "<change-folder-readonly><%uservar_1><enter> !~/mail/bin/query <%uservar_1> fake_inbox " (second line separated for clarity, rejoin it for correct parsing) Basically, I made a handful of new variables (uservar_1 through uservar_5), that don't mean anything to the rest of mutt, and changed the parser so it would replace <%variable> with the contents of <variable>, whatever that may be. The patch (against 1.3.28) is as follows: diff -urb mutt-1.3.28.orig/globals.h mutt-1.3.28/globals.h --- mutt-1.3.28.orig/globals.h Fri Jan 4 06:57:19 2002 +++ mutt-1.3.28/globals.h Mon May 20 23:14:20 2002 @@ -67,6 +67,8 @@ WHERE char *MhUnseen; WHERE char *MsgFmt; +WHERE char *UserVar[5]; + #ifdef USE_SOCKET WHERE char *Preconnect INITVAL (NULL); WHERE char *Tunnel INITVAL (NULL); diff -urb mutt-1.3.28.orig/init.c mutt-1.3.28/init.c --- mutt-1.3.28.orig/init.c Mon Feb 11 19:58:54 2002 +++ mutt-1.3.28/init.c Wed May 22 00:37:40 2002 @@ -105,6 +105,57 @@ return (-1); } +/* given the variable ``s'', return it's value as a string, or NULL if + * not found, or not possible. Note the string may not be modified, or + * freed, or so forth, and may not remain valid forever. + */ +char *mutt_option_value (char *s, int len) +{ + int i; + char *quadvals[] = { "no", "yes", "ask-no", "ask-yes" }; + + for (i = 0; MuttVars[i].option; i++) + if (!ascii_strncasecmp (s, MuttVars[i].option, len) && + mutt_strlen (MuttVars[i].option) == len) + { + if (MuttVars[i].type == DT_SYN) + i = mutt_option_index ((char *) MuttVars[i].data); + break; + } + + if (i == -1 || !MuttVars[i].option) + return NULL; + + switch ( DTYPE(MuttVars[i].type) ) + { + case DT_BOOL: /* boolean option */ + return option (MuttVars[i].data) ? "yes" : "no"; + case DT_QUAD: /* quad-option (yes/no/ask-yes/ask-no) */ + return quadvals[quadoption (MuttVars[i].data)]; + + case DT_STR: /* a string */ + case DT_PATH: /* a pathname */ + { + char **p = (char **) MuttVars[i].data; + if (!p || !*p || !**p) return NULL; + return *p; + } + + case DT_NUM: /* a number */ + case DT_SORT: /* sorting methods */ + case DT_RX: /* regular expressions */ + case DT_MAGIC: /* mailbox type */ + case DT_ADDR: /* e-mail address */ + /* all these are just too hard :) */ + return NULL; + + case DT_SYN: /* synonym for another variable */ + default: + /* XXX: shouldn't ever happen */ + return NULL; + } +} + int mutt_extract_token (BUFFER *dest, BUFFER *tok, int flags) { char ch; diff -urb mutt-1.3.28.orig/init.h mutt-1.3.28/init.h --- mutt-1.3.28.orig/init.h Thu Feb 28 18:24:13 2002 +++ mutt-1.3.28/init.h Mon May 20 23:10:17 2002 @@ -2366,6 +2366,11 @@ ** Controls whether mutt writes out the Bcc header when preparing ** messages to be sent. Exim users may wish to use this. */ + { "uservar_1", DT_STR, R_NONE, UL &UserVar[0], UL 0 }, + { "uservar_2", DT_STR, R_NONE, UL &UserVar[1], UL 0 }, + { "uservar_3", DT_STR, R_NONE, UL &UserVar[2], UL 0 }, + { "uservar_4", DT_STR, R_NONE, UL &UserVar[3], UL 0 }, + { "uservar_5", DT_STR, R_NONE, UL &UserVar[4], UL 0 }, /*--*/ { NULL } }; diff -urb mutt-1.3.28.orig/keymap.c mutt-1.3.28/keymap.c --- mutt-1.3.28.orig/keymap.c Wed Oct 17 00:29:27 2001 +++ mutt-1.3.28/keymap.c Wed May 22 00:37:17 2002 @@ -253,6 +253,13 @@ return NULL; } +static void push_literal_string (char *s) +{ + char *p = s + mutt_strlen (s) - 1; + while (p >= s) + mutt_ungetch (*p--, 0); +} + static void push_string (char *s) { char *pp, *p = s + mutt_strlen (s) - 1; @@ -277,6 +284,16 @@ } l = p - pp + 1; + + if (pp[1] == '%') + { + char *val = mutt_option_value (pp+2, l-3); + if (val) + push_literal_string (val); + p = pp - 1; + continue; + } + for (i = 0; KeyNames[i].name; i++) { if (!ascii_strncasecmp (pp, KeyNames[i].name, l)) diff -urb mutt-1.3.28.orig/protos.h mutt-1.3.28/protos.h --- mutt-1.3.28.orig/protos.h Thu Jan 17 06:44:25 2002 +++ mutt-1.3.28/protos.h Tue May 21 02:34:21 2002 @@ -479,4 +479,5 @@ void ci_bounce_message (HEADER *, int *); int ci_send_message (int, HEADER *, char *, CONTEXT *, HEADER *); +char *mutt_option_value (char*, int); I haven't setup my archive to see how pleasant it is to use yet. Cheers, aj -- Anthony Towns <[EMAIL PROTECTED]> <http://azure.humbug.org.au/~aj/> I don't speak for anyone save myself. GPG signed mail preferred. ``BAM! Science triumphs again!'' -- http://www.angryflower.com/vegeta.gif
msg28273/pgp00000.pgp
Description: PGP signature