Make interactive commands asynchronous #1
Loading…
Add table
Add a link
Reference in a new issue
No description provided.
Delete branch "%!s()"
Deleting a branch is permanent. Although the deleted branch may continue to exist for a short time before it actually gets removed, it CANNOT be undone in most cases. Continue?
Problem
The interactive commands
incus-create,incus-start,incus-stop, andincus-deletecall the synchronousincus--runfunction, which usesshell-command-to-string. This blocks Emacs until the subprocess finishes. Container creation is the worst offender (it downloads an image), but stop and delete can also take noticeable time.Solution
1. Add
incus--run-asyncAdd a new internal function:
Implementation notes:
make-processwith a:sentinel.:commandshould be(cons incus-executable args).\\bError\\b(same logic asincus--run).The synchronous
incus--runremains unchanged for quick queries (e.g.,incus--parse-list,incus-container-exists-p).2. Convert interactive commands
Convert these four commands to use
incus--run-async:incus-createShow "Creating container NAME…" immediately. On success, show "Created container NAME from IMAGE" and refresh the list buffer. On failure, show "Failed to create NAME: OUTPUT".
incus-startShow "Starting container NAME…" immediately. On success, show "Started NAME".
incus-stopShow "Stopping container NAME…" immediately. On success, show "Stopped NAME".
incus-deleteThe confirmation prompt (
yes-or-no-p) stays synchronous. After confirmation, show "Deleting container NAME…" immediately. On success, show "Deleted NAME" and refresh the list buffer.3. What stays the same
incus--run(synchronous) is unchanged.incus-launch,incus-start-container,incus-stop-container,incus-delete-container(low-level API) remain synchronous.incus-lsremains synchronous.