emacs: Update emacs module from upstream.

This commit is contained in:
Kevin Baensch 2020-03-27 20:59:26 +01:00
parent cc7df95c40
commit 7c1f7aa9a1
Signed by: derped
GPG key ID: C0F1D326C7626543
2 changed files with 35 additions and 11 deletions

View file

@ -1,5 +1,5 @@
# Original Source: # 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 # MIT License
@ -32,18 +32,22 @@ let
cfg = config.programs.emacs.init; cfg = config.programs.emacs.init;
emacsPackageType = packageFunctionType = mkOptionType {
types.coercedTo name = "packageFunction";
types.str description = "function from epkgs to package";
(pkgName: epkgs: [ epkgs.${pkgName} ]) check = isFunction;
(types.nullOr types.unspecified); merge = mergeOneOption;
};
usePackageType = types.submodule ({ name, config, ... }: { usePackageType = types.submodule ({ name, config, ... }: {
options = { options = {
enable = mkEnableOption "Emacs package ${name}"; enable = mkEnableOption "Emacs package ${name}";
package = mkOption { package = mkOption {
type = emacsPackageType; type =
types.either
(types.str // { description = "name of package"; })
packageFunctionType;
default = name; default = name;
description = '' description = ''
The package to use for this module. Either the package name 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 <option>:chords</option>.
'';
};
mode = mkOption { mode = mkOption {
type = types.listOf types.str; type = types.listOf types.str;
default = []; default = [];
@ -189,6 +202,7 @@ let
in in
flatten (mapAttrsToList mkMap bs); flatten (mapAttrsToList mkMap bs);
mkBindKeyMap = mkBindHelper "bind-keymap" ""; mkBindKeyMap = mkBindHelper "bind-keymap" "";
mkChords = mkBindHelper "chords" "";
mkHook = map (v: ":hook ${v}"); mkHook = map (v: ":hook ${v}");
mkDefer = v: mkDefer = v:
if isBool v then optional v ":defer t" if isBool v then optional v ":defer t"
@ -201,6 +215,7 @@ let
++ mkBind config.bind ++ mkBind config.bind
++ mkBindKeyMap config.bindKeyMap ++ mkBindKeyMap config.bindKeyMap
++ mkBindLocal config.bindLocal ++ mkBindLocal config.bindLocal
++ mkChords config.chords
++ mkCommand config.command ++ mkCommand config.command
++ mkDefer config.defer ++ mkDefer config.defer
++ mkDemand config.demand ++ mkDemand config.demand
@ -269,6 +284,9 @@ let
# Whether the configuration makes use of `:bind`. # Whether the configuration makes use of `:bind`.
hasBind = any (p: p.bind != {}) (attrValues cfg.usePackage); hasBind = any (p: p.bind != {}) (attrValues cfg.usePackage);
# Whether the configuration makes use of `:chords`.
hasChords = any ( p: p.chords != {}) (attrValues cfg.usePackage);
usePackageSetup = usePackageSetup =
'' ''
(eval-when-compile (eval-when-compile
@ -292,6 +310,11 @@ let
+ optionalString hasBind '' + optionalString hasBind ''
;; For :bind in (use-package). ;; For :bind in (use-package).
(require 'bind-key) (require 'bind-key)
''
+ optionalString hasChords ''
;; For :chords in (use-package).
(use-package use-package-chords
:config (key-chord-mode 1))
''; '';
initFile = '' initFile = ''
@ -397,7 +420,8 @@ in
in in
[ epkgs.use-package ] [ epkgs.use-package ]
++ optional hasBind epkgs.bind-key ++ optional hasBind epkgs.bind-key
++ optional hasBind epkgs.diminish ++ optional hasDiminish epkgs.diminish
++ optional hasChords epkgs.use-package-chords
++ ( ++ (
concatMap (v: getPkg (v.package)) concatMap (v: getPkg (v.package))
(builtins.attrValues cfg.usePackage) (builtins.attrValues cfg.usePackage)

View file

@ -361,12 +361,12 @@ mkIf (elem "emacs::org" config.machine.pkgs) {
programs.emacs.init.usePackage.org-tempo = { programs.emacs.init.usePackage.org-tempo = {
enable = true; enable = true;
package = null; package = epkgs: null;
}; };
programs.emacs.init.usePackage.ox = { programs.emacs.init.usePackage.ox = {
enable = true; enable = true;
package = null; package = epkgs: null;
defer = true; defer = true;
command = []; command = [];
config = '' config = ''
@ -392,7 +392,7 @@ mkIf (elem "emacs::org" config.machine.pkgs) {
programs.emacs.init.usePackage.ox-md = { programs.emacs.init.usePackage.ox-md = {
enable = true; enable = true;
package = null; package = epkgs: null;
after = [ "ox" ]; after = [ "ox" ];
}; };