From 8d523a2f6d254524b17ca310b7267b2af7024ab2 Mon Sep 17 00:00:00 2001 From: Craig Jennings Date: Wed, 13 Aug 2025 16:50:20 -0500 Subject: feat(system-defaults): native compilation prefs and log warnings - Set async compile workers, highest optimization, and always-compile - Redirect native-comp warnings to comp-warnings.log via advice on display-warning - NOTE: log native comp warnings still needs testing --- modules/system-defaults.el | 36 +++++++++++++++++++++++++++++++++++- 1 file changed, 35 insertions(+), 1 deletion(-) (limited to 'modules') diff --git a/modules/system-defaults.el b/modules/system-defaults.el index cf0d1041..f7e18d95 100644 --- a/modules/system-defaults.el +++ b/modules/system-defaults.el @@ -5,6 +5,40 @@ ;;; Code: + +;; -------------------------- Native Comp Preferences -------------------------- +;; After async compiler starts, set preferences and warning level + +(with-eval-after-load 'comp-run + (setopt native-comp-async-jobs-number 8) ; parallel compile workers + (setopt native-comp-speed 3) ; highest optimization level + (setopt native-comp-always-compile t)) ; always native-compile + +;; -------------------------- Log Native Comp Warnings ------------------------- +;; Log native comp warnings rather than cluttering the buffer + +(defvar comp-warnings-log + (expand-file-name "comp-warnings.log" user-emacs-directory) + "File where native-comp warnings will be appended.") + +(defun cj/log-comp-warning (type message &rest args) + "Log native-comp warnings of TYPE with MESSAGE & ARGS to 'comp-warnings-log'. +Suppress them from appearing in the *Warnings* buffer. If TYPE contains 'comp', +log the warning with a timestamp to the file specified by 'comp-warnings-log'. +Return non-nil to indicate the warning was handled." + (when (memq 'comp (if (listp type) type (list type))) + (with-temp-buffer + (insert (format-time-string "[%Y-%m-%d %H:%M:%S] ")) + (insert (if (stringp message) + (apply #'format message args) + (format "%S %S" message args))) + (insert "\n") + (append-to-file (point-min) (point-max) comp-warnings-log)) + ;; Return non-nil to tell `display-warning' “we handled it.” + t)) + +(advice-add 'display-warning :before-until #'cj/log-comp-warning) + ;; ---------------------------------- Unicode ---------------------------------- (set-locale-environment "en_US.UTF-8") @@ -197,7 +231,7 @@ (when (daemonp) (exec-path-from-shell-initialize))) -;; ------------------------------- GNU Ls On BSD ------------------------------- +;; ------------------------------- GNU 'ls' On BSD ------------------------------- ;; when on BSD use the ls from FSF sysutils/coreutils: pkg install coreutils (cond ((eq system-type 'berkeley-unix) -- cgit v1.2.3