all messages for Emacs-related lists mirrored at yhetil.org
 help / color / mirror / code / Atom feed
From: martin rudalics <rudalics@gmx.at>
To: jay.p.belanger@gmail.com
Cc: emacs-devel@gnu.org
Subject: Re: save-window-excursion and window-configuration-change-hook	interaction
Date: Tue, 18 May 2010 14:06:56 +0200	[thread overview]
Message-ID: <4BF282E0.8000001@gmx.at> (raw)
In-Reply-To: <87mxvy5mly.fsf@vh213601.truman.edu>

 > Suppose I have two windows; say the top window is active
 > and the bottom window (window WIN, buffer BUF) has
 > ===
 > a
 > b
 > c
 > ===
 > in it, with point before the "a".
 > If I run the command aaa:
 >
 > (defun aaa ()
 >   (interactive)
 >   (with-current-buffer BUF
 >     (save-window-excursion
 >       (select-window WIN)
 >       (search-forward "b"))
 >     (set-window-point WIN (point))))
 >
 > then the point in the bottom window moves to after the "b", which is
 > what I would expect.   However, if the bottom window (with point again
 > before the "a") has a non-nil window-configuration-change-hook,
 > then running aaa does not move the point in the bottom window.  I would
 > expected the point in the bottom window to move as before.
 > (To add the hook, with the bottom window active I did
 >  M-: (add-hook 'window-configuration-change-hook (lambda () ()) nil t)
 > )

IIUC this happens for the following reason:

(1) When you quit the excursion, `set-window-configuration' sets
     `window-point' of WIN to the value it had before since WIN is _not_
     the selected window.

(2) When you now run the buffer local `window-configuration-change-hook'
     it selects WIN to run the hook with WIN selected and BUF current.
     Selecting WIN sets the `point' of BUF to the `window-point' recorded
     for WIN which, however, was reset in step (1) to the value it had
     before entering the excursion.

So the only reasonable solution in your case is to save the the position
after the search and do a `set-window-point' with that saved position.

martin, who never liked the idea of running
`window-configuration-change-hook' locally.



  reply	other threads:[~2010-05-18 12:06 UTC|newest]

Thread overview: 4+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2010-05-17 19:55 save-window-excursion and window-configuration-change-hook interaction Jay Belanger
2010-05-18 12:06 ` martin rudalics [this message]
2010-05-18 18:59   ` Jay Belanger
2010-05-20  9:44     ` martin rudalics

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

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

  git send-email \
    --in-reply-to=4BF282E0.8000001@gmx.at \
    --to=rudalics@gmx.at \
    --cc=emacs-devel@gnu.org \
    --cc=jay.p.belanger@gmail.com \
    /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.
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.