> One problem I see with this implementation is that it also waits for twice > the delay. The reason can be seen in the sequence of events when the mouse > is moved to a new window: > > - handle-select-window calls autoselect-window-start. > > - autoselect-window-start sets autoselect-window-position to > (mouse-position). However, this position appears to be the position > *before* the mouse movement. It's the first row/column after the mouse has crossed the window border. Try by yourself: Take two windows of fixed size one above the other and move the mouse between them. The cddrs of autoselect-window-position calculated by autoselect-window-start should differ by one no matter where mouse movement started or ended. In any case `window-at' for autoselect-window-position should always return the window you move to. > - autoselect-window-start starts a timer to run autoselect-window-select > after the specified delay. > > - when autoselect-window-select runs after the first timeout, it checks to > see if autoselect-window-position is equal to (mouse-position), which cannot > be true even if the mouse has not moved again. If you move from the lower window to the upper window and stop movement exactly at the mode line of the upper window (that is, if you move the mouse by a few pixels only) it can be true. > So, window selection does > not occur, and it just sets autoselect-window-position to (mouse-position). > > - when autoselect-window-select runs after the second timeout, and the mouse > has not moved, autoselect-window-position is equal to (mouse-position) and > window selection occurs. Hopefully. In my experience, the timeout before the last can be annoying too. Sometimes I'm just off by one character. > To be honest, I'd be quite happy with the feature if it did not try to > detect for a quiescent mouse as it would still be a big improvement. In > that case I guess the implementation would not need to use (mouse-position) > and the above problem would not occur. > > If it could be made to work, it would be a bonus (though perhaps should be > an additional option, i.e., delay or delay with quiescence). OK, I moved everything back to mouse.el and added a customizable variable `mouse-autoselect-quiescent'. Using a number as value for that variable checks whether movement was restricted to that many chars around the last position. This leaves future users a number of choices. > Of course, one > simple hack/workaround would be to use (/ mouse-autoselect-window 2.0) for > the timer delay, That would be ugly. > though I'd be interested to see why mouse-position returns > what it does. I think that `mouse-position' does the best it can. Mice are unpredictable ...