feat(emacs): Set {EDITOR,VISUAL} to Emacs

- Includes a tiny wrapper script which connects to the Emacs daemon if it's
  running, or simply runs `emacs` otherwise.
This commit is contained in:
Madeleine Sydney
2025-02-15 12:32:29 -07:00
parent 273d4995a7
commit 84df241cfe

View File

@@ -56,12 +56,24 @@ let
done done
''; '';
}; };
emacsclient-or-emacs = pkgs.writeShellScriptBin "emacsclient-or-emacs" ''
emacsclient --alternate-editor=${emacsWrapper}/bin/emacs "$@"
'';
in { in {
sydnix.impermanence.cache.directories = [ sydnix.impermanence.cache.directories = [
# Impermanence expects the path to be relative to ~. # Impermanence expects the path to be relative to ~.
(lib.removePrefix config.home.homeDirectory straightBaseDir) (lib.removePrefix config.home.homeDirectory straightBaseDir)
]; ];
# Set emacsclient as the default editor for the time being.
home.sessionVariables =
let e = "${emacsclient-or-emacs}/bin/emacsclient-or-emacs";
in {
"EDITOR" = e;
"VISUAL" = e;
};
home.file = home.file =
let default = let default =
lib.removePrefix "${config.home.homeDirectory}/" lib.removePrefix "${config.home.homeDirectory}/"
@@ -74,6 +86,7 @@ in {
home.packages = [ home.packages = [
emacsWrapper emacsWrapper
emacsclient-or-emacs
] ++ fontPackages; ] ++ fontPackages;
# There's probably a better place to put this, but the current setup demands # There's probably a better place to put this, but the current setup demands
@@ -85,5 +98,6 @@ in {
enable = true; enable = true;
# Generate a desktop entry for emacsclient. # Generate a desktop entry for emacsclient.
client.enable = true; client.enable = true;
package = emacsWrapper;
}; };
} }