Setting up Emacs key mappings on Windows Outlook

I’ve had all I can stand and I can’t stand no more.

It’s been four months since I moved from a Windows to a Mac machine.  I really like the macbook air.  But Outlook 2011 for the Mac is driving me crazy.  It keeps giving me incomprehensible error messages like “unknown error” or “end of file was reached”.  It mangles my meeting invites.  It looses attachments.  It makes me restart every time I change networks otherwise it’s “Not connected”.  It’s terribly slow. It kept me from doing my tax return (okay, that’s not Outlook’s fault. I was just procrastinating).  And for some inexplicable reason it was always 10-15 minutes behind my actual inbox – my mail in Outlook on a VMWare machine always gets mail faster than the Mac version.

I started looking into alternatives.  Apple’s Mail.app looks pretty good, but it’s not customizable enough.  Mozilla Thunderbird, which I use for personal mail, is very customizable.  But due to the way things are set up with Exchange, it seems I would have to go through hoops to download mail when outside the Adobe network if I used it.  I also looked to see if there were new versions of the Emacs mail readers I used to use like Mew and Wanderlust.  Unfortunately Wanderlust isn’t maintained, and as far as I can tell Mew doesn’t have full support of HTML mail which a lot of people around the office use.

After a few days of pondering, I decide to go back ot using Outlook on Windows, in a VM.  I was already using it for doing some calendaring things that Outlook on Mac doesn’t support. It’s fast. It’s written to work well with Exchange (well, as good as possible I suppose).  Calendaring actually works – unlike with the Mac version.  And it’s much more feature-rich and customizable.

One thing I’ve gotten used to with Outlook on the Mac, though, are the Emacs key bindings.  As an avid Emacs user for just about everything (unfortunately, as mentioned above, no longer for mail though…), this has been working great for me and makes me more productive.  So I decided to see if I could customize Outlook on Windows with all the key bindings that I wanted, and succeeded! I found an open source tool called AutoHotKey that allows for setting up macros and shortcut keys.

It works great so far.  I probably still have a lot of tweaking to do, but thanks to the AutoHotKey documentation I’m up and running.  For anyone interested, below is the filtering code for Outlook windows and controls as well as the key bindings I’m using.  In case you’re wondering, a few of the mappings are from Wanderlust, an emacs mail reader mentioned above that I used to use.

Let me know if it’s useful for you and/or if you have some better ideas for my mail and calendaring needs!

;; Sets up partial matching for window titles
SetTitleMatchMode 2
;; Use these keys when the main outlook window has focus
#IfWinActive ahk_class rctrl_renwnd32, NUIDocumentWindow
  ^n::Send {down}
  ^p::Send {up}
  ^f::Send {right}
  ^b::Send {left}
  ^g::Send {esc}
  ^s::Send ^!k ;; search this folder
  ^a::Send {home}
  ^e::Send {end}
  w::
    if ActiveControlIsOfClass("SUPERGRID") ;; if the inbox control has focus otherwise send the default
      Send ^M ;; write a new message
    else
      Send w
    return
  o::
    if ActiveControlIsOfClass("SUPERGRID") 
      Send ^V ;; refile a message
    else
      Send o
    return
  +f::Send !4 ;; folllow-up later
  f::
    if ActiveControlIsOfClass("SUPERGRID") 
      Send !6 ;; forward
    else
      Send f
    return
  !1::Send ^1 ;; Mail pane ;; map command-1 to ctrl-1 because I'm used to command 1
  !2::Send ^2 ;; Calendar pane
  ^d::
    if ActiveControlIsOfClass("SUPERGRID") 
      Send ^d
    else
      Send {delete}
    return
#IfWinActive
;; Use these keys if focus is on a new message
#IfWinActive ahk_class rctrl_renwnd32, Message
  ^n::Send {down}
  ^p::Send {up}
  ^f::Send {right}
  ^b::Send {left}
  ^a::Send {home}
  ^e::Send {end} ;; search
  ^d::Send {delete}
#IfWinActive