Unsetting Key Bindings in emacs

I make use of emacs – my ability to customize the editor has made it easier for me to be productive. Switching between windows has always been a bit annoying in emacs. After reading Managing Emacs windows, I figured that I would give the ace-window library a try to see if it could solve my problems.

After downloading ace-window and dropping the file in my .emacs, I was ready to go. I’m lazy and a touch typist, so I set up ace-window to run from the home row using:

(global-set-key (kbd "C-;") 'ace-window)

My initial experiments worked well and I was able to hop between buffers and frames quickly. Things came crashing to a halt when I hit a Markdown buffer. Markdown buffers fire up a spellchecker usingFlyspell and Flyspell maps C-; to spellcheck previous word or some other moderately worthless command.

My first attempt at getting rid of this setting was to use global-unset-key. This would work, but only if Flyspell immediately started with all emacs buffers and if the key bindings were set across all of emacs. This was a no-go, but I left it in my emacs customization just because I don’t want something else to steal this binding in the future.

My second attempt was to create a minor mode. If you’re interested in this approach, you can find instructions at Globally override key binding in Emacs. This approach didn’t work at all. I couldn’t determine why Flyspell mode was loading at a higher priority than my own minor mode. Another answer in that same question suggested adding “advice” to the load function. This approach was barely effective. After the buffer was initially populated, my key binding would not be in place; after some period of time, though, my binding would start working and I could use C-: to navigate between windows. As near as I can tell, the problem is that the spell check process was still running in the buffer and that means that the mode hadn’t finished loading for the buffer.