3
0
Fork 0
forked from mirrors/nixpkgs

Add an option to set EDITOR to emacsclient

This commit is contained in:
Rodney Lorrimar 2016-06-21 10:26:07 +02:00 committed by Damien Cassou
parent 958ae22cc3
commit c70b6b8263

View file

@ -6,6 +6,15 @@ let
cfg = config.services.emacs;
editorScript = pkgs.writeScriptBin "emacseditor" ''
#!${pkgs.stdenv.shell}
if [ -z "$1" ]; then
exec ${cfg.package}/bin/emacsclient --create-frame --alternate-editor ${cfg.package}/bin/emacs
else
exec ${cfg.package}/bin/emacsclient --alternate-editor ${cfg.package}/bin/emacs "$@"
fi
'';
in {
options.services.emacs = {
@ -45,6 +54,15 @@ in {
'';
};
defaultEditor = mkOption {
type = types.bool;
default = false;
example = true;
description = ''
When enabled, configures emacsclient to be the default editor
using the EDITOR environment variable.
'';
};
};
config = mkIf (cfg.enable || cfg.install) {
@ -59,7 +77,10 @@ in {
};
} // optionalAttrs cfg.enable { wantedBy = [ "default.target" ]; };
environment.systemPackages = [ cfg.package ];
};
environment.systemPackages = [ cfg.package editorScript ];
environment.variables = if cfg.defaultEditor then {
EDITOR = mkOverride 900 "${editorScript}/bin/emacseditor";
} else {};
};
}