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

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

Signature

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

Documentation

Save clipboard image DATA of mime TYPE and insert an @file mention.

Writes the image to a temporary eca-screenshot file, like the eca chat buffer does, and inserts "@/path/to/file " at point so the server picks it up as a file context when the prompt is sent. RET on the mention toggles the image thumbnail.

Source Code

;; Defined in /nix/store/jklqzw6pzz6j4jrbv8wy0iwgi7jlrbld-emacs-packages-deps/share/emacs/site-lisp/elpa/eca-20260928.1827/eca-chat-compose.el
;; Internal

(defun eca-chat-compose--yank-image-handler (type data)
  "Save clipboard image DATA of mime TYPE and insert an @file mention.
Writes the image to a temporary eca-screenshot file, like the eca
chat buffer does, and inserts \"@/path/to/file \" at point so the
server picks it up as a file context when the prompt is sent.  RET
on the mention toggles the image thumbnail."
  (when-let* ((output-path (eca-chat-media--save-clipboard-image type data)))
    (unless (memq (char-before) '(nil ?\s ?\t ?\n))
      (insert " "))
    (let ((start (point)))
      (insert (eca-chat--propertize-image-mention
               (concat eca-chat-context-prefix output-path)
               output-path))
      (eca-chat--add-image-link-overlay start (point)))
    (insert " ")
    (eca-info "Image added, size: %s"
              (file-size-human-readable (file-attribute-size (file-attributes output-path))))))