Stealing focus: emacs, and PIL, in Windows

damonwischik at gmail.com damonwischik at gmail.com
Fri Nov 25 06:43:20 EST 2005


I'm using GNU Emacs 21.3.1 with python-mode 1.0alpha under Windows XP.
Whenever I execute a command in an edit window (with
py-execute-region), the output window steals the focus. How can I stop
this happening?

I don't know any lisp, but I hacked together this routine so that that
when I press ctrl+return the entire current block is executed.

(defun py-execute-paragraph (vis)
  "Send the current paragraph to Python
Don't know what vis does."
  (interactive "P")
  (save-excursion
    (forward-paragraph)
    (let ((end (point)))
      (backward-paragraph)
      (py-execute-region (point) end ))))
(global-set-key [(ctrl return)] 'py-execute-paragraph)

It seems to me (though I could well be wrong) that the focus stays in
the edit window during the execution of this command (thanks to
save-excursion); but the focus shifts to the command window whenever
there is output, in this case a new prompt ">>>", in the routine
py-comint-output-filter-function. I commented out the command
  (pop-to-buffer (current-buffer))
and now the command window no longer steals focus. But I don't know if
this has any other side effects, or it there's a better way to prevent
focus being stolen.

Damon.




More information about the Python-list mailing list