>_EXECUTIVE SUMMARY
emacs-awk is the Emacs major mode for AWK, targeting the awkrs Rust implementation. awkrs-mode derives from prog-mode and provides font-lock, a syntax table, brace-aware indentation, filetype detection, a buffer runner (awkrs -f FILE via compile), eldoc + completion for builtin functions, and an LSP client that launches awkrs --lsp.
Design principle: the highlighted surface is AWK's actual, fixed language surface — keywords, built-in variables, built-in functions, field references, and /regex/ literals. Because AWK has a small finite builtin set (unlike the sibling stryke with its ~10,450 generated builtins), the lists are plain regexp-opt alternations in awkrs-mode.el; no generated hash-table stdlib is required. The mode is named awkrs-mode so it never clashes with Emacs' built-in CC-Mode awk-mode.
~WHY NO GENERATED STDLIB
The sibling emacs-stryke generates a 170 KB stryke-stdlib.el of hash tables because a single regexp-opt over stryke's ~10,450 builtins overflows Emacs' regexp compiler (invalid-regexp "Regular expression too big"). AWK has no such problem: its builtin surface is fixed by the language spec — 20 keywords, 16 built-in variables, 22 built-in functions — comfortably within the regexp-size limit. So awkrs-mode.el uses plain regexp-opt alternations, and awkrs-stdlib.el holds only the hand-authored builtin-function signatures used for eldoc and completion-at-point. Field references and /regex/ literals (which division a / b must not be mistaken for) are matched with a dedicated regexp and a syntax-propertize rule that only fires in operand position.
| Component | Detail |
|---|---|
awkrs-mode.el | Major mode — syntax table (# comments, string quotes, sigils as punctuation), font-lock keyword list, /regex/ syntax-propertize, awkrs-indent-line, awkrs-run-buffer (C-c C-c), eldoc + completion, eglot + lsp-mode registration, auto-mode-alist + interpreter-mode-alist. |
awkrs-stdlib.el | Hand-authored builtin-function signatures (POSIX awk + gawk extensions awkrs accepts) for eldoc and completion. Byte-compiles cleanly; loads instantly. |
scripts/face-test.el | Fontify a sample buffer and assert the face at each probe token. |
awkrs --lsp | Launched with only --lsp; an appended --stdio is rejected by the binary, so neither client adds one. |
$VERIFICATION
CI byte-compiles the package with byte-compile-error-on-warn (warnings are errors) and runs the batch face test. Each probe asserts the actual face text-property after font-lock-ensure.
| Sample token | Asserted face |
|---|---|
BEGIN / END / function / for / next / print / printf | font-lock-keyword-face |
FS / NR / NF | awkrs-builtin-var-face |
length / substr / toupper | font-lock-builtin-face |
summarize (user function name) | font-lock-function-name-face |
| double-quoted string | font-lock-string-face |
# comment | font-lock-comment-face |