[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
windows saved in variables, and `save-selected-window'
From: |
Eric Abrahamsen |
Subject: |
windows saved in variables, and `save-selected-window' |
Date: |
Sun, 14 Jun 2020 10:32:30 -0700 |
User-agent: |
Gnus/5.13 (Gnus v5.13) Emacs/28.0.50 (gnu/linux) |
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)))
- windows saved in variables, and `save-selected-window',
Eric Abrahamsen <=