diff options
author | Alyssa Ross <hi@alyssa.is> | 2023-08-31 17:17:49 +0000 |
---|---|---|
committer | Alyssa Ross <hi@alyssa.is> | 2023-08-31 17:17:49 +0000 |
commit | ac456d475f4e50818499b804359355c0f3b4bbf7 (patch) | |
tree | 939e349186040e6011dca1f6b9cf4c6edeb14544 /overlays/patches/emacs/overlay/parse.nix | |
parent | f5938ba5bb25b6810b879f2b83f69ca8ee4f0f94 (diff) | |
download | nixlib-ac456d475f4e50818499b804359355c0f3b4bbf7.tar nixlib-ac456d475f4e50818499b804359355c0f3b4bbf7.tar.gz nixlib-ac456d475f4e50818499b804359355c0f3b4bbf7.tar.bz2 nixlib-ac456d475f4e50818499b804359355c0f3b4bbf7.tar.lz nixlib-ac456d475f4e50818499b804359355c0f3b4bbf7.tar.xz nixlib-ac456d475f4e50818499b804359355c0f3b4bbf7.tar.zst nixlib-ac456d475f4e50818499b804359355c0f3b4bbf7.zip |
modules/emacs: switch to emacs29-pgtk
It's finally released!
Diffstat (limited to 'overlays/patches/emacs/overlay/parse.nix')
-rw-r--r-- | overlays/patches/emacs/overlay/parse.nix | 156 |
1 files changed, 0 insertions, 156 deletions
diff --git a/overlays/patches/emacs/overlay/parse.nix b/overlays/patches/emacs/overlay/parse.nix deleted file mode 100644 index d17ee7bfb195..000000000000 --- a/overlays/patches/emacs/overlay/parse.nix +++ /dev/null @@ -1,156 +0,0 @@ -{ pkgs, lib }: - -let - inherit (import ./repos/fromElisp { inherit pkgs; }) fromElisp fromOrgModeBabelElisp'; - - isStrEmpty = s: (builtins.replaceStrings [ " " ] [ "" ] s) == ""; - - splitString = _sep: _s: builtins.filter - (x: builtins.typeOf x == "string") - (builtins.split _sep _s); - - # Parse (all) Package-Requires packageElisp headers found in the input string - # `packageElisp` into a list of package name strings. - # - # Example inputs: - # - # ;; Package-Requires: () - # => [ ] - # ;; Package-Requires: ((dash "2.12.1") (pkg-info "0.4") (let-alist "1.0.4") (seq "1.11") (emacs "24.3")) - # => [ "dash" "pkg-info" "let-alist" "seq" "emacs" ] - # ;; Package-Requires: (dash (pkg-info "0.4")) - # => [ "dash" "pkg-info" ] - # ;; Package-Requires: ((dash) (pkg-info "0.4")) - # => [ "dash" "pkg-info" ] - parsePackagesFromPackageRequires = packageElisp: - let - lines = splitString "\r?\n" packageElisp; - requires = - lib.concatMapStrings - (line: - let match = builtins.match ";;;* *[pP]ackage-[rR]equires *: *\\((.*)\\) *" line; - in if match == null then "" else builtins.head match) - lines; - parseReqList = s: - let matchAndRest = builtins.match " *\\(? *([^ \"\\)]+)( +\"[^\"]+\" *\\)| *\\))?(.*)" s; - in - if isStrEmpty s then - [ ] - else - if matchAndRest == null then - throw "Failed to parse package requirements list: ${s}" - else - [ (builtins.head matchAndRest) ] ++ (parseReqList (builtins.elemAt matchAndRest 2)); - in - parseReqList requires; - - # Get a list of packages declared wanted with `use-package` in the - # input string `config`. The goal is to only list packages that - # would be installed by `use-package` on evaluation; thus we look at - # the `:ensure` and `:disabled` keyword values to attempt to figure - # out which and whether the package should be installed. - # - # Example input: - # - # '' - # (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)) - # '' - # => [ "direnv" "paredit" ] - parsePackagesFromUsePackage = { - configText - , alwaysEnsure ? false - , isOrgModeFile ? false - , alwaysTangle ? false - }: - let - readFunction = - if isOrgModeFile then - fromOrgModeBabelElisp' { ":tangle" = if alwaysTangle then "yes" else "no"; } - else - fromElisp; - - find = item: list: - if list == [] then [] else - if builtins.head list == item then - list - else - find item (builtins.tail list); - - getKeywordValue = keyword: list: - let - keywordList = find keyword list; - in - if keywordList != [] then - let - keywordValue = builtins.tail keywordList; - in - if keywordValue != [] then - builtins.head keywordValue - else - true - else - null; - - isDisabled = item: - let - disabledValue = getKeywordValue ":disabled" item; - in - if disabledValue == [] then - false - else if builtins.isBool disabledValue then - disabledValue - else if builtins.isString disabledValue then - true - else - false; - - getName = item: - let - ensureValue = getKeywordValue ":ensure" item; - usePackageName = builtins.head (builtins.tail item); - in - if builtins.isString ensureValue then - if lib.hasPrefix ":" ensureValue then - usePackageName - else - ensureValue - else if ensureValue == true || (ensureValue == null && alwaysEnsure) then - usePackageName - else - []; - - recurse = item: - if builtins.isList item && item != [] then - let - packageManager = builtins.head item; - in - if builtins.elem packageManager [ "use-package" "leaf" ] then - if !(isDisabled item) then - [ packageManager (getName item) ] ++ map recurse item - else - [] - else - map recurse item - else - []; - in - lib.flatten (map recurse (readFunction configText)); - -in -{ - inherit parsePackagesFromPackageRequires; - inherit parsePackagesFromUsePackage; -} |