Skip to content

About

Run mise tasks from Emacs — discovery, execution, cancellation via compilation-mode

Resources

Stars

5 stars

Watchers

1 watching

Forks

Latest commit

 

History

24 Commits

Folders and files

Repository files navigation

mise-tasks.el

Run mise tasks from Emacs. Discovers, executes, and cancels long-running tasks with a compilation-mode buffer per project. Plays nicely with Projectile.

Complements the existing env-injection packages like mise.el. mise-tasks covers the task-runner side.

Features

  • Runs tasks, not just env. Other existing mise Emacs packages focus on injecting environment variables — none run tasks. mise-tasks fills that gap and stays out of env handling, so it composes cleanly on top of whichever env package you already use.
  • Fits your existing workflow. mise-tasks-projectile-mode reroutes projectile-compile-project (SPC p c) through mise inside mise projects, and leaves it untouched everywhere else — so picking a task uses muscle memory you already have.
  • Monorepo support. Auto-detects experimental_monorepo_root = true and engages mise's experimental monorepo discovery, including setting MISE_EXPERIMENTAL=1 in the subprocess env, which GUI Emacs sessions on macOS otherwise miss.
  • Task discovery via mise tasks --json: global tasks (~/.config/mise/config.toml), project tasks (mise.toml), and gitignored override tasks (mise.local.toml).
  • Works with any completion UI. Task descriptions and [global] scope markers show through standard annotation-function metadata that vertico, marginalia, helm, ivy, and default completion all render — and when a global and project task share a name, both stay selectable via a [scope:source] suffix.
  • Process management. Tasks run through compile, so C-c C-k / M-x kill-compilation works as you expect, and mise-tasks-kill adds a SIGINT-then-SIGKILL escalation for anything that ignores the first signal. Each project gets its own *mise: <project>* buffer, so re-runs reuse it and different projects run concurrently.
  • Trust deferred to mise. The package never grants trust itself. When a project's config is not trusted yet, mise-tasks-run / mise-tasks-list raise a clear error telling you to run the stock mise trust command. Mise persists trust in its own state directory, so future sessions never re-prompt — and an automatic caller (find-file hook, projectile-switch-project action) can never fire a trust dialog by accident.
  • Last-task memory. mise-tasks-run-last re-runs the last task you picked in this project.
  • Lockfile highlighting. mise-tasks-lock-mode fontifies mise.lock / mise.local.lock files, emphasising the mise-specific tokens on top of the base TOML highlighting.

Install

Not yet on MELPA. For now, clone and add to load-path:

(add-to-list 'load-path "~/path/to/mise-tasks")
(require 'mise-tasks)

Spacemacs

You can add mise-tasks into dotspacemacs-additional-packages section:

  (mise-tasks :location (recipe :fetcher github :repo "klochowicz/mise-tasks.el")

and, inside your user-config, configure desired keybindings (example below):

(defun dotspacemacs/user-config ()
  (require 'mise-tasks)
  (spacemacs/declare-prefix "pm" "mise")
  (spacemacs/set-leader-keys
    "pmm" '("run task"      . mise-tasks-run)
    "pmr" '("re-run last"   . mise-tasks-run-last)
    "pml" '("list tasks"    . mise-tasks-list)
    "pmk" '("kill running"  . mise-tasks-kill))
  ;; Optional: route SPC p c to mise-tasks-run in mise projects.
  ;; Non-mise projects keep the default projectile-compile-project.
  (mise-tasks-projectile-mode 1))

Routing projectile-compile-project through mise

mise-tasks-projectile-mode is a global minor mode that advises projectile-compile-project. With it on:

  • Inside a mise project (any of mise.toml, .mise.toml, mise.local.toml, mise/config.toml, .mise/config.toml, .config/mise.toml, .config/mise/config.toml found by walking up from default-directory): the call is dispatched to mise-tasks-run, so picking a task uses your existing SPC p c muscle memory.
  • Outside a mise project: the original projectile-compile-project runs unchanged, so the binding stays useful everywhere.

Opt in once with (mise-tasks-projectile-mode 1); disable with (mise-tasks-projectile-mode -1).

Commands

Command Purpose
mise-tasks-run Pick a task and run it. C-u prefix prompts for extra args appended after --.
mise-tasks-run-last Re-run the last task in this project.
mise-tasks-list Tabulated browser of tasks. RET runs, g refreshes, k kills.
mise-tasks-kill SIGINT the running task; repeat to SIGKILL.

Lockfile syntax highlighting

mise-tasks-lock-mode is a major mode for mise lockfiles. It is registered in auto-mode-alist automatically, so mise.lock and mise.local.lock open with highlighting — no configuration needed.

It derives from the built-in conf-toml-mode (a lockfile is just TOML), then layers on emphasis for the tokens unique to a lockfile:

Token Example
@generated marker # @generated … (flagged so you don't hand-edit)
Tool name [[tools.node]]
Platform "platforms.linux-arm64"
Backend kind backend = "core:node"
Checksum algorithm checksum = "sha256:…"

Colours come from your theme's standard font-lock faces.

Environment management

There are no plans to add this functionality here; I recommend using mise.el for this.

Customisation

;; Override monorepo detection
(setq mise-tasks-monorepo-mode 'auto)                  ; 'always | 'never

;; Disable experimental env-var injection
(setq mise-tasks-experimental-env nil)

Discovery

Calls mise tasks --json --no-header once at the project root. When experimental_monorepo_root = true is found in the root config, also passes --all and sets MISE_EXPERIMENTAL=1 in the subprocess env so mise's monorepo task discovery engages even in GUI Emacs sessions that don't inherit your shell environment.

If mise reports that the config is not trusted, discovery raises a user-error telling you to run the stock mise trust command. The package never grants trust itself — that guarantees no automatic caller (find-file hooks, projectile-switch-project-action, eager auto-compile, custom mode hooks) can ever pop a trust dialog when you open a project.

Trust is mise's own concern: run mise trust in the project once (it covers nested parents) and mise persists the result in its own state directory (~/.local/state/mise/trusted-configs/), so subsequent sessions need nothing further.

Development

CI on GitHub Actions runs against Emacs 28.1, 29.4, and 30.1 snapshot.

Parts of this package were written with the assistance of Claude Code, as disclosed in the Assisted-by file header per MELPA's attribution guidelines. All code is reviewed, tested, and maintained by the author.

License

GPL-3.0-or-later. See LICENSE.

About

Run mise tasks from Emacs — discovery, execution, cancellation via compilation-mode

Resources

Stars

5 stars

Watchers

1 watching

Forks

Releases

Packages

Used by

Contributors

Languages