Stealing focus: emacs, and PIL, in Windows

Graham Fawcett graham.fawcett at gmail.com
Sat Nov 26 13:05:13 EST 2005


damonwischik at gmail.com wrote:
> 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?
[snip]
> 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.

For someone who says he doesn't know Lisp, you seem to be doing just
fine. :-)

Not sure if there would be side-effects. Note that py-execute-string,
py-execute-buffer, py-execute-def-or-class all use py-execute-region.
Their behaviour may be altered by your change. But it would be easy to
test.

If you did encounter a problematic side-effect, you could define your
own "py-execute-region-custom" as a copy of py-execute-region but with
the (pop-to-buffer) call removed. Then use

  (require 'python-mode)  ;; if you're putting this in .emacs
  (define-key py-mode-map "\C-c|"     'py-execute-region-custom)

to redefine the keyboard mapping.  (The (require 'python-mode) call
ensures that the py-mode-map variable has been initialized.) You could
provide an alternate mapping for your new function, of course.

If you put the custom function and your define-key call both in your
.emacs file, then you can easily port it to other machines (perh.
easier than maintaining a patch for python-mode).

Graham




More information about the Python-list mailing list