From 858ed5a8e768c5b456369dcda4603ab21f969222 Mon Sep 17 00:00:00 2001 From: John Turner Date: Sat, 25 Mar 2023 03:28:06 -0400 Subject: [PATCH] use early-init.el to allow setting native comp cache dir Some of the init.el setup code moved to early-init.el to allow loading our init modules in early init. Loading the native comp init module in init.el set the cache directory variable too late and resulted in the original directory still being populated with eln files. --- early-init.el | 40 +++++++++++++++++++++++++ init.el | 44 +++------------------------- init/native-comp/init-native-comp.el | 3 +- 3 files changed, 46 insertions(+), 41 deletions(-) create mode 100644 early-init.el diff --git a/early-init.el b/early-init.el new file mode 100644 index 0000000..de9661e --- /dev/null +++ b/early-init.el @@ -0,0 +1,40 @@ +(setq auth-source-save-behavior nil + auto-save-default nil + change-major-mode-with-file-name nil + custom-buffer-indent 4 + custom-file (file-name-concat user-emacs-directory "custom.el") + custom-theme-directory (file-name-concat user-emacs-directory "themes/") + debugger 'edebug + enable-local-variables :safe + inferior-lisp-program "sbcl" + inhibit-splash-screen t + make-backup-files nil + scheme-program-name "guile" + tab-width 4 + temporary-file-directory (file-name-concat (getenv "HOME") "tmp" ".emacs")) + +(setq-default display-fill-column-indicator-column 120 + indent-tabs-mode nil) + +(let* ((init-modules-wildcard + (file-name-concat user-emacs-directory "init" "*")) + (lisp-modules-wildcard + (file-name-concat user-emacs-directory "lisp" "*")) + (init-modules-files + (file-expand-wildcards init-modules-wildcard t)) + (lisp-modules-files + (file-expand-wildcards lisp-modules-wildcard t)) + (files + (append init-modules-files lisp-modules-files)) + (directories + (seq-filter 'file-directory-p files))) + (mapc (lambda (directory) + (add-to-list 'load-path directory)) + directories)) + +(mkdir temporary-file-directory t) + +(require 'init-garbage-collection) + +(when (and (>= emacs-major-version 29) (native-comp-available-p)) + (require 'init-native-comp)) diff --git a/init.el b/init.el index a73be6b..85a711b 100644 --- a/init.el +++ b/init.el @@ -1,42 +1,9 @@ -(require 'seq) - -(setq auth-source-save-behavior nil - auto-save-default nil - change-major-mode-with-file-name nil - custom-buffer-indent 4 - custom-file (file-name-concat user-emacs-directory "custom.el") - custom-theme-directory (file-name-concat user-emacs-directory "themes/") - debugger 'edebug - enable-local-variables :safe - inferior-lisp-program "sbcl" - inhibit-splash-screen t - make-backup-files nil - scheme-program-name "guile" - tab-width 4) - -(setq-default display-fill-column-indicator-column 120 - indent-tabs-mode nil) - -(let* ((init-modules-wildcard - (file-name-concat user-emacs-directory "init" "*")) - (lisp-modules-wildcard - (file-name-concat user-emacs-directory "lisp" "*")) - (init-modules-files - (file-expand-wildcards init-modules-wildcard t)) - (lisp-modules-files - (file-expand-wildcards lisp-modules-wildcard t)) - (files - (append init-modules-files lisp-modules-files)) - (directories - (seq-filter 'file-directory-p files))) - (mapc (lambda (directory) - (add-to-list 'load-path directory)) - directories)) - (defmacro require? (feature) `(require ,feature nil t)) -(require? 'site-gentoo) +(unless (when-let ((e (getenv "NO_SITE_GENTOO"))) + (string= e "1")) + (require? 'site-gentoo)) (require? 'magit) @@ -50,7 +17,6 @@ (require 'init-eldoc) (require 'init-electric) (require 'init-flymake) -(require 'init-garbage-collection) (require 'init-ibuffer) (require 'init-ielm) (require 'init-keys) @@ -71,14 +37,12 @@ (when (require? 'lsp-mode) (require 'init-lsp-mode)) -(when (and (> emacs-major-version 28) (native-comp-available-p)) - (require 'init-native-comp)) - (when (require? 'pixel-scroll) (require 'init-pixel-scroll)) (when (and (require? 'treesit) (treesit-available-p)) (require 'init-treesit)) + (require 'man-completion) (require 'license-boilerplate) diff --git a/init/native-comp/init-native-comp.el b/init/native-comp/init-native-comp.el index 9ae0489..630a083 100644 --- a/init/native-comp/init-native-comp.el +++ b/init/native-comp/init-native-comp.el @@ -1,3 +1,4 @@ -(setq native-comp-async-jobs-number (string-to-number (shell-command-to-string "nproc"))) +(setq native-comp-async-jobs-number (string-to-number (shell-command-to-string "nproc")) + native-compile-target-directory temporary-file-directory) (provide 'init-native-comp)