[ESS-bugs] select-window (C-c M-j) doesn't give input focus to target (*R*) [Carbon GNU Emacs]

David Reitter david.reitter at gmail.com
Sun Apr 2 20:18:51 CEST 2006


On 2 Apr 2006, at 19:01, Stephen Eglen wrote:

> ok.  Have you gone through the logic in ess-show-buffer?  IN
> particular, see part 2:
>
>       ;; 2. Maybe BUF visible in another frame.
>       (setq frame (ess-buffer-visible-other-frame buf))
>       (if frame
> 	  ;; BUF is visible in frame, so just check frame is raised.
> 	  (if (not (eq (frame-visible-p frame) t))
> 	      ;; frame is not yet visible, so raise it.
> 	      (raise-frame frame))
>
> I'm not able to test this right now, but my memory the other day was
> that the code at the end of ess-show-buffer was able to select-frame
> and then put the mouse in that frame to make the frame active.  I
> wonder if that is the problem?  (Maybe there is an interaction with
> the O/s here, with mac requiring click of the window to grab the
> focus?

Ah. That explains things.
Moving the mouse around isn't going to do anything on Carbon / OS X,  
and also not on any X11 version if configured differently. For  
example, the X11 server I occasionally use (Apple X11) can be  
configured to select the windows that the mouse points on - but  
that's not the default.

Secondly, why not use `select-frame-set-input-focus'  to do this?  
It's meant to do exactly that.
With X, on the Mac, and on Windows it calls the appropriate function,  
while the backup is actually the call to set-mouse-position:

from GNU Emacs frame.el:

(defun select-frame-set-input-focus (frame)
   "Select FRAME, raise it, and set input focus, if possible."
     (select-frame frame)
     (raise-frame frame)
     ;; Ensure, if possible, that frame gets input focus.
     (cond ((memq window-system '(x mac))
	   (x-focus-frame frame))
	  ((eq window-system 'w32)
	   (w32-focus-frame frame)))
     (cond (focus-follows-mouse
	   (set-mouse-position (selected-frame) (1- (frame-width)) 0))))


I would probably test for (fboundp `select-frame-set-input-focus)  
before using it. You may need to keep the set-mouse-position business  
for XEmacs or very old versions of GNU Emacs - it's worth checking.

>> Note that the bug only occurs when you have two frames, one with a
>> single window displaying the R source file, one with a single window
>> displaying the *R* process buffer.
>
> Can I clarify?  If the frame containing *R* is currently split to show
> more than one window, you do not see the bug?

Yes. And that's actually quite logical because the input focus seems  
to be frame-wise, and always goes into the selected frame. If the  
frame is split, it has input focus anyways when you do C-c M-j. Then,  
`ess-show-buffer' will do a `select-window' which makes the *R*  
window the selected one and the cursor is where it belongs.

-- D




More information about the ESS-bugs mailing list