Mutt Sidebar Configuration

I am a mutt user (in fact, I'm a mutt-sidebar user). That means several things, one of which is that I spend a nonzero amount of time configuring my e-mail client to behave as I want it to. I am also a vim user, and in the spirit of loving vim, I set out on an adventure to make everything look and feel like vim. A natural thing to want to do is be able to navigate the sidebar (i.e. the folder list) with j and k keys as one does in vim. Reasonable attempts at this fail for various reasons, and I hope this post will explain why and also how to do what you want.

First, a natural thing to want to do is to bind sidebar navigation to <ctrl>+j and <ctrl>+k, since the <ctrl> binding indicates somehow that the navigation is "slightly different", and therefore is a good mnemonic for a "slightly different" kind of up and down movement. To do this, you could put something like:

bind index,pager \ck sidebar-prev
bind index,pager \cj sidebar-next

at the end of your ~/.muttrc. However, this has an unexpected result: moving up and down in the menu works just fine, but now pressing <return> also moves you down in the sidebar, instead of opening the highlighted message (its default) or whatever else you had it set to.

The problem is that <ctrl>+j and <return> are actually the same character. That is, when you press <ctrl>+j the terminal interprets it and sends an ASCII 10 (the LF character), which is the same thing that <return> sends. In fact <ctrl>+* (where * is any character a-z) is bound to some control code (it's just that most of them are unused in modern applications, e.g. <ctrl>+i is an alias for tab). Unfortunately that means we can't bind <ctrl>+j and <return> to different things in mutt, since they're actually the same character.

So what's the workaround? Well, I decided that <alt> is just as reasonable as <ctrl>. Running :exec what-key told me that \252 (i.e. octal 252) is <alt>+j, so I can add the following lines to ~/.muttrc:

bind index,pager \253 sidebar-prev
bind index,pager \252 sidebar-next

but it didn't work! Mutt Well, it might work for some people, depending on their terminal configurations. According to the Rute User's tutorial and Exposition:

The alt modifier (i.e. Alt-?) is in fact a short way of pressing and releasing Esc before entering the key combination; hence Esc then f is the same as Alt-f--UNIX is different from other operating systems in this use of Esc.

So what's the issue? Well, some terminals do this by default, and some don't. In xterm, the default is not to convert <alt> characters into the escape sequences mutt expects. However, by putting

xterm*metaSendsEscape: true

in your ~/.Xresources and running xrdb ~/.Xresources and restarting xterm, it /will/ interpret <alt> keypresses correctly, and your <alt>+j keybindings will work.

Google Voice ncurses interface

For a while I have been using a Google Voice number as my primary texting number since it doesn't cost any money and has the additional benefit that when I'm at a computer, I can type text messages on a regular keyboard instead of on my tiny phone keyboard. This is all well and good, except I don't particularly care for the web interface; not because it's bad, but simply because it requires you to have a web browser open.

To solve this, I wrote an ncurses based "chat" client, gvchat. It provides and instant messaging interface for the most recent text message your GV account has received. When someone new texts you, it seamlessly switches to that new thread. At this point there is no way to initiate new texts, but I plan on growing the feature set in the coming months. However, for now it fits my needs so I thought I'd put it up for other people in the same boat.

Additionally, the client has a class 'Chat', which implements a crude ncurses based chat interface. As this improves, my hope is to add an XMPP backend for it as well. Any ncurses tips and tricks (or pointers to libraries which already have this functionality and are built on top of ncurses) are much appreciated!!