Subject: bug#23987: 24.5; Icy with Ggtags Problem

From: Drew Adams <[email-masked]>
Date: Thu, 21 Jul 2016 09:44:44 -0700 (PDT)

>    Error running timer `compilation-auto-jump': (error "Selecting
>    deleted buffer")

This might, as supposed, be a ggtags issue.  But I wonder if this
isn't actually a `compile.el' issue.

It seems like asking for trouble for any function
(e.g. `compilation-auto-jump') that is invoked by an idle timer
to be doing something based on evaluation of `(current-buffer)',
in particular, without testing whether the result of that
evaluation is a live buffer.

In the present case, a user is apparently doing code completion.
And in the case of Icicles, that can involve use of the minibuffer.

I suspect that `compilation-auto-jump' should control itself, and
act only in the buffer that it apparently expects to be acting in.

Seems like fragile code.  Any reason why an idle-timer function
should assume something about what buffer is current or should
not bother to check whether `(current-buffer)' is a live buffer?

My guess is that this is not a ggtags or Icicles issue, but is
just dumb behavior by `compilation-auto-jump'.

This is my suggestion, FWIW:

(defun compilation-auto-jump (buffer pos)
  (when (buffer-live-p buffer) ; <===========================
    (with-current-buffer buffer
      (goto-char pos)
      (let ((win  (get-buffer-window buffer 0)))
        (when win (set-window-point win pos)))
      (when compilation-auto-jump-to-first-error
	 (compile-goto-error)))))

Seems like a no-brainer...