AtlatestRepositorysigil-hooks
1# sigil-hooks
2
3Emacs-style hook system for Sigil — register named callbacks and run them on event.
4
5A hook is a list of functions called when a specific event occurs. Multiple
6handlers can be registered for each hook and are invoked in registration order.
7
8## Usage
9
10```scheme
11(import (sigil hooks))
13(define on-save (make-hook))
15(add-hook! on-save (lambda () (display "Saved!\n")))
16(add-hook! on-save (lambda () (display "Logged.\n")))
18(run-hook on-save)
19;; prints: Saved!
20;; Logged.
21```
23Hooks can also receive arguments via `run-hook-with-args`:
25```scheme
26(define on-file-save (make-hook))
28(add-hook! on-file-save
29 (lambda (filename)
30 (display "Saved: ") (display filename) (newline)))
32(run-hook-with-args on-file-save "document.txt")
33```
35## Modules
37| Module | Purpose |
38|-----------------|----------------------------------------------------------------|
39| `(sigil hooks)` | Core hook API: `make-hook`, `add-hook!`, `remove-hook!`, `clear-hook!`, `run-hook`, `run-hook-with-args`, `hook?`, `hook-empty?`. |
41## Build & Test
43```bash
44sigil deps install
45sigil build
46sigil test
47```
49## License
51BSD-3-Clause. See [LICENSE](LICENSE) for details.