Linux and Sundry

An Emacs Bisection

cricket on a screenA problem has been following me around for a couple of years.  Emacs, in which I have been spending more than a small portion of my time, has had a problem that would manifest in any non-X mode.  It persisted across multiple terminals: putty on Windows back to a Linux box, emacs -nw in a GNOME Terminal , even a bog-standard Linux console.  Specifically, hitting ‘Page Up’ and would result in the string ‘5~‘ being printed and ‘Page Down’ would result in '6~‘.  Not deadly, but just enough to throw me off my stride when moving around files.  I’d never gotten around to sorting in out, since it worked just fine when running as an X server.

This came up after the PLUG meeting last night, over pizza and beer at the Best House last night.  As Walt pointed out, there was almost certainly a very good reason for this, and it would be living somewhere in the years of messy accretions that comprise my .emacs file and its satellites.

I knew this was probably the case.  Like most .emacs files, mine was not planned.  It grew from bits and useful snippets, mode hooks, random configurations, pieces that crept in as distribution cruft, and pastings of now-unknown provenance.  The whole morass needs a good mucking out, but that’s not on the to-do list.  Perhaps, though, I could finally get the nagging problem resolved.

The first test was an obvious one: remove all the startup files and see if the problem went away.

Now, at some point I acquired a set of XEmacs startup files.  The reason for this is hazy…I haven’t used XEmacs in years.  Nonetheless, there it is: an .xemacs folder with an init.el and custom.el.  At some point, something broke when I tried to take my .emacs file and .emacs.d folder without bringing .xemacs along for the ride, so the path of least resistance was to let it follow me from machine to machine ever since.

After renaming all the startup files, the problem was indeed gone and I could happily page up and down.  From there on, the process is a mechanical one: add files back in until it fails, then comment everything out in the file and add chunks back in until the problem returns.  Once it does, you can be pretty sure you’ve isolated the problem.

Indeed, the problem was lurking in .xemacs/init.el, in the following pair of lines:

(global-set-key "e[" 'enlarge-window)
(global-set-key "e]" 'shrink-window)

It seems to me like a slightly odd manifestion, but there you have it.  With those lines removed, my Emacs bliss is unimpeded.

I really ought to get around to getting rid of that XEmacs cruft.

(CC-licensed image of a cricket from TaranRampersad‘s flickr photostream.)