Re: Setting subscribe/list within muttrc (using IMAP) [SOLVED]
* Michelle Konzack <linux4michelle@xxxxxxxxxx> [2007-08-29 19:12 +0200]:
> Am 2007-08-24 23:49:36, schrieb David J. Weller-Fahy:
> > Perhaps I'm looking for a feature that doesn't exist, and I'm almost
> > certainly missing something simple, but here's the background:
> <snip>
>
> It seems there is no way in mutt...
That is the way it seemed. However, after digging into the archives a
bit deeper, and playing with a patch I found, I've come up with a
solution that works for me (it does require patching, though). Details
follow.
Inspiration came from:
<http://marc.info/?l=mutt-users&m=99616338121641&w=2>
The patch exports the current mailbox name to an environment variable,
then I source a shell script as part of a folder hook. The shell script
parses the mailbox name to determine whether it is a list mailbox, then,
if it is, outputs the muttrc commands I use for lists. I've tested this
with all the lists I subscribe to, and it works with one caveat:
All my lists are stored in the format =lists.list-name, so
mutt-users is in =lists.mutt-users. While this makes it easy for my
script to parse the name, it also means that my script/setup may not
work for you.
Hope this helps... I know it doesn't do everything, but it gets me a
little closer. ;]
> I am too using a simplified code sniplet of "uw-imap" to get all
> directories (and number of NEW/READ messages ) from an imap-server...
Would you mind sharing your sniplet? It may be a bit better than mine.
Regards,
--
dave [ please don't CC me ]
# vim:ft=diff:
This is a patch to place the current mailbox path in an environment variable
whenever a folder-hook is called. This (trivial) patch was based on a
message[1] on the mutt mailing list:
[1]: http://marc.info/?l=mutt-users&m=99616338121641&w=2
In fact, the ONLY differences are the name of the variable, and adding the
patch name to PATCHES. ;]
diff -r f467353f5657 PATCHES
--- a/PATCHES Sat Mar 31 18:50:39 2007 -0700
+++ b/PATCHES Wed Aug 29 22:09:38 2007 +0200
@@ -0,0 +1,1 @@
+patch-tip-20070829-env_current_mailbox
diff -r 3f8829e739e9 hook.c
--- a/hook.c Tue Aug 28 11:33:52 2007 -0700
+++ b/hook.c Thu Aug 30 22:08:56 2007 +0200
@@ -282,6 +282,8 @@ void mutt_folder_hook (char *path)
BUFFER err, token;
char buf[STRING];
+ setenv( "MUTT_CURRENTMAILBOX", path, 1 );
+
current_hook_type = M_FOLDERHOOK;
err.data = buf;
#!/bin/sh
# .mutt/rc.testforlist.sh
# This will only work if:
# - $MUTT_CURRENTMAILBOX contains the name of the current mailbox in mutt.
# - Your list directory structure looks like the following:
# lists
# lists.aklug
# lists.mutt-users
# lists.resnet-l
# lists.[mailing list name]
#
# If your structure is not like the above, then tweak the code heavily.
mailbox=`echo $MUTT_CURRENTMAILBOX | sed -r -e "s/^imaps:\/\/[^\/]+\///"`
listpfx=`echo $mailbox | cut -d . -f 1`
if test "$listpfx" = "lists" ; then
test "$mailbox" != "lists" && echo "subscribe ${mailbox#lists.}"
echo "folder-hook +$mailbox set from=dave-$( echo $mailbox | tr '.' '-'
)@weller-fahy.com"
fi