From 7c1f7aa9a1ba04c87c6675ba3e1bb6da87cc3f40 Mon Sep 17 00:00:00 2001 From: derped Date: Fri, 27 Mar 2020 20:59:26 +0100 Subject: [PATCH] emacs: Update emacs module from upstream. --- options/emacs-init.nix | 40 ++++++++++++++++++++++++++++++++-------- pkgsets/emacs/org.nix | 6 +++--- 2 files changed, 35 insertions(+), 11 deletions(-) diff --git a/options/emacs-init.nix b/options/emacs-init.nix index 717590d..ef6dcae 100644 --- a/options/emacs-init.nix +++ b/options/emacs-init.nix @@ -1,5 +1,5 @@ # Original Source: -# https://gitlab.com/rycee/nur-expressions/raw/master/hm-modules/emacs-init.nix (b83922825b19de97786c38885e99abb613214e11) +# https://gitlab.com/rycee/nur-expressions/raw/master/hm-modules/emacs-init.nix (d27525db3358b9463fab1b4a7739cb77e27b768c) # MIT License @@ -32,18 +32,22 @@ let cfg = config.programs.emacs.init; - emacsPackageType = - types.coercedTo - types.str - (pkgName: epkgs: [ epkgs.${pkgName} ]) - (types.nullOr types.unspecified); + packageFunctionType = mkOptionType { + name = "packageFunction"; + description = "function from epkgs to package"; + check = isFunction; + merge = mergeOneOption; + }; usePackageType = types.submodule ({ name, config, ... }: { options = { enable = mkEnableOption "Emacs package ${name}"; package = mkOption { - type = emacsPackageType; + type = + types.either + (types.str // { description = "name of package"; }) + packageFunctionType; default = name; description = '' The package to use for this module. Either the package name @@ -76,6 +80,15 @@ let ''; }; + chords = mkOption { + type = types.attrsOf types.str; + default = {}; + example = { "jj" = "ace-jump-char-mode"; "jk" = "ace-jump-word-mode"; }; + description = '' + The entries to use for . + ''; + }; + mode = mkOption { type = types.listOf types.str; default = []; @@ -189,6 +202,7 @@ let in flatten (mapAttrsToList mkMap bs); mkBindKeyMap = mkBindHelper "bind-keymap" ""; + mkChords = mkBindHelper "chords" ""; mkHook = map (v: ":hook ${v}"); mkDefer = v: if isBool v then optional v ":defer t" @@ -201,6 +215,7 @@ let ++ mkBind config.bind ++ mkBindKeyMap config.bindKeyMap ++ mkBindLocal config.bindLocal + ++ mkChords config.chords ++ mkCommand config.command ++ mkDefer config.defer ++ mkDemand config.demand @@ -269,6 +284,9 @@ let # Whether the configuration makes use of `:bind`. hasBind = any (p: p.bind != {}) (attrValues cfg.usePackage); + # Whether the configuration makes use of `:chords`. + hasChords = any ( p: p.chords != {}) (attrValues cfg.usePackage); + usePackageSetup = '' (eval-when-compile @@ -292,6 +310,11 @@ let + optionalString hasBind '' ;; For :bind in (use-package). (require 'bind-key) + '' + + optionalString hasChords '' + ;; For :chords in (use-package). + (use-package use-package-chords + :config (key-chord-mode 1)) ''; initFile = '' @@ -397,7 +420,8 @@ in in [ epkgs.use-package ] ++ optional hasBind epkgs.bind-key - ++ optional hasBind epkgs.diminish + ++ optional hasDiminish epkgs.diminish + ++ optional hasChords epkgs.use-package-chords ++ ( concatMap (v: getPkg (v.package)) (builtins.attrValues cfg.usePackage) diff --git a/pkgsets/emacs/org.nix b/pkgsets/emacs/org.nix index d426c88..fce0fbb 100644 --- a/pkgsets/emacs/org.nix +++ b/pkgsets/emacs/org.nix @@ -361,12 +361,12 @@ mkIf (elem "emacs::org" config.machine.pkgs) { programs.emacs.init.usePackage.org-tempo = { enable = true; - package = null; + package = epkgs: null; }; programs.emacs.init.usePackage.ox = { enable = true; - package = null; + package = epkgs: null; defer = true; command = []; config = '' @@ -392,7 +392,7 @@ mkIf (elem "emacs::org" config.machine.pkgs) { programs.emacs.init.usePackage.ox-md = { enable = true; - package = null; + package = epkgs: null; after = [ "ox" ]; };