Hi Simon.
> Hi Martin, I occasionally get this (taken from *Messages*):
>
> mouse-autoselect-window-start: Wrong type argument: numberp, nil
>
> I just caught it with debug-on-error, though I'm not sure quite how to read
> it as it looks like 2 errors have occurred. The way I read it, we are in
> the process of switching to the *Backtrace* window when the error
> (presumably) happened again:
>
> Debugger entered--Lisp error: (wrong-type-argument numberp nil)
> window-at(nil nil #)
> mouse-autoselect-window-start()
> handle-select-window((select-window (#)))
> call-interactively(handle-select-window)
>
> But it is kind-of what I guessed, that the error is thrown by window-at
> because mouse-position returns nil for X and Y.
>
> I can fairly easily reproduce this with emacs -Q if I move from the selected
> first frame to a second frame and then off that second frame quickly when
> (a) the second frame has split windows, (b) the second frame's selected
> window (ie, when the second frame is selected) and its point is covered by
> the first frame.
I can obtain the error too, even when running two distinct Emacs
processes with one frame each. Obviously, `mouse-position' _should_
return nil whenever it's not able to determine a meaningful position,
hence I can't put the blame on that.
> The amount of time spent in the second frame does not seem to depend on
> mouse-autoselect-window.
I suppose you tell that from using an autoselect timeout in your window
manager that differs from `mouse-autoselect-window'.
> Maybe it has more to do with whether Emacs gets
> the chance to get some info out of X before the mouse has moved off the
> second frame. I use Solaris CDE on a PC running Exceed, which may
> complicate/slow things.
Honestly, I expected many more problems when switching frames than you
encountered so far.
> Maybe the only fix is to be tolerant of nil for X and Y from mouse-position.
The only thing I can offer is to wrap this in a `condition-case' and
have `handle-select-window' do it's usual stuff when
`mouse-autoselect-window-start' fails.
martin