AtlatestRepositorysigil-hooks
sigil-hooks / treeREADME.md
1
# sigil-hooks3
> **Archived at Sigil 0.19.0:** The maintained implementation now lives in4
> `codeberg:sigil/sigil`. This repository and all tags remain available for5
> provenance, but no further standalone releases will be published.7
Emacs-style hook system for Sigil — register named callbacks and run them on event.9
A hook is a list of functions called when a specific event occurs. Multiple10
handlers can be registered for each hook and are invoked in registration order.12
## Usage14
```scheme15
(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
```27
Hooks can also receive arguments via `run-hook-with-args`:29
```scheme30
(define on-file-save (make-hook))32
(add-hook! on-file-save33
(lambda (filename)34
(display "Saved: ") (display filename) (newline)))36
(run-hook-with-args on-file-save "document.txt")37
```39
## Modules41
| 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 & Test47
```bash48
sigil deps install49
sigil build50
sigil test51
```53
## License55
BSD-3-Clause. See [LICENSE](LICENSE) for details.