Announcements and discussions for Gnus, the GNU Emacs Usenet newsreader
 help / color / mirror / Atom feed
* nnmaildir nested Maildirs workaround
@ 2018-09-18 15:25 Thomas Schneider
  2018-09-22  8:20 ` Saša Janiška
  0 siblings, 1 reply; 2+ messages in thread
From: Thomas Schneider @ 2018-09-18 15:25 UTC (permalink / raw)
  To: info-gnus-english

Hello,

I wanted to use Gnus also for reading mails.  For historical reasons, my
Maildirs are nested (e. g. ~/.maildir/work/INBOX/foo/bar/{cur,new,tmp})
and synced to various IMAP servers.  I still wanted to keep the Maildirs
local, and keep my nested structure, but nnmaildir only supports a flat
hierarchy without leading dots (as mbsync would create them).

Long story short, I now have ~/.nnmaildir with a bunch of symlinks
created by the following script.  It could be better, but for now this
does the trick.

---
#!/usr/bin/env python3

import os
import os.path
import sys

try:
    maildir = os.environ['MAILDIR']
except KeyError:
    if os.path.exists(os.path.expanduser('~/.maildir')):
        maildir = os.path.expanduser('~/.maildir')
    elif os.path.exists(os.path.expanduser('~/Maildir')):
        maildir = os.path.expanduser('~/Maildir')
    else:
        print('no maildir found', file = sys.stderr)
        sys.exit(1)

maildirs = {d for d, dirs, _ in os.walk(maildir)
            if 'cur' in dirs} # cur shall be sufficient to make a dir a maildir

nnm = os.path.expanduser('~/.nnmaildir')
if not os.path.exists(nnm):
    os.mkdir(nnm, mode = 0o700)

for d in maildirs:
    n = d[len(maildir) + 1:].replace('/', '.')
    dst = os.path.join(nnm, n)
    if os.path.exists(dst):
        continue
    src_rel = os.path.relpath(d, os.path.dirname(dst))
    os.symlink(src_rel, dst)
---

^ permalink raw reply	[flat|nested] 2+ messages in thread

* Re: nnmaildir nested Maildirs workaround
  2018-09-18 15:25 nnmaildir nested Maildirs workaround Thomas Schneider
@ 2018-09-22  8:20 ` Saša Janiška
  0 siblings, 0 replies; 2+ messages in thread
From: Saša Janiška @ 2018-09-22  8:20 UTC (permalink / raw)
  To: info-gnus-english

Thomas Schneider <qsx@chaotikum.eu> writes:

> Hello,

> I wanted to use Gnus also for reading mails.  For historical reasons, my
> Maildirs are nested (e. g. ~/.maildir/work/INBOX/foo/bar/{cur,new,tmp})
> and synced to various IMAP servers.  I still wanted to keep the Maildirs
> local, and keep my nested structure, but nnmaildir only supports a flat
> hierarchy without leading dots (as mbsync would create them).

After I decided to use org-mode as input format for my web content I
certainly wanted to settle on Gnus as my only mailer, but had kind of
doubt in its robustness since several times my sent mail was lost (sent
a post to this list about it, but it never went through) when using
nnimap back-end and that's why I wanted to move to mu4e, but then
decided to stay with Gnus by using nnmaildir while the mail was fetched
via getmail (along with bogofilter, clamav and maildrop delivery).

So far, everything looks fine, but your script does help to make Maildir
hierarchy seen by Gnus. Thank you! (I did create some symlinks manually
when starting, but to complete the setup, the script does nice job.)


Sincerely,
Gour

-- 
It is far better to discharge one's prescribed duties, even though
faultily, than another's duties perfectly. Destruction in the course
of performing one's own duty is better than engaging in another's duties,
for to follow another's path is dangerous.



^ permalink raw reply	[flat|nested] 2+ messages in thread

end of thread, other threads:[~2018-09-22  8:20 UTC | newest]

Thread overview: 2+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2018-09-18 15:25 nnmaildir nested Maildirs workaround Thomas Schneider
2018-09-22  8:20 ` Saša Janiška

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).