about summary refs log tree commit diff
path: root/elisp.nix
diff options
context:
space:
mode:
authortalyz <kim.lindberger@gmail.com>2020-08-07 15:24:28 +0200
committertalyz <kim.lindberger@gmail.com>2020-08-07 15:24:28 +0200
commit7fd146158ef3d30304560445e277b50c4721cba1 (patch)
tree5cab5aff6b0d03d8a25e4c93f9b3f7f3e38437f8 /elisp.nix
parent9d38d75d818c12c3d60262c4498dec33144e91fc (diff)
downloadnixlib-7fd146158ef3d30304560445e277b50c4721cba1.tar
nixlib-7fd146158ef3d30304560445e277b50c4721cba1.tar.gz
nixlib-7fd146158ef3d30304560445e277b50c4721cba1.tar.bz2
nixlib-7fd146158ef3d30304560445e277b50c4721cba1.tar.lz
nixlib-7fd146158ef3d30304560445e277b50c4721cba1.tar.xz
nixlib-7fd146158ef3d30304560445e277b50c4721cba1.tar.zst
nixlib-7fd146158ef3d30304560445e277b50c4721cba1.zip
Use the native Org mode parsing capabilities of fromElisp...
..for IFD free Org babel file support.
Diffstat (limited to 'elisp.nix')
-rw-r--r--elisp.nix41
1 files changed, 17 insertions, 24 deletions
diff --git a/elisp.nix b/elisp.nix
index 70b1726b1f3e..67654608805b 100644
--- a/elisp.nix
+++ b/elisp.nix
@@ -12,9 +12,9 @@ let
 
 in
 { config
+# emulate `use-package-always-ensure` behavior
 , alwaysEnsure ? false
-, # emulate `use-package-always-ensure` behavior
-  extraEmacsPackages ? epkgs: [ ]
+, extraEmacsPackages ? epkgs: [ ]
 , package ? pkgs.emacs
 , override ? (epkgs: epkgs)
 }:
@@ -23,38 +23,31 @@ let
     Emacs-overlay API breakage notice:
 
     Previously emacsWithPackagesFromUsePackage always added every use-package definition to the closure.
-    Now we will only add packages with `:ensure t`.
+    Now we will only add packages with `:ensure`, `:ensure t` or `:ensure <package name>`.
 
     You can get back the old behaviour by passing `alwaysEnsure = true`.
     For a more in-depth usage example see https://github.com/nix-community/emacs-overlay#extra-library-functionality
   '';
   showNotice = value: if alwaysEnsure then value else builtins.trace ensureNotice value;
 
-  # Note that using .org configurations will result in IFD
-  orgBabelTangeledConfig = pkgs.runCommand "emacs-config.el"
-    { } ''
-    cp ${config} emacs-config.org
-    ${package}/bin/emacs --batch ./emacs-config.org -f org-babel-tangle
-    mv emacs-config.el $out
-  '';
-
-  config' =
+  isOrgModeFile =
     let
       ext = lib.last (builtins.split "\\." (builtins.toString config));
-      t = builtins.typeOf config;
+      type = builtins.typeOf config;
+    in
+      type == "path" && ext == "org";
+
+  configText =
+    let
+      type = builtins.typeOf config;
     in
-    (
-      if t == "string" then config
-      else if t == "path" then (
-        builtins.readFile (
-          if ext == "org" then orgBabelTangeledConfig
-          else config
-        )
-      )
-      else throw "Unsupported type for config: \"${t}\""
-    );
+      if type == "string" then config
+      else if type == "path" then builtins.readFile config
+      else throw "Unsupported type for config: \"${type}\"";
 
-  packages = showNotice (parse.parsePackagesFromUsePackage config' alwaysEnsure);
+  packages = showNotice (parse.parsePackagesFromUsePackage {
+    inherit configText alwaysEnsure isOrgModeFile;
+  });
   emacsPackages = pkgs.emacsPackagesGen package;
   emacsWithPackages = emacsPackages.emacsWithPackages;
   mkPackageError = name: