// EMACS-AWK — ENGINEERING REPORT

Emacs major mode for AWK (awkrs) · font-lock for keywords, built-in vars/funcs, fields, /regex/ · run via awkrs · LSP via awkrs --lsp (eglot + lsp-mode) · verified with batch face assertions

>_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.

22
Builtin functions
16
Built-in variables
20
Keywords
$0..$NF
Field references
2
LSP clients (eglot + lsp-mode)
3
Detection paths (ext + 2 shebangs)
15
Face assertions
27.1
Min Emacs version

~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.

ComponentDetail
awkrs-mode.elMajor 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.elHand-authored builtin-function signatures (POSIX awk + gawk extensions awkrs accepts) for eldoc and completion. Byte-compiles cleanly; loads instantly.
scripts/face-test.elFontify a sample buffer and assert the face at each probe token.
awkrs --lspLaunched 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 tokenAsserted face
BEGIN / END / function / for / next / print / printffont-lock-keyword-face
FS / NR / NFawkrs-builtin-var-face
length / substr / toupperfont-lock-builtin-face
summarize (user function name)font-lock-function-name-face
double-quoted stringfont-lock-string-face
# commentfont-lock-comment-face