Skip to content

shell-maker--curl-version-supported blocks UI on every prompt submit #35

Description

@plvoit

Bug: shell-maker--curl-version-supported blocks UI on every prompt submit

Summary

shell-maker--curl-version-supported calls shell-command-to-string synchronously
on every prompt submission, blocking the Emacs UI for several seconds.

Call stack

shell-maker--curl-version-supported()
shell-maker--clear-input-for-execution(...)
shell-maker-submit()

Root cause

shell-maker.el:1296:

(defun shell-maker--curl-version-supported ()
  "Return t if curl version is 7.76 or newer, nil otherwise."
  (let ((curl-version-string (shell-command-to-string
                               (concat shell-maker-curl-executable " --version "))))
    (when (string-match "\\([0-9]+\\.[0-9]+\\.[0-9]+\\)" curl-version-string)
      (let ((version (match-string 1 curl-version-string)))
        (version<= "7.76" version)))))

The curl version never changes at runtime, so re-checking it on every submission
is unnecessary. The blocking shell-command-to-string call stalls the UI thread
until curl exits (~5 seconds on some systems).

Fix

Cache the result after the first call:

(defvar shell-maker--curl-version-supported-cache 'unchecked)

(defun shell-maker--curl-version-supported ()
  "Return t if curl version is 7.76 or newer, nil otherwise."
  (when (eq shell-maker--curl-version-supported-cache 'unchecked)
    (setq shell-maker--curl-version-supported-cache
          (let ((str (shell-command-to-string
                      (concat shell-maker-curl-executable " --version "))))
            (when (string-match "\\([0-9]+\\.[0-9]+\\.[0-9]+\\)" str)
              (version<= "7.76" (match-string 1 str))))))
  shell-maker--curl-version-supported-cache)

The sentinel 'unchecked distinguishes "not yet run" from nil (curl too old /
not found), so the failure path is also cached correctly.

Environment

  • Emacs 29.x, Linux
  • shell-maker 20260512.1253

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions