* Trying to return focus to a window
@ 2008-11-23 21:10 Richard Riley
2008-11-24 4:46 ` Kevin Rodgers
0 siblings, 1 reply; 3+ messages in thread
From: Richard Riley @ 2008-11-23 21:10 UTC (permalink / raw)
To: help-gnu-emacs
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?
thanks,
r.
^ permalink raw reply [flat|nested] 3+ messages in thread
* Re: Trying to return focus to a window
2008-11-23 21:10 Trying to return focus to a window Richard Riley
@ 2008-11-24 4:46 ` Kevin Rodgers
2008-11-24 6:20 ` Andy Stewart
0 siblings, 1 reply; 3+ messages in thread
From: Kevin Rodgers @ 2008-11-24 4:46 UTC (permalink / raw)
To: help-gnu-emacs
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.
--
Kevin Rodgers
Denver, Colorado, USA
^ permalink raw reply [flat|nested] 3+ messages in thread
* Re: Trying to return focus to a window
2008-11-24 4:46 ` Kevin Rodgers
@ 2008-11-24 6:20 ` Andy Stewart
0 siblings, 0 replies; 3+ messages in thread
From: Andy Stewart @ 2008-11-24 6:20 UTC (permalink / raw)
To: help-gnu-emacs
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 <kevin.d.rodgers@gmail.com> 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.
^ permalink raw reply [flat|nested] 3+ messages in thread
end of thread, other threads:[~2008-11-24 6:20 UTC | newest]
Thread overview: 3+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2008-11-23 21:10 Trying to return focus to a window Richard Riley
2008-11-24 4:46 ` Kevin Rodgers
2008-11-24 6:20 ` Andy Stewart
Code repositories for project(s) associated with this external index
https://git.savannah.gnu.org/cgit/emacs.git
https://git.savannah.gnu.org/cgit/emacs/org-mode.git
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.