From 489239b2ed1461389e0a6687370aa36aa9c9a845 Mon Sep 17 00:00:00 2001 From: Erwin Boskma Date: Wed, 5 Apr 2023 13:21:29 +0200 Subject: [PATCH] Handle multiple emacs config files --- home-manager/modules/emacs/config.org | 14 +++++++++++++- home-manager/modules/emacs/default.nix | 14 +++++++++----- 2 files changed, 22 insertions(+), 6 deletions(-) diff --git a/home-manager/modules/emacs/config.org b/home-manager/modules/emacs/config.org index f324f1b..563f017 100644 --- a/home-manager/modules/emacs/config.org +++ b/home-manager/modules/emacs/config.org @@ -17,7 +17,7 @@ Last export: {{{modification-time(%Y-%m-%d %H:%M)}}} This ends up in =early-init.el=. -#+begin_src emacs-lisp +#+begin_src emacs-lisp :tangle early-init.el ;; -*- lexical-binding: t; -*- ;; Prevent package.el from loading packages until we're ready for it (setq package-enable-at-startup nil) @@ -37,6 +37,17 @@ This ends up in =early-init.el=. ;; compiled ahead-of-time when they are installed and site files are compiled ;; when gccemacs is installed. (setq comp-deferred-compilation nil) + + ;; This should fix input lag by ~80% when using PGTK + (setq-default pgtk-wait-for-event-timeout 0) +#+end_src + +** Enable lexical binding + +Setting =lexical-binding= to =t= can improve startup time. This has to be first! + +#+begin_src emacs-lisp + ;; -*- lexical-binding: t; -*- #+end_src ** Personal variables @@ -1136,6 +1147,7 @@ Rust support with [[https://github.com/rust-lang/rust-mode][rust-mode]]. :after lsp-mode :hook (rust-mode . lsp-deferred) + (rust-ts-mode . lsp-deferred) (before-save . lsp-format-buffer) (before-save . lsp-organize-imports) :init diff --git a/home-manager/modules/emacs/default.nix b/home-manager/modules/emacs/default.nix index 2f9a6a3..5df8386 100644 --- a/home-manager/modules/emacs/default.nix +++ b/home-manager/modules/emacs/default.nix @@ -6,14 +6,16 @@ with lib; let cfg = config.eboskma.programs.emacs; + tangleEmacsConfig = initFile: pkgs.runCommand "tangled-emacs-${initFile}" { } '' + cp ${./config.org} ./config.org + ${cfg.package}/bin/emacs --batch --quick --load org ./config.org --funcall org-babel-tangle + cp ${initFile} $out + ''; + emacsWithPackages = pkgs.emacsWithPackagesFromUsePackage { config = let - tangledOrgConfig = pkgs.runCommand "tangled-emacs-config" { } '' - cp ${./config.org} ./config.org - ${cfg.package}/bin/emacs --batch -Q ./config.org -f org-babel-tangle - cp init.el $out - ''; + tangledOrgConfig = tangleEmacsConfig "init.el"; in builtins.readFile tangledOrgConfig; @@ -67,6 +69,8 @@ in socketActivation.enable = true; }; + home.file."emacs.d/early-init.el".source = tangleEmacsConfig "early-init.el"; + home.packages = with pkgs; [ (texlive.combine { inherit (texlive) scheme-small wrapfig ulem capt-of;