nix-community / emacs-overlay

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

[Feature Request] Add support for setup.el #395

Open fuzy112 opened 6 months ago

fuzy112 commented 6 months ago

Currently emacsWithPackagesFromUsePackage supports use-package and leaf. It will be helpful to also support setup.el.

fbergroth commented 5 months ago

I'm using setup.el, and wrote this to parse the package names:

parsePackagesFromSetup = configText: let
  inherit (builtins) head tail;
  recurse = inSetup: item:
    if !(builtins.isList item) || item == []
    then []
    else if !inSetup && head item == "setup"
    then recurse true (tail item)
    else if inSetup && head item == ":package"
    then tail item
    else builtins.concatMap (recurse inSetup) item;
in
  ["setup"] ++ (recurse false (fromElisp configText));

packages = parsePackagesFromSetup (builtins.readFile ./init.el);
fuzy112 commented 5 months ago

Fredrik Bergroth @.***> writes:

I'm using setup.el, and wrote this to parse the package names:

parsePackagesFromSetup = configText: let
  inherit (builtins) head tail;
  recurse = inSetup: item:
    if !(builtins.isList item) || item == []
    then []
    else if !inSetup && head item == "setup"
    then recurse true (tail item)
    else if inSetup && head item == ":package"
    then tail item
    else builtins.concatMap (recurse inSetup) item;
in
  ["setup"] ++ (recurse false (fromElisp configText));

packages = parsePackagesFromSetup (builtins.readFile ./init.el);

Hi Fredrik,

Thanks for sharing the snippet. It works like a charm!!! 👍👍