unofficial mirror of help-gnu-emacs@gnu.org
 help / color / mirror / Atom feed
From: Kevin Rodgers <kevin.d.rodgers@gmail.com>
To: help-gnu-emacs@gnu.org
Subject: Re: Trying to return focus to a window
Date: Sun, 23 Nov 2008 21:46:34 -0700	[thread overview]
Message-ID: <ggdbj3$ur$1@ger.gmane.org> (raw)
In-Reply-To: <ggcgsg$jnj$1@news.motzarella.org>

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





  reply	other threads:[~2008-11-24  4:46 UTC|newest]

Thread overview: 3+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2008-11-23 21:10 Trying to return focus to a window Richard Riley
2008-11-24  4:46 ` Kevin Rodgers [this message]
2008-11-24  6:20   ` Andy Stewart

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

  List information: https://www.gnu.org/software/emacs/

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to='ggdbj3$ur$1@ger.gmane.org' \
    --to=kevin.d.rodgers@gmail.com \
    --cc=help-gnu-emacs@gnu.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).