From mboxrd@z Thu Jan 1 00:00:00 1970 Path: news.gmane.org!not-for-mail From: Andy Stewart Newsgroups: gmane.emacs.help Subject: Re: Trying to return focus to a window Date: Mon, 24 Nov 2008 14:20:57 +0800 Message-ID: <874p1xve46.fsf@debian.domain> References: NNTP-Posting-Host: lo.gmane.org Mime-Version: 1.0 Content-Type: text/plain; charset=us-ascii X-Trace: ger.gmane.org 1227510539 18535 80.91.229.12 (24 Nov 2008 07:08:59 GMT) X-Complaints-To: usenet@ger.gmane.org NNTP-Posting-Date: Mon, 24 Nov 2008 07:08:59 +0000 (UTC) To: help-gnu-emacs@gnu.org Original-X-From: help-gnu-emacs-bounces+geh-help-gnu-emacs=m.gmane.org@gnu.org Mon Nov 24 08:10:02 2008 Return-path: Envelope-to: geh-help-gnu-emacs@m.gmane.org Original-Received: from lists.gnu.org ([199.232.76.165]) by lo.gmane.org with esmtp (Exim 4.50) id 1L4Va2-0001fS-12 for geh-help-gnu-emacs@m.gmane.org; Mon, 24 Nov 2008 08:09:58 +0100 Original-Received: from localhost ([127.0.0.1]:43165 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.43) id 1L4VYs-0000vY-J8 for geh-help-gnu-emacs@m.gmane.org; Mon, 24 Nov 2008 02:08:46 -0500 Original-Received: from mailman by lists.gnu.org with tmda-scanned (Exim 4.43) id 1L4VYY-0000v9-Nb for help-gnu-emacs@gnu.org; Mon, 24 Nov 2008 02:08:26 -0500 Original-Received: from exim by lists.gnu.org with spam-scanned (Exim 4.43) id 1L4VYX-0000uK-KZ for help-gnu-emacs@gnu.org; Mon, 24 Nov 2008 02:08:26 -0500 Original-Received: from [199.232.76.173] (port=46197 helo=monty-python.gnu.org) by lists.gnu.org with esmtp (Exim 4.43) id 1L4VYX-0000u4-GR for help-gnu-emacs@gnu.org; Mon, 24 Nov 2008 02:08:25 -0500 Original-Received: from main.gmane.org ([80.91.229.2]:38794 helo=ciao.gmane.org) by monty-python.gnu.org with esmtps (TLS-1.0:RSA_AES_256_CBC_SHA1:32) (Exim 4.60) (envelope-from ) id 1L4VYW-0000kW-Ns for help-gnu-emacs@gnu.org; Mon, 24 Nov 2008 02:08:25 -0500 Original-Received: from list by ciao.gmane.org with local (Exim 4.43) id 1L4VYU-0003mi-RP for help-gnu-emacs@gnu.org; Mon, 24 Nov 2008 07:08:22 +0000 Original-Received: from 222.212.137.244 ([222.212.137.244]) by main.gmane.org with esmtp (Gmexim 0.1 (Debian)) id 1AlnuQ-0007hv-00 for ; Mon, 24 Nov 2008 07:08:22 +0000 Original-Received: from lazycat.manatee by 222.212.137.244 with local (Gmexim 0.1 (Debian)) id 1AlnuQ-0007hv-00 for ; Mon, 24 Nov 2008 07:08:22 +0000 X-Injected-Via-Gmane: http://gmane.org/ Original-Lines: 47 Original-X-Complaints-To: usenet@ger.gmane.org X-Gmane-NNTP-Posting-Host: 222.212.137.244 User-Agent: Gnus/5.13 (Gnus v5.13) Emacs/23.0.60 (gnu/linux) Cancel-Lock: sha1:p5UpEoui12O2FvYCDsJ1GyPabRw= X-detected-operating-system: by monty-python.gnu.org: GNU/Linux 2.6, seldom 2.4 (older, 4) X-BeenThere: help-gnu-emacs@gnu.org X-Mailman-Version: 2.1.5 Precedence: list List-Id: Users list for the GNU Emacs text editor List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Original-Sender: help-gnu-emacs-bounces+geh-help-gnu-emacs=m.gmane.org@gnu.org Errors-To: help-gnu-emacs-bounces+geh-help-gnu-emacs=m.gmane.org@gnu.org Xref: news.gmane.org gmane.emacs.help:60047 Archived-At: Hi, Kevin. Now i'm debugging it. I have use save-selected-window defadvice. Advice is not problem (although use save-selected-window is simple, but effect same as second advice). But problem is not at advice, is some code make focus on iPython buffer after `py-execute-buffer'. -- Andy. Kevin Rodgers writes: > Richard Riley wrote: >> I have tried two ways to have the focus return to the source >> buffer/window when "execute buffer" is done using python integration >> as outlined here : >> >> http://www.emacswiki.org/emacs/PythonMode#toc10 >> >> The two ways I have tried (both using defadvice) are: >> >> ,---- >> | ;; (defadvice py-execute-buffer (around stay-current-buffer activate) >> | ;; "This advice make cursor stay current position after execute `py-execute-buffer'." >> | ;; (save-excursion >> | ;; ad-do-it) >> | ;; (message "py-execute-function done")) >> | | (defadvice py-execute-buffer (around stay-current-buffer activate) >> | "This advice make cursor stay current position after execute `py-execute-buffer'." >> | (let ((remember-point (point)) >> | (remember-window (selected-window))) >> | ad-do-it >> | (message "focus stuff done") >> | (select-window remember-window) >> | (goto-char remember-point))) >> `---- >> >> But in both cases the cursor stays in the iPython window (same >> frame). Can someone suggest how best to get the cursor back into the >> python buffer when I execute py-execute-buffer? is there something >> fundamentally wrong with the approach I have taken above or a naive code >> error? > > You could try save-selected-window instead of save-excursion.