Skip to content

Commit

Permalink
Merge pull request #1362 from bmccary/master
Browse files Browse the repository at this point in the history
~ expansion for .config/alot/config
  • Loading branch information
lucc authored Jan 21, 2019
2 parents 6bb18fa + a2ff114 commit 8c25bed
Show file tree
Hide file tree
Showing 4 changed files with 18 additions and 18 deletions.
4 changes: 2 additions & 2 deletions alot/defaults/alot.rc.spec
Original file line number Diff line number Diff line change
Expand Up @@ -312,14 +312,14 @@ thread_focus_linewise = boolean(default=True)
# sendmail command. This is the shell command used to send out mails via the sendmail protocol
sendmail_command = string(default='sendmail -t')

# where to store outgoing mails, e.g. `maildir:///home/you/mail/Sent`.
# where to store outgoing mails, e.g. `maildir:///home/you/mail/Sent` or `maildir://~/mail/Sent`.
# You can use mbox, maildir, mh, babyl and mmdf in the protocol part of the URL.
#
# .. note:: If you want to add outgoing mails automatically to the notmuch index
# you must use maildir in a path within your notmuch database path.
sent_box = mail_container(default=None)

# where to store draft mails, e.g. `maildir:///home/you/mail/Drafts`.
# where to store draft mails, e.g. `maildir:///home/you/mail/Drafts` or `maildir://~/mail/Drafts`.
# You can use mbox, maildir, mh, babyl and mmdf in the protocol part of the URL.
#
# .. note:: You will most likely want drafts indexed by notmuch to be able to
Expand Down
25 changes: 12 additions & 13 deletions alot/utils/configobj.py
Original file line number Diff line number Diff line change
Expand Up @@ -90,24 +90,23 @@ def mail_container(value):
"""
Check that the value points to a valid mail container,
in URI-style, e.g.: `mbox:///home/username/mail/mail.box`.
`~`-expansion will work, e.g.: `mbox://~/mail/mail.box`.
The value is cast to a :class:`mailbox.Mailbox` object.
"""
if not re.match(r'.*://.*', value):
raise VdtTypeError(value)
mburl = urlparse(value)
if mburl.scheme == 'mbox':
box = mailbox.mbox(mburl.path)
elif mburl.scheme == 'maildir':
box = mailbox.Maildir(mburl.path)
elif mburl.scheme == 'mh':
box = mailbox.MH(mburl.path)
elif mburl.scheme == 'babyl':
box = mailbox.Babyl(mburl.path)
elif mburl.scheme == 'mmdf':
box = mailbox.MMDF(mburl.path)
else:
raise VdtTypeError(value)
return box
uri_scheme_to_mbclass = {
'mbox': mailbox.mbox,
'maildir': mailbox.Maildir,
'mh': mailbox.MH,
'babyl': mailbox.Babyl,
'mmdf': mailbox.MMDF,
}
klass = uri_scheme_to_mbclass.get(mburl.scheme)
if klass:
return klass(mburl.netloc + mburl.path)
raise VdtTypeError(value)


def force_list(value, min=None, max=None):
Expand Down
3 changes: 2 additions & 1 deletion docs/source/configuration/accounts.rst
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,8 @@ Here is an example configuration
gpg_key = D7D6C5AA
sendmail_command = msmtp --account=wayne -t
sent_box = maildir:///home/bruce/mail/work/Sent
draft_box = maildir:///home/bruce/mail/work/Drafts
# ~ expansion also works
draft_box = maildir://~/mail/work/Drafts
[[secret]]
realname = Batman
Expand Down
4 changes: 2 additions & 2 deletions docs/source/configuration/accounts_table
Original file line number Diff line number Diff line change
Expand Up @@ -52,7 +52,7 @@

.. describe:: draft_box

where to store draft mails, e.g. `maildir:///home/you/mail/Drafts`.
where to store draft mails, e.g. `maildir:///home/you/mail/Drafts` or `maildir://~/mail/Drafts`.
You can use mbox, maildir, mh, babyl and mmdf in the protocol part of the URL.

.. note:: You will most likely want drafts indexed by notmuch to be able to
Expand Down Expand Up @@ -166,7 +166,7 @@

.. describe:: sent_box

where to store outgoing mails, e.g. `maildir:///home/you/mail/Sent`.
where to store outgoing mails, e.g. `maildir:///home/you/mail/Sent` or `maildir://~/mail/Sent`.
You can use mbox, maildir, mh, babyl and mmdf in the protocol part of the URL.

.. note:: If you want to add outgoing mails automatically to the notmuch index
Expand Down

0 comments on commit 8c25bed

Please sign in to comment.