Getting w3m to work with Emacs 23 in Ubuntu 11.10

I encountered some issues getting Emacs 23 working on Ubuntu 11.10 and I wanted to chronicle my travails in case someone else bumped into this. I tripped into this error after installing w3m-el-snapshot.

Debugger entered--Lisp error: (void-function w3m-make-menu-item)

After some research into how provide and require work in Emacs Lisp, I discovered a few things. The function w3m-make-menu-item is defined in w3m-util. You’ll need to add /usr/share/emacs/site-lisp/w3m to your load-path.

(add-to-list 'load-path "/usr/share/emacs/site-lisp/w3m")

Wipe out your .elc bytecode compilation results, and consider moving the contents of the above folder into your .emacs.d, such as in .emacs.d/w3m. Then adding that to your load-path instead so that you aren’t affected by things like a distro specific site-start.

find /usr/share/emacs/site-lisp/w3m -name "*.elc" | xargs rm

Wiping out the elc’s is what resolved the problem for me. This is because of how

(provide 'w3m-util) ;; at the end of w3m-util.el
(require 'w3m-util) ;; at the beginning of w3m.el

interact with bytecode-compiled Emacs Lisp.

I know this site is a bit of a disaster zone, but if you like my writing or think you could learn something useful from me, please take a look at the book I've been writing with my coauthor Julie. There's a free sample available too!