Commit 19c16e76ac9c

Vincent Demeester <vincent@sbr.pm>
2025-12-05 14:34:28
ci: Add Emacs Lisp byte-compile pre-commit hook
- Catch syntax errors in elisp files before they reach production - Exclude generated and legacy files from validation - Improve code quality for Emacs configuration Co-Authored-By: Claude <noreply@anthropic.com>
1 parent f1cfca0
Changed files (2)
flake.lock
@@ -808,11 +808,11 @@
     },
     "nixpkgs_2": {
       "locked": {
-        "lastModified": 1763966396,
-        "narHash": "sha256-6eeL1YPcY1MV3DDStIDIdy/zZCDKgHdkCmsrLJFiZf0=",
+        "lastModified": 1764667669,
+        "narHash": "sha256-7WUCZfmqLAssbDqwg9cUDAXrSoXN79eEEq17qhTNM/Y=",
         "owner": "NixOS",
         "repo": "nixpkgs",
-        "rev": "5ae3b07d8d6527c42f17c876e404993199144b6a",
+        "rev": "418468ac9527e799809c900eda37cbff999199b6",
         "type": "github"
       },
       "original": {
flake.nix
@@ -216,6 +216,31 @@
             ruff.enable = true;
             # shell
             shellcheck.enable = true;
+            # emacs lisp - basic syntax checking
+            elisp-byte-compile = {
+              enable = true; # Disabled by default, can be enabled manually
+              name = "Emacs Lisp byte-compile";
+              entry =
+                let
+                  pkgs = import inputs.nixpkgs { inherit system; };
+                  # Create a wrapper that runs Emacs byte-compilation
+                  elisp-check = pkgs.writeShellScript "elisp-check" ''
+                    ${pkgs.emacs}/bin/emacs --batch \
+                      --eval "(setq byte-compile-error-on-warn t)" \
+                      -f batch-byte-compile "$@"
+                  '';
+                in
+                toString elisp-check;
+              files = "\\.el$";
+              excludes = [
+                "tools/emacs/old/.*"
+                "tools/emacs/elpa/.*"
+                "tools/emacs/transient/.*"
+                "tools/emacs/custom\\.el"
+                "tools/emacs/\\.chatgpt-shell\\.el"
+                "\\.dir-locals\\.el"
+              ];
+            };
           };
         };
       });