473,396 Members | 1,853 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,396 software developers and data experts.

Stealing focus: emacs, and PIL, in Windows

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.

Nov 25 '05 #1
1 1743
da**********@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

Nov 26 '05 #2

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

2
by: Robert Misiak | last post by:
Is it possible to display a window on top without it stealing focus? (and I'm not talking about stealing focus from my application - I'm talking about it stealing focus from any application.) ...
0
by: gkelly | last post by:
I have an AppBar that works fine, except for one problem. It's stealing focus -The AppBar is written in C# -Access to it is via a COM object -Main app is a C++ app. -Button on app will use...
13
by: M O J O | last post by:
Hi, I need to create a popup form what will not steal focus. I've searched the net and I managed to put some code together. Below is the result of my code, but I have a single question .......
2
by: BluDog | last post by:
Hi I have a borderless form that i am using as a popup, i want to display this form without it stealing focus from the form it pops up over. I do not want to display the form modally, as when...
0
by: criscannon | last post by:
Hi, I need to something like a YM notification window that tells whether a user signs in or out. I am able to use animatewindow to show my form. however, whenever the form is shown, my parent...
1
by: damonwischik | last post by:
I'm using the Python Image Library (PIL) for Python 2.4. If I have an image and I show it from PIL import Image im = Image.new('RGB',100,100) im.show() then the output window steals focus....
21
by: Sharon | last post by:
I have added an auto scroll feature to my DataGrid control like this: private void DoAutoScroll() { DataView dv = m_DataGrid.DataSource as DataView; DataGridCell cell = m_DataGrid.CurrentCell;...
7
by: Dave Booker | last post by:
I am using a WebBrowser object in my .NET 2.0 application, but it is not shown to the user. Every time a timer event triggers it to perform a m_WebBrowser.Navigate() I get that classic IE 'click'...
331
by: Xah Lee | last post by:
http://xahlee.org/emacs/modernization.html ] The Modernization of Emacs ---------------------------------------- THE PROBLEM Emacs is a great editor. It is perhaps the most powerful and...
0
by: ryjfgjl | last post by:
In our work, we often receive Excel tables with data in the same format. If we want to analyze these data, it can be difficult to analyze them because the data is spread across multiple Excel files...
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
0
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
0
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
0
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...
0
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.