From 84df241cfe93df5f7071c1a3777ee4eee7bb5f50 Mon Sep 17 00:00:00 2001 From: Madeleine Sydney Date: Sat, 15 Feb 2025 12:32:29 -0700 Subject: [PATCH] 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. --- users/crumb/programs/emacs.nix | 14 ++++++++++++++ 1 file changed, 14 insertions(+) diff --git a/users/crumb/programs/emacs.nix b/users/crumb/programs/emacs.nix index 51f7834..c5221b6 100755 --- a/users/crumb/programs/emacs.nix +++ b/users/crumb/programs/emacs.nix @@ -56,12 +56,24 @@ let done ''; }; + + emacsclient-or-emacs = pkgs.writeShellScriptBin "emacsclient-or-emacs" '' + emacsclient --alternate-editor=${emacsWrapper}/bin/emacs "$@" + ''; in { sydnix.impermanence.cache.directories = [ # Impermanence expects the path to be relative to ~. (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 = let default = lib.removePrefix "${config.home.homeDirectory}/" @@ -74,6 +86,7 @@ in { home.packages = [ emacsWrapper + emacsclient-or-emacs ] ++ fontPackages; # There's probably a better place to put this, but the current setup demands @@ -85,5 +98,6 @@ in { enable = true; # Generate a desktop entry for emacsclient. client.enable = true; + package = emacsWrapper; }; }