From: Thierry Volpiatto <thierry.volpiatto@gmail.com>
To: Stefan Monnier <monnier@IRO.UMontreal.CA>
Cc: martin rudalics <rudalics@gmx.at>, emacs-devel@gnu.org
Subject: Re: window.el modify current emacs23 behavior of anything.
Date: Wed, 21 Sep 2011 08:34:09 +0200 [thread overview]
Message-ID: <87ipom8kv2.fsf@gmail.com> (raw)
In-Reply-To: <jwvbouej2gh.fsf-monnier+emacs@gnu.org> (Stefan Monnier's message of "Tue, 20 Sep 2011 18:08:25 -0400")
Stefan Monnier <monnier@IRO.UMontreal.CA> writes:
>> When `bury-buffer' restores the buffer previously shown in the selected
>> window, it also restores that buffer's `window-start' and `window-point'
>> position in the window. If the window is selected, this implicitly
>> moves the buffer's point to the window's point. This means that if the
>> restored buffer's point was changed before calling `bury-buffer', that
>> position is lost.
>
> Oh, I see the problem:
>
> Try M-: (progn (set-window-start (selected-window) (point)) (goto-char (point-min)))
>
> and you'll see the that set-window-point wins even though it's run
> before the goto-char.
>
> That's why a sit-for works around the problem: it causes the
> set-window-start to be "executed", letting the subsequent goto-char do
> its job.
>
> So maybe the right fix is to remove the call to set-window-start.
Using the NOFORCE arg of `set-window-start' seem to fix problem in
anything, but don't know if it can create problems in other places:
#+BEGIN_SRC lisp
(defun set-window-buffer-start-and-point (window buffer &optional start point)
"Set WINDOW's buffer to BUFFER.
Optional argument START non-nil means set WINDOW's start position
to START. Optional argument POINT non-nil means set WINDOW's
point to POINT. If WINDOW is selected this also sets BUFFER's
`point' to POINT. If WINDOW is selected and the buffer it showed
before was current this also makes BUFFER the current buffer."
(let ((selected (eq window (selected-window)))
(current (eq (window-buffer window) (current-buffer))))
(set-window-buffer window buffer)
(when (and selected current)
(set-buffer buffer))
(when start
(set-window-start window start t)) ;; Use noforce arg.
(when point
(if selected
(with-current-buffer buffer
(goto-char point))
(set-window-point window point)))))
#+END_SRC
`set-window-buffer-start-and-point' is called by
`switch-to-prev-buffer' which is called by `bury-buffer'.
--
A+ Thierry
Get my Gnupg key:
gpg --keyserver pgp.mit.edu --recv-keys 59F29997
next prev parent reply other threads:[~2011-09-21 6:34 UTC|newest]
Thread overview: 24+ messages / expand[flat|nested] mbox.gz Atom feed top
2011-09-12 6:04 window.el modify current emacs23 behavior of anything Thierry Volpiatto
2011-09-12 6:38 ` Thierry Volpiatto
2011-09-12 7:22 ` Thierry Volpiatto
2011-09-12 7:24 ` Eli Zaretskii
2011-09-12 8:52 ` Thierry Volpiatto
2011-09-12 9:03 ` martin rudalics
2011-09-12 23:26 ` Thierry Volpiatto
2011-09-13 18:28 ` martin rudalics
2011-09-13 19:12 ` Thierry Volpiatto
2011-09-16 16:36 ` Thierry Volpiatto
2011-09-16 17:10 ` martin rudalics
2011-09-16 19:34 ` Thierry Volpiatto
2011-09-17 8:42 ` martin rudalics
2011-09-17 17:06 ` Thierry Volpiatto
2011-09-17 17:28 ` martin rudalics
2011-09-18 9:08 ` Thierry Volpiatto
2011-09-19 19:35 ` Stefan Monnier
2011-09-20 16:07 ` martin rudalics
2011-09-20 22:08 ` Stefan Monnier
2011-09-21 6:34 ` Thierry Volpiatto [this message]
2011-09-21 8:35 ` martin rudalics
2011-09-21 8:34 ` martin rudalics
2011-09-21 12:59 ` Stefan Monnier
-- strict thread matches above, loose matches on Subject: below --
2011-09-16 14:23 Dmitry Gutov
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=87ipom8kv2.fsf@gmail.com \
--to=thierry.volpiatto@gmail.com \
--cc=emacs-devel@gnu.org \
--cc=monnier@IRO.UMontreal.CA \
--cc=rudalics@gmx.at \
/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 public inbox
https://git.savannah.gnu.org/cgit/emacs.git
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).