Sup email client keybindings and filters
Lately I've been playing with Sup, a geeky console-based email client written in Ruby. I've used it enough to understand it and settle in a bit, but unfortunately also enough to realize that it's probably not right for me. Along the way, though, I've done some work with keybindings and message filters that I'd like to share with you.
Before I get to that, though, a brief review of Sup. What first attracted me to Sup was the fact that it's written in Ruby (with fairly clean code, from what I've seen), and has a fairly extensive system of hooks for customizing and extending the client behavior (the hooks are also written in Ruby). Also, it has a nice label-based filing system and powerful search utilities (a la Gmail), rather than the tired old folders metaphor. It runs in the console and is entirely keyboard driven, the workflow is pretty quick and easy, and you compose messages in the text editor of your choice (emacs, vim, etc.).
Those are the strong points, for me. Unfortunately, there are a number of issues that made me decide to look elsewhere. Foremost is the console-based interface using Curses, which holds it back in a variety of ways. One issue I ran into was that there's no way to define keybindings that use the Alt key; Curses simply doesn't support that. Sup also doesn't seem to be able to render non-Latin characters, which is occasionally an issue for me. And naturally, being console-based, modern luxuries like HTML mail and previews of attached images are out of the question.
So, Sup turns out not to be my cup of tea after all. But, maybe it is yours, so I'll share the fruits of my brief foray.
-
The first obstacle was the fact that Sup, like many Unix-style "mail user agents", has no facilities for the actual fetching or sending of email over a network. Instead, it leverages programs like fetchmail, offlineimap, and sendmail to handle those things. This Unix-style mail system was something I had no prior experience in, so I had a lot to learn. After a lot of research and a fair bit of frustration, my advice is to forget the traditional fetchmail and sendmail, and instead use getmail and msmtp. They are a lot simpler to set up, and do everything most people need.
-
After I got my email imported into Sup, I wanted to change some key bindings to be more comfortable. In particular, being an Emacs user, I am used to Ctrl-n/Ctrl-p to move the cursor up and down lines, while Sup defaults to the vi-style hjkl bindings (which make no sense for me, using the Dvorak keyboard layout). Unfortunately, I could find very little documentation about how to change the keybindings, other than the fact that there was a "keybindings.rb" hook that I could write... if I knew what to write in it.
Undeterred, I dove into the source code and learned all about the keybindings system. Then, I turned that knowledge into a comprehensive CustomizingKeys wiki page, so that the next guy wouldn't have to dig through the code like I did. That was a fun afternoon project.
-
Next, I realized I needed a system to filter my incoming mail, automatically apply appropriate labels, and so on. Sup doesn't have a filtering system like that built in, but it's fairly straightforward to create one by taking advantage of Sup's hook system. There is some documentation about this on the AutoAddLabelsToNewMessages wiki page, but as I started writing my filters, I began to realize that, although writing ruby code for every filter gives you a lot of flexibility and power, it also involves a lot of redundant code and is not very easy to read or maintain.
So, I started writing my own filter system, which loads rules from a YAML file (see the example filters file). I've posted the result to my sup-filters repository on GitHub. Actually, what I've posted there is even more polished and better documented than what I used myself. Even after I had decided I wasn't going to use Sup myself, I spent a couple days cleaning it up for other people, to call it a job well done. That's Just How I Roll™.
Anyway, if you use Sup, I hope you will find this stuff useful. As for myself, I will miss Sup's labels and easy searching, but it's time to continue my quest for a well-fitting email client. Next on my list to try is Wanderlust. If you have any recommendations for other clients to try, leave a comment!
Comments
on
If you liked parts of sup and you like emacs, maybe notmuch is closer to what you are looking after.
on
Hallo! Your page on keybindings seems to have been lost when they moved the wiki to GitHub. You don't happen to have a copy laying around or an example config line or two of how to rebind a key do you?
Before I started hacking on the code itself, just thought I'd ask! Thanks!
on
I'm afraid I don't have a copy of that page. :(
Have a look at
lib/sub/keymap.rb
and the various files inlib/sup/modes/
(especiallylib/sup/modes/thread_view_mode.rb
). Each mode has its own Keymap instance, and there is a global keymap as well. A Hash of all the modes, and the global keymap, are provided to the "keybindings" hook. So I think you could do put something more or less like this (totally untested, just guessing) in~/.sup/hooks/keybindings.rb
:There's a way to do modifier keys like Ctrl and Shift, too, but I don't recall exactly how. I think it involved curses/ncurses. You might find an example of a key binding with a modifier in one of the sup modes.
Hope that helps!
Comments are closed.