1
0
Fork 0

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:
# 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 <option>:chords</option>.
'';
};
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)

View File

@ -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" ];
};