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

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).