/bic

Best IMAP Client (for Emacs)

Primary LanguageEmacs Lisp

BIC, the Best IMAP Client

BIC is an IMAP client for Emacs. It is built on the following principles:

  • asynchronicity: the Emacs user interface should be blocked as little as possible. Any long-running commands should be run in the background.
  • minimal configuration: you should be able to just read your mail without adding half a page of configuration variable settings to your .emacs file, or installing and configuring any external programs. Life is too short.
  • offline is online: the client should have the same behaviour even if the connection to the mail server is lost, and changes should be synchronised seamlessly once the connection is reestablished.
  • osmosis: you shouldn’t have to ask your mail client to download your messages for offline access; they should just be available without you having to do anything.

That said, it is still a work in progress. See “Known problems” below.

Who, if not you? When, if not now?

Of course, there is no such thing as a “Best IMAP Client”; that depends on far too many factors. BIC is a snapshot in time and space: it’s the intersection of what is possible in Emacs 25.1, what is possible considering the principles I stated above, and what I had the time and energy to implement.

In a way, BIC is defined more by what it isn’t than by what it is: it isn’t Gnus, which blocks when communicating with the server, and it isn’t mu4e, which requires mu and offlineimap to be installed.

So what will BIC become in the future? Hard to tell. It has basic functionality, though many features you’d expect in an email client are missing (see “Known problems”). I may or may not have the time and energy to “complete” the work. Maybe the principles BIC is based on will be irrelevant: will the IMAP protocol still be used? will reading email in Emacs still be a desirable thing? will the concept of email change beyond recognition?

What I want to say with this is that the future of BIC is in your hands. Do you think that BIC is useful or meaningful, that the basic ideas and concepts are helpful? If so, maybe you are the chosen one to make BIC better. Create an issue on GitHub with your thoughts, ideas and questions.

Requirements

BIC requires Emacs 25, nothing less. Emacs 25.1 was released on 2016-09-17.

BIC also requires the packages fsm (from GNU ELPA) and srv (from MELPA) to be installed.

BIC has not been tested on Windows, so any reports, positive or negative, are very welcome.

How to use

Type M-x package-install-file, and enter the directory where bic.el etc are found.

Then type M-x bic. If it’s the first time you use BIC, it will ask for your email address and IMAP server. Otherwise, it will just start BIC with the previously configured account. (If you want to add another account, type M-x bic-add-account.)

For any mailbox you open, BIC will download all messages that are less than 30 days old, and all messages that are unread or flagged regardless of date.

The key bindings are mostly based on Gnus. See C-h m for the corresponding buffer for more information.

How to stop using it

If you just want to stay disconnected for a while, use M-x bic-deactivate or M-x bic-deactivate-all, and then use M-x bic-activate or M-q bic-activate-all when you want to reconnect.

If you want to stop BIC, type M-x bic-stop for each account you have added, or M-x bic-stop-all to stop all accounts. All downloaded data is stored in the ~/.emacs.d/bic directory; you can remove that if you want.

Known problems

  • At the moment, it only downloads messages from your inbox automatically. For other mailboxes, messages are downloaded when you open that mailbox. (This does not apply if your IMAP server supports NOTIFY.) You can use M-x bic-list-status-all to explicitly sync all subscribed mailboxes.
  • The unread message count in the mailbox tree view is currently only updated when you explicity request a status update.
  • It’s too verbose, showing too many messages in the echo area.
  • There is currently no way to access messages older than 30 days, unless they are unread or flagged.
  • If a large number of messages has been downloaded for a certain mailbox, opening that mailbox will take a long time.
  • It doesn’t detect that messages have been deleted on the server.
  • There is currently no way to copy or move messages.
  • Messages are not threaded.
  • There is no search function.
  • If the server doesn’t support IDLE, messages will be downloaded rather infrequently.
  • If you enter the wrong password, BIC will repeatedly try to connect using the incorrect password until you run M-x auth-source-forget-all-cached.
  • While BIC attempts to open connections asynchronously, on some systems Emacs performs DNS requests synchronously. This can sometimes lead to the user interface being blocked while BIC tries to reconnect to the server. There was a thread about this on emacs-devel, and another one.

    For GNU/Linux, support for asynchronous DNS resolution was introduced in Emacs 26.1.

    For OS X, asynchronous DNS is not yet supported. See this emacs-devel thread.

  • While Emacs supports making GnuTLS perform TLS handshakes asynchronously, BIC somehow doesn’t manage to make use of that. Need to investigate.

Troubleshooting

If something goes wrong, there are four places where you may want to look for more information:

  • The *bic-transcript-username@example.com* buffer contains a transcript of IMAP requests and responses exchanged with the server. When copying text from the transcript buffer to another buffer, BIC makes an effort to remove information you might not want to share, such as email addresses and subject lines.
  • The *Warnings* buffer contains warnings about unexpected events.
  • The *fsm-debug* buffer shows messages and state transitions for the state machines. This is usually uninteresting, except for the messages that contain “warning” or “error”.
  • Currently, the *Messages* buffer gets more than its fair share of various more or less informative messages.

If BIC makes Emacs slow, try profiling it to find out which part of the code needs to be optimised:

  • M-x profiler-start
  • Do whatever makes Emacs slow.
  • M-x profiler-report
  • Afterwards, deactivate profiling with M-x profiler-stop.

What about sending email?

Note that BIC is the Best IMAP Client, not the Best SMTP Client :) You should look into the smtpmail library that is included with Emacs.

BIC can integrate with smtpmail, to make it queue outgoing messages while you’re offline, and send them automatically when you come online again. To enable that behaviour, set bic-smtpmail-toggle-queueing to t.

Contact

Feel free to open an issue in the issue tracker, or send me an email at magnus.henoch@gmail.com.