Function: eca-chat--key-pressed-return

eca-chat--key-pressed-return is an interactive and natively compiled function defined in eca-chat.el.

Signature

(eca-chat--key-pressed-return)

Documentation

Send the current prompt to eca process if in prompt.

Key Bindings

eca-chat-mode-map RET

Source Code

;; Defined in /nix/store/jklqzw6pzz6j4jrbv8wy0iwgi7jlrbld-emacs-packages-deps/share/emacs/site-lisp/elpa/eca-20260928.1827/eca-chat.el
(defun eca-chat--key-pressed-return ()
  "Send the current prompt to eca process if in prompt."
  (interactive)
  (eca-chat--allow-write
   (let* ((session (eca-session))
          (prompt (eca-chat--prompt-content))
          (freeform-question (eca-chat--freeform-question)))
     (cond
      ;; check if completion popup is active
      ((eca-chat--completion-active-p)
       (eca-chat--completion-accept))

      ;; toggle the thumbnail of the image mention at point; handled
      ;; here since font-lock strips `keymap' text properties
      ((when-let* ((link (eca-chat--image-link-at (point))))
         (eca-chat--toggle-image-thumbnail link)
         t))

      ;; check it's an actionable text
      ((-some->> (thing-at-point 'symbol) (get-text-property 0 'eca-button-on-action))
       (-some->> (thing-at-point 'symbol)
         (get-text-property 0 'eca-button-on-action)
         (funcall)))

      ;; check is inside a expandable text
      ((eca-chat--expandable-content-at-point)
       (let ((ov (eca-chat--expandable-content-at-point)))
         (eca-chat--expandable-content-toggle (overlay-get ov 'eca-chat--expandable-content-id))))

      ;; follow markdown link [text](url) or a bare URL, even when the URL
      ;; is wrapped in emphasis like **https://...** (face is then a list,
      ;; so check membership instead of `eq' against a single symbol).
      ((eca-chat--face-at-point-member-p '(markdown-link-face
                                           markdown-url-face
                                           markdown-plain-url-face))
       (eca-chat--follow-link-at-point))

      ;; pending question + freeform allowed — answer with prompt text,
      ;; clearing it even when other questions are left to answer
      ((and freeform-question
            (not (string-empty-p prompt)))
       (eca-chat--answer-question freeform-question prompt)
       (eca-chat--set-prompt ""))

      ;; pending question — block normal send/steer
      (eca-chat--pending-questions nil)

      ;; check prompt
      ((and (not (string-empty-p prompt))
            (not eca-chat--chat-loading))
       (eca-chat--send-prompt session prompt))

      ((and (not (string-empty-p prompt))
            eca-chat--chat-loading)
       (eca-chat--steer-prompt session prompt))

      (t nil)))))