nix-community / emacs-overlay

Bleeding edge emacs overlay [maintainer=@adisbladis]
505 stars 165 forks source link

How to debug the emacsWithPackagesFromUsePackage parser #374

Closed ParetoOptimalDev closed 3 months ago

ParetoOptimalDev commented 10 months ago

I had some issues that I weren't sure were:

That meant I needed to debug it. There isn't an easy way to do that currently.

Assuming you have the emacs-overlay repo locally just open nix-repl and follow the log below.

Full nix-repl log demonstrating debugging parser ``` nix-repl> pkgs = import {} nix-repl> parse = pkgs.callPackage ./parse.nix { } nix-repl> let configExampleTxt = '' (use-package org :commands org-mode :bind (("C-c a" . org-agenda) :map org-mode-map ([C-right] . org-demote-subtree) ([C-left] . org-promote-subtree))) (use-package direnv :ensure t :config (direnv-mode)) (use-package paredit-mode :ensure paredit :hook (emacs-lisp-mode lisp-mode lisp-interaction-mode)) ''; # Note that isOrgModeFile is false nix-repl> parse.parsePackagesFromUsePackage {configText = configExampleTxt; alwaysEnsure = true; isOrgModeFile = false; alwaysTangle = true; } parse.parsePackagesFromUsePackage {configText = configExampleTxt; alwaysEnsure = true; isOrgModeFile = false; alwaysTangle = true; } [ "use-package" "org" "use-package" "direnv" "use-package" "paredit" ] nix-repl> let config = pkgs.lib.readFile "/tmp/simple.org"; in parse.parsePackagesFromUsePackage {configText = config; alwaysEnsure = true; isOrgModeFile = true; alwaysTangle = true; } let config = pkgs.lib.readFile "/tmp/simple.org"; in parse.parsePackagesFromUsePackage {configText = config; alwaysEnsure = true; isOrgModeFile = true; alwaysTangle = true; } [ "use-package" "org" "use-package" "direnv" "use-package" "paredit" ] nix-repl> let configPath = "/tmp/simple.org"; config = pkgs.lib.readFile configPath; packageList = parse.parsePackagesFromUsePackage {configText = config; alwaysEnsure = true; isOrgModeFile = true; alwaysTangle = true; }; dedupedPackages = pkgs.lib.naturalSort (pkgs.lib.unique packageList); packagesStr = (pkgs.lib.concatStringsSep "\n" dedupedPackages); in pkgs.lib.trace "\n${packagesStr}" "" let configPath = "/tmp/simple.org"; config = pkgs.lib.readFile configPath; packageList = parse.parsePackagesFromUsePackage {configText = config; alwaysEnsure = true; isOrgModeFile = true; alwaysTangle = true; }; dedupedPackages = pkgs.lib.naturalSort (pkgs.lib.unique packageList); packagesStr = (pkgs.lib.concatStringsSep "\n" dedupedPackages); in pkgs.lib.trace "\n${packagesStr}" "" trace: direnv org paredit use-package "" ```

Question: Would it be worth adding a debug output to the flake so that code like the above could be called on an elisp or org file directly like:

nix eval --impure --apply "p: p.debugParser({configText = config; alwaysEnsure = true; isOrgModeFile = true; alwaysTangle = true; })" github:nix-community/emacs-overlay#debug
573 commented 10 months ago

+1

adisbladis commented 3 months ago

This issue belongs in https://github.com/talyz/fromElisp