Perils of bleeding edge

Posted on Wed 27 July 2011 in geek

I've taken to running the latest emacs from a source tree install. It works well enough and additional modes I use have been liberally ${VC} fetched into my .emacs.d. However there are still a number of packages I'd like to use from Debian's emacs version agnostic site-lisp directories. I came up with this:

 ;; Add site-lisp to search path
;
; This is a work-around function for when I'm running bleeding
; emacs from the source tree but still want Debian's developer
; tools. I'd caution about having too many extra packages about that
; have been merged into the source tree (cedet etc) lest it get
; confused.
(defun load-debian-site-lisp()
"Attempt to load Debian's site-lisp if it's there"
  (interactive)
  (when (and (not (member "/usr/share/emacs/site-lisp" load-path))
             (fboundp 'normal-top-level-add-subdirs-to-load-path))
          (let* ((default-directory "/usr/share/emacs/site-lisp"))
      (normal-top-level-add-subdirs-to-load-path))))

(load-debian-site-lisp)

Which seems to work well enough to give me my debian-changelog-mode back. However it's still not seamless as I have to manually (require 'debian-changelog-mode) before loading a changelog which forces the issue with local variables. I suspect I'll have to replicate the boilerplate that /usr/share/emacs/site-lisp/debian-startup.el does but I can't use because it doesn't degrade gracefully if no debian-emacs-flavour is defined. Suggestions for making this behaviour neater would be useful....