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

From: [email-masked] (B.V. Raghav)
Date: Fri, 22 Jul 2016 20:21:49 +0530

Drew Adams <[email-masked]> writes:

>> > (defun compilation-auto-jump (buffer pos)
>> >   (when (buffer-live-p buffer) ; <=======
> ...
>> This function did not help the use case...
>
> Hm. I thought that the error reported was that some code tried
> to use a buffer that was dead (killed).  And that the code
> that raised the error was invoked from `compilation-auto-jump'
> (which is invoked from an idle timer).
>
>  Error running timer `compilation-auto-jump': (error "Selecting
>    deleted buffer")
>
> Are you getting the _same_ error even after changing the code
> as indicated?  If so then I might not understand what's going
> on.
>
Yes, I had thought the same, when I had included this in the init.el, in
the end. Then I sent a print message, and it printed the message, but
that was all.

I had tried it with `emacs -Q',
  added ggtags, and icicles to the load path;
  copied the function to scratch buffer, and C-M-x

But the same result!

Now I am trying your suggestion, using the message instead of print.

(defun compilation-auto-jump (buffer pos)
  "Override suggested by Drew Adams bug#23987 <[email-masked]>"
  (message "Override for compilation-auto-jump called Buf:%s Pos:%s"
	   buffer pos)
  (when (buffer-live-p buffer) ; <=============
    (with-current-buffer buffer
      (goto-char pos)
      (let ((win (get-buffer-window buffer 0)))
	(if win (set-window-point win pos)))
      (if compilation-auto-jump-to-first-error
	  (compile-goto-error)))))

Here is the output from the *Messages* buffer

> For information about GNU Emacs and the GNU system, type C-h C-a.
> Mark set
> Function icicle-repeat-complex-command is already compiled
> Quit [2 times]
> Making completion list...
> Ggtags mode enabled
> Global found 1 definition
> Override for compilation-auto-jump called Buf:*ggtags-global* Pos:208
> Quit
> Global found 4 references
> Override for compilation-auto-jump called Buf:*ggtags-global* Pos:230
> Global found 1 definition
> Override for compilation-auto-jump called Buf:*ggtags-global* Pos:223
> <backtab> is undefined
> Quit
> Turning OFF Icicle mode...done
> Turning ON Icicle mode...done
> Turning OFF Icicle mode...done
> Turning ON Icicle mode...done
> Turning ON Icicle mode...done
> Computing completion candidates...
> Quit
> Computing completion candidates...
> Global found 1 definition
> Override for compilation-auto-jump called Buf:#<killed buffer> Pos:229
> Computing completion candidates...
> Turning OFF Icicle mode...done
> Global found 1 definition
> Override for compilation-auto-jump called Buf:*ggtags-global* Pos:229

Ggtags works as expected, before icy-mode, but with icy-mode switched
on, the message flashes, saying called for a killed buffer. Then again
after switching off icy-mode, invoking ggtags, for the same definition.

Incidentally this happens only, for sole completions, for example,
func_foo_bar, has single occurence as definition, then this failure
happens. However for multiple completions, it works, seamlessly.

On top of it, when I override the call to
`ggtags-navigation-mode-cleanup' inside of `ggtags-global-handle-exit',
as follows:
(ggtags-navigation-mode-cleanup buf 0.25)
instead of `0'                     /^^^^\-----here

This function works for arbitrarily small numbers 0.006 etc. buf
sometimes also does fail.

There indeed is a jump to the definition, but a split window is left
open at the bottom. This probably is a ggtags affair.

Thanks,
HTH

-- 
(B.V. Raghav)
Ph.D. Student,
Design Programme, IIT Kanpur

Ph: +91-9450988137
Email: [email-masked]