From ed7d4ab4e6205db71d21bc8df5882a0751773051 Mon Sep 17 00:00:00 2001 From: Tom Alexander Date: Fri, 26 Jan 2024 21:21:09 -0500 Subject: [PATCH] Run emacs garbage collection when idle. This is to hopefully avoid running garbage collection while I am actively interacting with emacs, which should theoretically result in a smoother experience. --- ansible/roles/emacs/files/early-init.el | 4 ++-- ansible/roles/emacs/files/elisp/base.el | 10 ++++++++++ ansible/roles/emacs/files/elisp/common-lsp.el | 1 + ansible/roles/vscode/files/settings.json | 3 ++- 4 files changed, 15 insertions(+), 3 deletions(-) diff --git a/ansible/roles/emacs/files/early-init.el b/ansible/roles/emacs/files/early-init.el index ae8a347..08e8e63 100644 --- a/ansible/roles/emacs/files/early-init.el +++ b/ansible/roles/emacs/files/early-init.el @@ -1,6 +1,6 @@ -(setq gc-cons-threshold 100000000) ;; Increase garbage collection threshold for performance (default 800000) +(setq gc-cons-threshold (* 128 1024 1024)) ;; Increase garbage collection threshold for performance (default 800000) ;; Increase amount of data read from processes, default 4k -(when (>= emacs-major-version 27) +(when (version<= "27.0" emacs-version) (setq read-process-output-max (* 1024 1024)) ;; 1mb ) diff --git a/ansible/roles/emacs/files/elisp/base.el b/ansible/roles/emacs/files/elisp/base.el index 590af3e..45a0dac 100644 --- a/ansible/roles/emacs/files/elisp/base.el +++ b/ansible/roles/emacs/files/elisp/base.el @@ -36,6 +36,8 @@ ;; Don't pop up a small window at the bottom of emacs at launch. inhibit-startup-screen t inhibit-startup-message t + ;; Don't show the list of buffers when opening many files. + inhibit-startup-buffer-menu t ;; Give the scratch buffer a clean slate. initial-major-mode 'fundamental-mode initial-scratch-message nil @@ -81,4 +83,12 @@ (setopt auto-revert-check-vc-info t) (global-auto-revert-mode) +;;;;; Performance +;; Run garbage collect when emacs is idle +(run-with-idle-timer 5 t (lambda () (garbage-collect))) +(add-function :after after-focus-change-function + (lambda () + (unless (frame-focus-state) + (garbage-collect)))) + (provide 'base) diff --git a/ansible/roles/emacs/files/elisp/common-lsp.el b/ansible/roles/emacs/files/elisp/common-lsp.el index 935aff9..66d10dc 100644 --- a/ansible/roles/emacs/files/elisp/common-lsp.el +++ b/ansible/roles/emacs/files/elisp/common-lsp.el @@ -38,6 +38,7 @@ :hook (eglot-managed-mode . company-mode) :config (setq company-backends '((company-capf))) + (setq company-idle-delay 0) ;; Default 0.2 ) ;; (use-package company-box diff --git a/ansible/roles/vscode/files/settings.json b/ansible/roles/vscode/files/settings.json index 375452d..d7766bb 100644 --- a/ansible/roles/vscode/files/settings.json +++ b/ansible/roles/vscode/files/settings.json @@ -18,5 +18,6 @@ "[python]": { "editor.defaultFormatter": "ms-python.black-formatter", "editor.formatOnSave": true - } + }, + "black-formatter.importStrategy": "fromEnvironment" }