aboutsummaryrefslogtreecommitdiff
path: root/modules/music-config.el
diff options
context:
space:
mode:
authorCraig Jennings <c@cjennings.net>2026-05-27 14:36:57 -0500
committerCraig Jennings <c@cjennings.net>2026-05-27 14:36:57 -0500
commit84d8ab6a3ad97697a717a770c42010e9ec9076e5 (patch)
tree3abf00cdbce3e04b4afb22cb80b346b9e2eeeb0b /modules/music-config.el
parent8635f7d2221f92763247e2330070f1c0796d23d7 (diff)
downloaddotemacs-84d8ab6a3ad97697a717a770c42010e9ec9076e5.tar.gz
dotemacs-84d8ab6a3ad97697a717a770c42010e9ec9076e5.zip
feat(window): remember a side window's size across toggles
The F10 music playlist opened at a fixed fraction every time, so any manual resize was lost the moment it was toggled closed. Now the toggle captures the window's size on close and reopens at that height, for the rest of the session. The mechanism is generic, not music-specific. cj/window-size-fraction (geometry-lib) is the pure kernel: a clamped window/frame ratio. cj/side-window-capture-size and cj/side-window-display (toggle-lib) wrap it for any display-buffer-in-side-window consumer — height for top/bottom, width for left/right — storing the remembered fraction in a caller-supplied state var. It mirrors the direction-split toggle pattern the vterm dispatchers already use, but for atomic side windows that can't be split. music-config wires F10 to it: cj/music-playlist-window-height is the default, cj/--music-playlist-height holds the remembered value (in-memory, resets each session). 12 new tests across the two libs, Normal/Boundary/Error each covered.
Diffstat (limited to 'modules/music-config.el')
-rw-r--r--modules/music-config.el20
1 files changed, 18 insertions, 2 deletions
diff --git a/modules/music-config.el b/modules/music-config.el
index 197c73be..fd619d8c 100644
--- a/modules/music-config.el
+++ b/modules/music-config.el
@@ -94,6 +94,7 @@
(require 'subr-x)
(require 'user-constants)
(require 'keybindings) ;; provides cj/custom-keymap
+(require 'cj-window-toggle-lib) ;; side-window size memory (F10 toggle)
;;; Settings (no Customize)
@@ -513,20 +514,35 @@ Intended for use on `emms-player-finished-hook'."
)
+(defvar cj/music-playlist-window-height 0.3
+ "Default fraction of frame height for the F10 music playlist side window.
+Used until the playlist is resized and toggled off this session; after that,
+the toggled-off height is remembered in `cj/--music-playlist-height'.")
+
+(defvar cj/--music-playlist-height nil
+ "Last height fraction the playlist side window was toggled off at.
+nil means fall back to `cj/music-playlist-window-height'. In-memory only --
+resets each Emacs session.")
+
(defun cj/music-playlist-toggle ()
- "Toggle the EMMS playlist buffer in a bottom side window."
+ "Toggle the EMMS playlist buffer in a bottom side window.
+The window opens at `cj/music-playlist-window-height'; if it has been
+resized and toggled off this session, it reopens at that remembered height."
(interactive)
(let* ((buf-name cj/music-playlist-buffer-name)
(buffer (get-buffer buf-name))
(win (and buffer (get-buffer-window buffer))))
(if win
(progn
+ (cj/side-window-capture-size win 'bottom 'cj/--music-playlist-height)
(delete-window win)
(message "Playlist window closed"))
(progn
(cj/emms--setup)
(setq buffer (cj/music--ensure-playlist-buffer))
- (setq win (display-buffer-in-side-window buffer '((side . bottom) (window-height . 0.5))))
+ (setq win (cj/side-window-display
+ buffer 'bottom 'cj/--music-playlist-height
+ cj/music-playlist-window-height))
(select-window win)
(with-current-buffer buffer
(if (and (fboundp 'emms-playlist-current-selected-track)