aboutsummaryrefslogtreecommitdiff
path: root/modules/ai-term.el
diff options
context:
space:
mode:
authorCraig Jennings <c@cjennings.net>2026-06-15 21:54:55 -0500
committerCraig Jennings <c@cjennings.net>2026-06-15 21:54:55 -0500
commit60f14d2c1aa5074f23ec5bccfa0d233ec6730bdb (patch)
tree6f25f635232f0f9b79877e57090b4ea9eacc0b86 /modules/ai-term.el
parentea46c4a90c9f2de94cdb6ab4e47e744a9506ee37 (diff)
downloaddotemacs-60f14d2c1aa5074f23ec5bccfa0d233ec6730bdb.tar.gz
dotemacs-60f14d2c1aa5074f23ec5bccfa0d233ec6730bdb.zip
feat(ai-term): dock the agent window by frame aspect ratio
The agent window now docks from whichever edge conserves more space, chosen at display time: right on a landscape frame, bottom on a square or portrait one, replacing the host (laptop/desktop) branch. cj/--ai-term-direction-for-aspect is the pure decision; default-size pairs the width or height fraction with it.
Diffstat (limited to 'modules/ai-term.el')
-rw-r--r--modules/ai-term.el36
1 files changed, 22 insertions, 14 deletions
diff --git a/modules/ai-term.el b/modules/ai-term.el
index baf752fe7..49d44d25e 100644
--- a/modules/ai-term.el
+++ b/modules/ai-term.el
@@ -391,22 +391,30 @@ fallback when `cj/--ai-term-last-size' is nil."
:type 'number
:group 'ai-term)
-(defun cj/--ai-term-default-direction ()
- "Return the host-appropriate default split direction for the agent window.
-
-`below' on a laptop (bottom horizontal split), `right' on a desktop
-(right-side vertical split). Detected via `env-laptop-p'."
- (if (env-laptop-p) 'below 'right))
+(defun cj/--ai-term-direction-for-aspect (pixel-width pixel-height)
+ "Return the space-conserving dock direction for a frame of PIXEL-WIDTH by
+PIXEL-HEIGHT. `right' when the frame is wider than tall (dock from the right
+edge), `below' when it is square or taller (dock from the bottom)."
+ (if (> pixel-width pixel-height) 'right 'below))
+
+(defun cj/--ai-term-default-direction (&optional frame)
+ "Return the default split direction for the agent window.
+
+Chosen at display time from FRAME's pixel aspect ratio (FRAME defaults to the
+selected frame): `right' on a landscape frame, `below' on a square or portrait
+one -- whichever edge conserves more screen space."
+ (let ((frame (or frame (selected-frame))))
+ (cj/--ai-term-direction-for-aspect (frame-pixel-width frame)
+ (frame-pixel-height frame))))
(defun cj/--ai-term-default-size ()
- "Return the host-appropriate default size fraction for the agent window.
-
-`cj/ai-term-laptop-height' on a laptop, `cj/ai-term-desktop-width'
-on a desktop -- pairing with the axis chosen by
-`cj/--ai-term-default-direction'."
- (if (env-laptop-p)
- cj/ai-term-laptop-height
- cj/ai-term-desktop-width))
+ "Return the default size fraction paired with the chosen direction.
+
+`cj/ai-term-desktop-width' (a width fraction) when the default direction is
+`right', `cj/ai-term-laptop-height' (a height fraction) when it is `below'."
+ (if (eq (cj/--ai-term-default-direction) 'right)
+ cj/ai-term-desktop-width
+ cj/ai-term-laptop-height))
(defvar cj/--ai-term-last-direction nil
"Last user-chosen direction for the AI-term display.