Function: eca-chat--yank-image-handler

eca-chat--yank-image-handler is a natively compiled function defined in eca-chat-context.el.

Signature

(eca-chat--yank-image-handler TYPE DATA)

Documentation

Handler for yank-media to insert images from clipboard.

TYPE is the MIME type (e.g., image/png). DATA is the binary image data as a string.

Source Code

;; Defined in /nix/store/jklqzw6pzz6j4jrbv8wy0iwgi7jlrbld-emacs-packages-deps/share/emacs/site-lisp/elpa/eca-20260928.1827/eca-chat-context.el
(defun eca-chat--yank-image-handler (type data)
  "Handler for `yank-media' to insert images from clipboard.
TYPE is the MIME type (e.g., image/png).
DATA is the binary image data as a string."
  (when-let* ((session (eca-session))
              (chat-buffer (eca-chat--get-last-buffer session))
              (output-path (eca-chat-media--save-clipboard-image type data)))
    (eca-chat--with-current-buffer chat-buffer
      (let ((context (list :type "file" :path output-path))
            (file-size (file-size-human-readable (file-attribute-size (file-attributes output-path)))))
        (eca-chat--select-window)
        (if (eq 'system eca-chat-yank-image-context-location)
            (eca-chat--add-context context)
          (goto-char (eca-chat--insert-prompt
                      (concat (eca-chat--context->str context 'static) " "))))
        (eca-info "Image added, size: %s" file-size)))))