AtlatestRepositorysigil-hooks
1# sigil-hooks
2
3> **Archived at Sigil 0.19.0:** The maintained implementation now lives in
4> `codeberg:sigil/sigil`. This repository and all tags remain available for
5> provenance, but no further standalone releases will be published.
6
7Emacs-style hook system for Sigil — register named callbacks and run them on event.
8
9A hook is a list of functions called when a specific event occurs. Multiple
10handlers can be registered for each hook and are invoked in registration order.
12## Usage
14```scheme
15(import (sigil hooks))
17(define on-save (make-hook))
19(add-hook! on-save (lambda () (display "Saved!\n")))
20(add-hook! on-save (lambda () (display "Logged.\n")))
22(run-hook on-save)
23;; prints: Saved!
24;; Logged.
25```
27Hooks can also receive arguments via `run-hook-with-args`:
29```scheme
30(define on-file-save (make-hook))
32(add-hook! on-file-save
33 (lambda (filename)
34 (display "Saved: ") (display filename) (newline)))
36(run-hook-with-args on-file-save "document.txt")
37```
39## Modules
41| Module | Purpose |
42|-----------------|----------------------------------------------------------------|
43| `(sigil hooks)` | Core hook API: `make-hook`, `add-hook!`, `remove-hook!`, `clear-hook!`, `run-hook`, `run-hook-with-args`, `hook?`, `hook-empty?`. |
45## Build & Test
47```bash
48sigil deps install
49sigil build
50sigil test
51```
53## License
55BSD-3-Clause. See [LICENSE](LICENSE) for details.