Function: eca-chat--resolve-image-max-width

eca-chat--resolve-image-max-width is a natively compiled function defined in eca-chat-image.el.

Signature

(eca-chat--resolve-image-max-width)

Documentation

Resolve eca-chat-image-max-width to a pixel value or nil.

Returns nil when no width cap should be applied. When the user selected fit-window the base is the chat window body width in pixels (or the frame width when no window is currently displayed), clamped to eca-chat-image-window-fit-cap from above. The base is then multiplied by the buffer-local eca-chat-image-scale zoom factor and clamped to a 50-pixel floor.

Source Code

;; Defined in /nix/store/jklqzw6pzz6j4jrbv8wy0iwgi7jlrbld-emacs-packages-deps/share/emacs/site-lisp/elpa/eca-20260928.1827/eca-chat-image.el
(defun eca-chat--resolve-image-max-width ()
  "Resolve `eca-chat-image-max-width' to a pixel value or nil.
Returns nil when no width cap should be applied.  When the user
selected `fit-window' the base is the chat window body width in
pixels (or the frame width when no window is currently displayed),
clamped to `eca-chat-image-window-fit-cap' from above.  The base is
then multiplied by the buffer-local `eca-chat-image-scale' zoom
factor and clamped to a 50-pixel floor."
  (let ((base (pcase eca-chat-image-max-width
                ('nil nil)
                ('fit-window
                 (let* ((win (get-buffer-window (current-buffer)))
                        (avail (if win
                                   (window-body-width win t)
                                 (frame-pixel-width))))
                   (max 100 (min eca-chat-image-window-fit-cap avail))))
                ((and (pred integerp) n) n)
                (_ nil))))
    (when base
      (max 50 (round (* base (or eca-chat-image-scale 1.0)))))))