From a2e41803d7d29a43ed37a5cf9fd7fe53ca5c15b5 Mon Sep 17 00:00:00 2001 From: Craig Jennings Date: Sun, 10 May 2026 15:28:31 -0500 Subject: refactor(cj-window-toggle): rename to cj-window-toggle-lib for naming consistency Rename modules/cj-window-toggle.el -> modules/cj-window-toggle-lib.el and tests/test-cj-window-toggle.el -> tests/test-cj-window-toggle-lib.el. Update provide forms, file headers, and the (require 'cj-window-toggle) call sites in ai-vterm.el, vterm-config.el, and the test file. Same rationale as the cj-cache and cj-org-text renames -- library files in this codebase are suffixed `-lib'. No behavior change. --- modules/ai-vterm.el | 2 +- modules/cj-window-toggle-lib.el | 85 +++++++++++++++++ modules/cj-window-toggle.el | 85 ----------------- modules/vterm-config.el | 2 +- tests/test-cj-window-toggle-lib.el | 188 +++++++++++++++++++++++++++++++++++++ tests/test-cj-window-toggle.el | 188 ------------------------------------- 6 files changed, 275 insertions(+), 275 deletions(-) create mode 100644 modules/cj-window-toggle-lib.el delete mode 100644 modules/cj-window-toggle.el create mode 100644 tests/test-cj-window-toggle-lib.el delete mode 100644 tests/test-cj-window-toggle.el diff --git a/modules/ai-vterm.el b/modules/ai-vterm.el index 482f6522..7181c227 100644 --- a/modules/ai-vterm.el +++ b/modules/ai-vterm.el @@ -37,7 +37,7 @@ (require 'cl-lib) (require 'seq) (require 'cj-window-geometry) -(require 'cj-window-toggle) +(require 'cj-window-toggle-lib) (declare-function vterm "vterm" (&optional buffer-name)) (declare-function vterm-send-string "vterm" (string &optional paste-p)) diff --git a/modules/cj-window-toggle-lib.el b/modules/cj-window-toggle-lib.el new file mode 100644 index 00000000..868ee99f --- /dev/null +++ b/modules/cj-window-toggle-lib.el @@ -0,0 +1,85 @@ +;;; cj-window-toggle-lib.el --- Shared toggle-state helpers for display-buffer dispatchers -*- lexical-binding: t; -*- + +;; Author: Craig Jennings + +;;; Commentary: + +;; Parameterized helpers used by ai-vterm.el (F9) and +;; vterm-config.el (F12) to capture a window's geometry at +;; toggle-off and replay it on the next toggle-on. Each consumer +;; holds its own pair of state variables (last-direction symbol + +;; last-size integer/float) and passes the variable symbols to the +;; helpers. Both helpers are pure with respect to their arguments; +;; the side effects are confined to the named state variables. +;; +;; Pulls the geometry primitives in from cj-window-geometry.el. + +;;; Code: + +(require 'cl-lib) +(require 'cj-window-geometry) + +(defun cj/window-toggle-capture-state (window default-direction + direction-var size-var) + "Write WINDOW's direction and body size into DIRECTION-VAR and SIZE-VAR. + +DEFAULT-DIRECTION is the symbol used by `cj/window-direction' when +WINDOW fills its frame's root area. DIRECTION-VAR and SIZE-VAR are +the symbols of the consumer's state variables; they receive the +captured values via `set'. + +No-op when WINDOW is nil or not live." + (when (window-live-p window) + (let* ((dir (cj/window-direction window default-direction)) + (size (cj/window-body-size window dir))) + (set direction-var dir) + (set size-var size)))) + +(defun cj/window-toggle-display-saved (buffer alist + direction-var default-direction + size-var default-size) + "Display-buffer action: split per saved DIRECTION-VAR and SIZE-VAR. + +Reads the consumer's stored direction and size through DIRECTION-VAR +and SIZE-VAR (symbols); falls back to DEFAULT-DIRECTION and +DEFAULT-SIZE when the stored values are nil. The cardinal direction +is mapped to its frame-edge variant via +`cj/cardinal-to-edge-direction' so the new buffer always lands at +the same frame edge regardless of the selected window. An integer +size is wrapped in a `(body-columns . N)' / `(body-lines . N)' cons +so `display-buffer-in-direction' sets the body explicitly, +divider-independent. A float size passes through as a fraction of +the new window's parent. + +Caller-supplied ALIST entries for direction, window-width, or +window-height are stripped before delegating to +`display-buffer-in-direction' so the saved-state values control +placement; the remaining alist entries are passed through." + (let* ((stored-dir (and (boundp direction-var) (symbol-value direction-var))) + (stored-size (and (boundp size-var) (symbol-value size-var))) + (direction (or stored-dir default-direction)) + (edge-direction (or (cj/cardinal-to-edge-direction direction) + (cj/cardinal-to-edge-direction default-direction))) + (size (or stored-size default-size)) + (size-key (if (memq direction '(right left)) + 'window-width + 'window-height)) + (body-tag (if (memq direction '(right left)) + 'body-columns + 'body-lines)) + (size-value (if (integerp size) + (cons body-tag size) + size)) + (filtered (cl-remove-if + (lambda (cell) + (memq (car-safe cell) + '(direction window-width window-height))) + alist)) + (effective (append + (list (cons 'direction edge-direction) + (cons size-key size-value)) + filtered))) + (display-buffer-in-direction buffer effective))) + +(provide 'cj-window-toggle-lib) +;;; cj-window-toggle-lib.el ends here diff --git a/modules/cj-window-toggle.el b/modules/cj-window-toggle.el deleted file mode 100644 index 2aa66ac9..00000000 --- a/modules/cj-window-toggle.el +++ /dev/null @@ -1,85 +0,0 @@ -;;; cj-window-toggle.el --- Shared toggle-state helpers for display-buffer dispatchers -*- lexical-binding: t; -*- - -;; Author: Craig Jennings - -;;; Commentary: - -;; Parameterized helpers used by ai-vterm.el (F9) and -;; vterm-config.el (F12) to capture a window's geometry at -;; toggle-off and replay it on the next toggle-on. Each consumer -;; holds its own pair of state variables (last-direction symbol + -;; last-size integer/float) and passes the variable symbols to the -;; helpers. Both helpers are pure with respect to their arguments; -;; the side effects are confined to the named state variables. -;; -;; Pulls the geometry primitives in from cj-window-geometry.el. - -;;; Code: - -(require 'cl-lib) -(require 'cj-window-geometry) - -(defun cj/window-toggle-capture-state (window default-direction - direction-var size-var) - "Write WINDOW's direction and body size into DIRECTION-VAR and SIZE-VAR. - -DEFAULT-DIRECTION is the symbol used by `cj/window-direction' when -WINDOW fills its frame's root area. DIRECTION-VAR and SIZE-VAR are -the symbols of the consumer's state variables; they receive the -captured values via `set'. - -No-op when WINDOW is nil or not live." - (when (window-live-p window) - (let* ((dir (cj/window-direction window default-direction)) - (size (cj/window-body-size window dir))) - (set direction-var dir) - (set size-var size)))) - -(defun cj/window-toggle-display-saved (buffer alist - direction-var default-direction - size-var default-size) - "Display-buffer action: split per saved DIRECTION-VAR and SIZE-VAR. - -Reads the consumer's stored direction and size through DIRECTION-VAR -and SIZE-VAR (symbols); falls back to DEFAULT-DIRECTION and -DEFAULT-SIZE when the stored values are nil. The cardinal direction -is mapped to its frame-edge variant via -`cj/cardinal-to-edge-direction' so the new buffer always lands at -the same frame edge regardless of the selected window. An integer -size is wrapped in a `(body-columns . N)' / `(body-lines . N)' cons -so `display-buffer-in-direction' sets the body explicitly, -divider-independent. A float size passes through as a fraction of -the new window's parent. - -Caller-supplied ALIST entries for direction, window-width, or -window-height are stripped before delegating to -`display-buffer-in-direction' so the saved-state values control -placement; the remaining alist entries are passed through." - (let* ((stored-dir (and (boundp direction-var) (symbol-value direction-var))) - (stored-size (and (boundp size-var) (symbol-value size-var))) - (direction (or stored-dir default-direction)) - (edge-direction (or (cj/cardinal-to-edge-direction direction) - (cj/cardinal-to-edge-direction default-direction))) - (size (or stored-size default-size)) - (size-key (if (memq direction '(right left)) - 'window-width - 'window-height)) - (body-tag (if (memq direction '(right left)) - 'body-columns - 'body-lines)) - (size-value (if (integerp size) - (cons body-tag size) - size)) - (filtered (cl-remove-if - (lambda (cell) - (memq (car-safe cell) - '(direction window-width window-height))) - alist)) - (effective (append - (list (cons 'direction edge-direction) - (cons size-key size-value)) - filtered))) - (display-buffer-in-direction buffer effective))) - -(provide 'cj-window-toggle) -;;; cj-window-toggle.el ends here diff --git a/modules/vterm-config.el b/modules/vterm-config.el index 5acf3363..9cf07abd 100644 --- a/modules/vterm-config.el +++ b/modules/vterm-config.el @@ -25,7 +25,7 @@ (require 'seq) (require 'subr-x) (require 'cj-window-geometry) -(require 'cj-window-toggle) +(require 'cj-window-toggle-lib) (defvar-keymap cj/vterm-map :doc "Personal vterm command map.") diff --git a/tests/test-cj-window-toggle-lib.el b/tests/test-cj-window-toggle-lib.el new file mode 100644 index 00000000..2c4ea831 --- /dev/null +++ b/tests/test-cj-window-toggle-lib.el @@ -0,0 +1,188 @@ +;;; test-cj-window-toggle-lib.el --- Tests for shared toggle-state helpers -*- lexical-binding: t; -*- + +;;; Commentary: +;; cj-window-toggle-lib.el provides parameterized capture-state and +;; display-saved helpers shared by ai-vterm.el (F9) and +;; eshell-vterm-config.el (F12). Each consumer holds its own pair of +;; state variables (last-direction symbol + last-size integer/float) +;; and passes the variable symbols to the helpers. These tests cover +;; the helpers in isolation against a fresh pair of test-only vars. + +;;; Code: + +(require 'ert) +(require 'cl-lib) + +(add-to-list 'load-path (expand-file-name "modules" user-emacs-directory)) +(require 'cj-window-toggle-lib) + +(defvar test-cj-window-toggle--last-direction nil) +(defvar test-cj-window-toggle--last-size nil) + +(ert-deftest test-cj-window-toggle-capture-records-right-split () + "Normal: right-split window writes direction=right and integer body-cols." + (save-window-excursion + (delete-other-windows) + (let ((right (split-window (selected-window) nil 'right)) + (test-cj-window-toggle--last-direction nil) + (test-cj-window-toggle--last-size nil)) + (cj/window-toggle-capture-state + right 'right + 'test-cj-window-toggle--last-direction + 'test-cj-window-toggle--last-size) + (should (eq test-cj-window-toggle--last-direction 'right)) + (should (integerp test-cj-window-toggle--last-size)) + (should (= test-cj-window-toggle--last-size + (window-body-width right)))))) + +(ert-deftest test-cj-window-toggle-capture-records-below-split () + "Normal: below-split window writes direction=below and integer body-lines." + (save-window-excursion + (delete-other-windows) + (let ((below (split-window (selected-window) nil 'below)) + (test-cj-window-toggle--last-direction nil) + (test-cj-window-toggle--last-size nil)) + (cj/window-toggle-capture-state + below 'below + 'test-cj-window-toggle--last-direction + 'test-cj-window-toggle--last-size) + (should (eq test-cj-window-toggle--last-direction 'below)) + (should (integerp test-cj-window-toggle--last-size)) + (should (= test-cj-window-toggle--last-size + (window-body-height below)))))) + +(ert-deftest test-cj-window-toggle-capture-falls-back-to-default-direction () + "Boundary: window filling the frame uses the supplied default direction." + (save-window-excursion + (delete-other-windows) + (let ((root (selected-window)) + (test-cj-window-toggle--last-direction nil) + (test-cj-window-toggle--last-size nil)) + (cj/window-toggle-capture-state + root 'below + 'test-cj-window-toggle--last-direction + 'test-cj-window-toggle--last-size) + (should (eq test-cj-window-toggle--last-direction 'below))))) + +(ert-deftest test-cj-window-toggle-capture-noop-on-nil-window () + "Error: nil window leaves both state vars unchanged." + (let ((test-cj-window-toggle--last-direction 'sentinel-dir) + (test-cj-window-toggle--last-size 0.123)) + (cj/window-toggle-capture-state + nil 'right + 'test-cj-window-toggle--last-direction + 'test-cj-window-toggle--last-size) + (should (eq test-cj-window-toggle--last-direction 'sentinel-dir)) + (should (= test-cj-window-toggle--last-size 0.123)))) + +(ert-deftest test-cj-window-toggle-capture-noop-on-deleted-window () + "Error: a deleted window leaves both state vars unchanged." + (let ((test-cj-window-toggle--last-direction 'sentinel-dir) + (test-cj-window-toggle--last-size 0.123) + (dead (save-window-excursion + (delete-other-windows) + (let ((w (split-window (selected-window) nil 'right))) + (delete-window w) + w)))) + (cj/window-toggle-capture-state + dead 'right + 'test-cj-window-toggle--last-direction + 'test-cj-window-toggle--last-size) + (should (eq test-cj-window-toggle--last-direction 'sentinel-dir)) + (should (= test-cj-window-toggle--last-size 0.123)))) + +(ert-deftest test-cj-window-toggle-display-saved-uses-defaults-when-state-nil () + "Normal: nil state -> direction=edge of default, size=default." + (let (received-alist + (test-cj-window-toggle--last-direction nil) + (test-cj-window-toggle--last-size nil)) + (cl-letf (((symbol-function 'display-buffer-in-direction) + (lambda (_b a) (setq received-alist a) 'fake-window))) + (cj/window-toggle-display-saved + 'fake-buf + '((inhibit-same-window . t)) + 'test-cj-window-toggle--last-direction + 'below + 'test-cj-window-toggle--last-size + 0.7)) + (should (eq (cdr (assq 'direction received-alist)) 'bottom)) + (should (= (cdr (assq 'window-height received-alist)) 0.7)) + (should (eq (cdr (assq 'inhibit-same-window received-alist)) t)))) + +(ert-deftest test-cj-window-toggle-display-saved-maps-below-to-bottom () + "Normal: saved below + integer size -> bottom edge, body-lines cons." + (let (received-alist + (test-cj-window-toggle--last-direction 'below) + (test-cj-window-toggle--last-size 12)) + (cl-letf (((symbol-function 'display-buffer-in-direction) + (lambda (_b a) (setq received-alist a) 'fake-window))) + (cj/window-toggle-display-saved + 'fake-buf nil + 'test-cj-window-toggle--last-direction + 'below + 'test-cj-window-toggle--last-size + 0.7)) + (should (eq (cdr (assq 'direction received-alist)) 'bottom)) + (should (equal (cdr (assq 'window-height received-alist)) + '(body-lines . 12))) + (should-not (assq 'window-width received-alist)))) + +(ert-deftest test-cj-window-toggle-display-saved-maps-right-to-rightmost () + "Normal: saved right + integer size -> rightmost edge, body-columns cons." + (let (received-alist + (test-cj-window-toggle--last-direction 'right) + (test-cj-window-toggle--last-size 80)) + (cl-letf (((symbol-function 'display-buffer-in-direction) + (lambda (_b a) (setq received-alist a) 'fake-window))) + (cj/window-toggle-display-saved + 'fake-buf nil + 'test-cj-window-toggle--last-direction + 'right + 'test-cj-window-toggle--last-size + 0.5)) + (should (eq (cdr (assq 'direction received-alist)) 'rightmost)) + (should (equal (cdr (assq 'window-width received-alist)) + '(body-columns . 80))) + (should-not (assq 'window-height received-alist)))) + +(ert-deftest test-cj-window-toggle-display-saved-strips-conflicting-entries () + "Boundary: caller-supplied direction/size are removed; saved values win." + (let (received-alist + (test-cj-window-toggle--last-direction 'right) + (test-cj-window-toggle--last-size 30)) + (cl-letf (((symbol-function 'display-buffer-in-direction) + (lambda (_b a) (setq received-alist a) 'fake-window))) + (cj/window-toggle-display-saved + 'fake-buf + '((direction . above) + (window-width . 0.2) + (window-height . 0.3) + (inhibit-same-window . t)) + 'test-cj-window-toggle--last-direction + 'right + 'test-cj-window-toggle--last-size + 0.5)) + (should (eq (cdr (assq 'direction received-alist)) 'rightmost)) + (should (equal (cdr (assq 'window-width received-alist)) + '(body-columns . 30))) + (should-not (assq 'window-height received-alist)) + (should (eq (cdr (assq 'inhibit-same-window received-alist)) t)))) + +(ert-deftest test-cj-window-toggle-display-saved-passes-float-size-through () + "Boundary: float size passes through as a fraction (no body-N wrapping)." + (let (received-alist + (test-cj-window-toggle--last-direction 'below) + (test-cj-window-toggle--last-size nil)) + (cl-letf (((symbol-function 'display-buffer-in-direction) + (lambda (_b a) (setq received-alist a) 'fake-window))) + (cj/window-toggle-display-saved + 'fake-buf nil + 'test-cj-window-toggle--last-direction + 'below + 'test-cj-window-toggle--last-size + 0.4)) + (should (eq (cdr (assq 'direction received-alist)) 'bottom)) + (should (= (cdr (assq 'window-height received-alist)) 0.4)))) + +(provide 'test-cj-window-toggle-lib) +;;; test-cj-window-toggle-lib.el ends here diff --git a/tests/test-cj-window-toggle.el b/tests/test-cj-window-toggle.el deleted file mode 100644 index c6273463..00000000 --- a/tests/test-cj-window-toggle.el +++ /dev/null @@ -1,188 +0,0 @@ -;;; test-cj-window-toggle.el --- Tests for shared toggle-state helpers -*- lexical-binding: t; -*- - -;;; Commentary: -;; cj-window-toggle.el provides parameterized capture-state and -;; display-saved helpers shared by ai-vterm.el (F9) and -;; eshell-vterm-config.el (F12). Each consumer holds its own pair of -;; state variables (last-direction symbol + last-size integer/float) -;; and passes the variable symbols to the helpers. These tests cover -;; the helpers in isolation against a fresh pair of test-only vars. - -;;; Code: - -(require 'ert) -(require 'cl-lib) - -(add-to-list 'load-path (expand-file-name "modules" user-emacs-directory)) -(require 'cj-window-toggle) - -(defvar test-cj-window-toggle--last-direction nil) -(defvar test-cj-window-toggle--last-size nil) - -(ert-deftest test-cj-window-toggle-capture-records-right-split () - "Normal: right-split window writes direction=right and integer body-cols." - (save-window-excursion - (delete-other-windows) - (let ((right (split-window (selected-window) nil 'right)) - (test-cj-window-toggle--last-direction nil) - (test-cj-window-toggle--last-size nil)) - (cj/window-toggle-capture-state - right 'right - 'test-cj-window-toggle--last-direction - 'test-cj-window-toggle--last-size) - (should (eq test-cj-window-toggle--last-direction 'right)) - (should (integerp test-cj-window-toggle--last-size)) - (should (= test-cj-window-toggle--last-size - (window-body-width right)))))) - -(ert-deftest test-cj-window-toggle-capture-records-below-split () - "Normal: below-split window writes direction=below and integer body-lines." - (save-window-excursion - (delete-other-windows) - (let ((below (split-window (selected-window) nil 'below)) - (test-cj-window-toggle--last-direction nil) - (test-cj-window-toggle--last-size nil)) - (cj/window-toggle-capture-state - below 'below - 'test-cj-window-toggle--last-direction - 'test-cj-window-toggle--last-size) - (should (eq test-cj-window-toggle--last-direction 'below)) - (should (integerp test-cj-window-toggle--last-size)) - (should (= test-cj-window-toggle--last-size - (window-body-height below)))))) - -(ert-deftest test-cj-window-toggle-capture-falls-back-to-default-direction () - "Boundary: window filling the frame uses the supplied default direction." - (save-window-excursion - (delete-other-windows) - (let ((root (selected-window)) - (test-cj-window-toggle--last-direction nil) - (test-cj-window-toggle--last-size nil)) - (cj/window-toggle-capture-state - root 'below - 'test-cj-window-toggle--last-direction - 'test-cj-window-toggle--last-size) - (should (eq test-cj-window-toggle--last-direction 'below))))) - -(ert-deftest test-cj-window-toggle-capture-noop-on-nil-window () - "Error: nil window leaves both state vars unchanged." - (let ((test-cj-window-toggle--last-direction 'sentinel-dir) - (test-cj-window-toggle--last-size 0.123)) - (cj/window-toggle-capture-state - nil 'right - 'test-cj-window-toggle--last-direction - 'test-cj-window-toggle--last-size) - (should (eq test-cj-window-toggle--last-direction 'sentinel-dir)) - (should (= test-cj-window-toggle--last-size 0.123)))) - -(ert-deftest test-cj-window-toggle-capture-noop-on-deleted-window () - "Error: a deleted window leaves both state vars unchanged." - (let ((test-cj-window-toggle--last-direction 'sentinel-dir) - (test-cj-window-toggle--last-size 0.123) - (dead (save-window-excursion - (delete-other-windows) - (let ((w (split-window (selected-window) nil 'right))) - (delete-window w) - w)))) - (cj/window-toggle-capture-state - dead 'right - 'test-cj-window-toggle--last-direction - 'test-cj-window-toggle--last-size) - (should (eq test-cj-window-toggle--last-direction 'sentinel-dir)) - (should (= test-cj-window-toggle--last-size 0.123)))) - -(ert-deftest test-cj-window-toggle-display-saved-uses-defaults-when-state-nil () - "Normal: nil state -> direction=edge of default, size=default." - (let (received-alist - (test-cj-window-toggle--last-direction nil) - (test-cj-window-toggle--last-size nil)) - (cl-letf (((symbol-function 'display-buffer-in-direction) - (lambda (_b a) (setq received-alist a) 'fake-window))) - (cj/window-toggle-display-saved - 'fake-buf - '((inhibit-same-window . t)) - 'test-cj-window-toggle--last-direction - 'below - 'test-cj-window-toggle--last-size - 0.7)) - (should (eq (cdr (assq 'direction received-alist)) 'bottom)) - (should (= (cdr (assq 'window-height received-alist)) 0.7)) - (should (eq (cdr (assq 'inhibit-same-window received-alist)) t)))) - -(ert-deftest test-cj-window-toggle-display-saved-maps-below-to-bottom () - "Normal: saved below + integer size -> bottom edge, body-lines cons." - (let (received-alist - (test-cj-window-toggle--last-direction 'below) - (test-cj-window-toggle--last-size 12)) - (cl-letf (((symbol-function 'display-buffer-in-direction) - (lambda (_b a) (setq received-alist a) 'fake-window))) - (cj/window-toggle-display-saved - 'fake-buf nil - 'test-cj-window-toggle--last-direction - 'below - 'test-cj-window-toggle--last-size - 0.7)) - (should (eq (cdr (assq 'direction received-alist)) 'bottom)) - (should (equal (cdr (assq 'window-height received-alist)) - '(body-lines . 12))) - (should-not (assq 'window-width received-alist)))) - -(ert-deftest test-cj-window-toggle-display-saved-maps-right-to-rightmost () - "Normal: saved right + integer size -> rightmost edge, body-columns cons." - (let (received-alist - (test-cj-window-toggle--last-direction 'right) - (test-cj-window-toggle--last-size 80)) - (cl-letf (((symbol-function 'display-buffer-in-direction) - (lambda (_b a) (setq received-alist a) 'fake-window))) - (cj/window-toggle-display-saved - 'fake-buf nil - 'test-cj-window-toggle--last-direction - 'right - 'test-cj-window-toggle--last-size - 0.5)) - (should (eq (cdr (assq 'direction received-alist)) 'rightmost)) - (should (equal (cdr (assq 'window-width received-alist)) - '(body-columns . 80))) - (should-not (assq 'window-height received-alist)))) - -(ert-deftest test-cj-window-toggle-display-saved-strips-conflicting-entries () - "Boundary: caller-supplied direction/size are removed; saved values win." - (let (received-alist - (test-cj-window-toggle--last-direction 'right) - (test-cj-window-toggle--last-size 30)) - (cl-letf (((symbol-function 'display-buffer-in-direction) - (lambda (_b a) (setq received-alist a) 'fake-window))) - (cj/window-toggle-display-saved - 'fake-buf - '((direction . above) - (window-width . 0.2) - (window-height . 0.3) - (inhibit-same-window . t)) - 'test-cj-window-toggle--last-direction - 'right - 'test-cj-window-toggle--last-size - 0.5)) - (should (eq (cdr (assq 'direction received-alist)) 'rightmost)) - (should (equal (cdr (assq 'window-width received-alist)) - '(body-columns . 30))) - (should-not (assq 'window-height received-alist)) - (should (eq (cdr (assq 'inhibit-same-window received-alist)) t)))) - -(ert-deftest test-cj-window-toggle-display-saved-passes-float-size-through () - "Boundary: float size passes through as a fraction (no body-N wrapping)." - (let (received-alist - (test-cj-window-toggle--last-direction 'below) - (test-cj-window-toggle--last-size nil)) - (cl-letf (((symbol-function 'display-buffer-in-direction) - (lambda (_b a) (setq received-alist a) 'fake-window))) - (cj/window-toggle-display-saved - 'fake-buf nil - 'test-cj-window-toggle--last-direction - 'below - 'test-cj-window-toggle--last-size - 0.4)) - (should (eq (cdr (assq 'direction received-alist)) 'bottom)) - (should (= (cdr (assq 'window-height received-alist)) 0.4)))) - -(provide 'test-cj-window-toggle) -;;; test-cj-window-toggle.el ends here -- cgit v1.2.3