* windows saved in variables, and `save-selected-window'
@ 2020-06-14 17:32 Eric Abrahamsen
2020-06-15 15:12 ` Michael Heerdegen
0 siblings, 1 reply; 3+ messages in thread
From: Eric Abrahamsen @ 2020-06-14 17:32 UTC (permalink / raw)
To: help-gnu-emacs
I'm writing a minor mode that does a little bit of window management,
including opening two windows on the current buffer, and keeping track
of the two windows in two variables (the variables should be
buffer-local, but I'm seeing the below behavior with regular defvar).
One of the goals is to have a command that conditionally updates what is
displayed in the "other window". The minimum broken version of the code
is below.
During the set up, the two variables *usually* end up pointing to live
windows (ie, #<window 607 on sdfsdgsgdgsg>). Sometimes one of the
variables ends up pointing at a "dead" window: #<window 607>. Either
way, after the use of `save-selected-window' below, one of the windows
is always dead.
Obviously I'm just doing this wrong altogether -- can anyone tell me the
correct approach?
TIA,
Eric
(defvar window-one nil)
(defvar window-two nil)
(define-minor-mode not-a-mode
"" nil " windows" nil
(if (null not-a-mode)
(setq window-one nil
window-two nil)
(split-window-sensibly)
(setq window-one (selected-window))
(other-window 1)
(setq window-two (selected-window))))
(defun update-other-window ()
(interactive)
(save-selected-window
(select-window window-one)
(goto-char (/ (point-max) 2))
(recenter)))
^ permalink raw reply [flat|nested] 3+ messages in thread
* Re: windows saved in variables, and `save-selected-window'
2020-06-14 17:32 windows saved in variables, and `save-selected-window' Eric Abrahamsen
@ 2020-06-15 15:12 ` Michael Heerdegen
2020-06-15 18:18 ` Eric Abrahamsen
0 siblings, 1 reply; 3+ messages in thread
From: Michael Heerdegen @ 2020-06-15 15:12 UTC (permalink / raw)
To: help-gnu-emacs
Eric Abrahamsen <eric@ericabrahamsen.net> writes:
> During the set up, the two variables *usually* end up pointing to live
> windows (ie, #<window 607 on sdfsdgsgdgsg>). Sometimes one of the
> variables ends up pointing at a "dead" window: #<window 607>. Either
> way, after the use of `save-selected-window' below, one of the windows
> is always dead.
>
> Obviously I'm just doing this wrong altogether -- can anyone tell me the
> correct approach?
What does one need to reproduce this? I evaluated your code and enabled
`note-a-mode', and afterwards
(mapcar #'window-live-p (list window-one window-two))
==> (t t)
Also calling (update-other-window) does not change the result.
Michael.
^ permalink raw reply [flat|nested] 3+ messages in thread
* Re: windows saved in variables, and `save-selected-window'
2020-06-15 15:12 ` Michael Heerdegen
@ 2020-06-15 18:18 ` Eric Abrahamsen
0 siblings, 0 replies; 3+ messages in thread
From: Eric Abrahamsen @ 2020-06-15 18:18 UTC (permalink / raw)
To: help-gnu-emacs
Michael Heerdegen <michael_heerdegen@web.de> writes:
> Eric Abrahamsen <eric@ericabrahamsen.net> writes:
>
>> During the set up, the two variables *usually* end up pointing to live
>> windows (ie, #<window 607 on sdfsdgsgdgsg>). Sometimes one of the
>> variables ends up pointing at a "dead" window: #<window 607>. Either
>> way, after the use of `save-selected-window' below, one of the windows
>> is always dead.
>>
>> Obviously I'm just doing this wrong altogether -- can anyone tell me the
>> correct approach?
>
> What does one need to reproduce this? I evaluated your code and enabled
> `note-a-mode', and afterwards
>
> (mapcar #'window-live-p (list window-one window-two))
>
> ==> (t t)
>
> Also calling (update-other-window) does not change the result.
Well damn, after a restart of Emacs I'm no longer seeing the weird
behavior. I can't imagine what I did to get it into that state, but
you're right, it's behaving as expected.
Sorry for the noise, and thanks for testing!
Eric
^ permalink raw reply [flat|nested] 3+ messages in thread
end of thread, other threads:[~2020-06-15 18:18 UTC | newest]
Thread overview: 3+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2020-06-14 17:32 windows saved in variables, and `save-selected-window' Eric Abrahamsen
2020-06-15 15:12 ` Michael Heerdegen
2020-06-15 18:18 ` Eric Abrahamsen
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.