ah ! I tried evaluating sub-expressions, albeit not in a compile-buffer. When I evaluate (compilation-buffer-internal-p (current-buffer)) I get thrown to the debugger: Debugger entered--Lisp error: (wrong-number-of-arguments #[nil "ŽÀŽÁ!‡" [local-variable-p compilation-locs] 2 ("/usr/share/emacs/22.1/lisp/progmodes/compile.elc" . 48467)] 1) compilation-buffer-internal-p(#) eval((compilation-buffer-internal-p (current-buffer))) eval-last-sexp-1(nil) eval-last-sexp(nil) call-interactively(eval-last-sexp) so the problem's there. C-h f says compilation-buffer-internal-p is a compiled Lisp function in `compile.el'. (compilation-buffer-internal-p) Test if inside a compilation buffer. and /usr/share/emacs/22.1/lisp/progmodes/compile.el.gz (helpfully uncompressed on the fly by emacs) says: ;;; test if a buffer is a compilation buffer, assuming we're in the buffer (defsubst compilation-buffer-internal-p () "Test if inside a compilation buffer." (local-variable-p 'compilation-locs)) ;;; test if a buffer is a compilation buffer, using compilation-buffer-internal-p (defsubst compilation-buffer-p (buffer) "Test if BUFFER is a compilation buffer." (with-current-buffer buffer (compilation-buffer-internal-p))) so it looks like a typo in your patch - it should either call compilation-buffer-p or omit the (current-buffer) parameter to compilation-buffer-internal-p. (I should also note that the error message produced, claiming and got the wrong number of arguments, was was not so helpful !) Changing the defun to (defun compilation-find-buffer (&optional avoid-current) "Return a compilation buffer. If AVOID-CURRENT is nil, and the current buffer is a compilation buffer, return it. If AVOID-CURRENT is non-nil, return the current buffer only as a last resort." (if (and (compilation-buffer-internal-p) (not avoid-current)) (current-buffer) (next-error-find-buffer avoid-current 'compilation-buffer-internal-p))) and doing C-c C-e to that fixes the bug :-) Eddy.