From f59850983001f9a2dc11132216f616dd93f773b3 Mon Sep 17 00:00:00 2001 From: Sakooooo <78461130+Sakooooo@users.noreply.github.com> Date: Sun, 28 Jul 2024 00:22:13 +0400 Subject: [PATCH] emacs optimizations --- config/emacs/emacs.org | 45 ++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 45 insertions(+) diff --git a/config/emacs/emacs.org b/config/emacs/emacs.org index 951db527..ad12dd07 100644 --- a/config/emacs/emacs.org +++ b/config/emacs/emacs.org @@ -44,6 +44,51 @@ (load bootstrap-file nil 'nomessage)) (setq straight-use-package-by-default t)) #+end_src +* Make Emacs faster +#+begin_src emacs-lisp +(message "Speeding up") +#+end_src +** Avoid garbage collection at startup +#+begin_src emacs-lisp +(use-package gcmh + :init + (setq gcmh-idle-delay 5) + (setq gcmh-high-cons-threshold (* 16 1024 1024)) + :config + (gcmh-mode)) +#+end_src +** Set garbage collection to be further back +#+begin_src emacs-lisp +(setq gc-cons-threshold most-positive-fixnum) +#+end_src +** Unset file-name-handler-alist +#+begin_src emacs-lisp +(defvar sakomacs--file-name-handler-alist file-name-handler-alist) +(setq file-name-handler-alist nil) + +;; Alternatively, restore it even later: +(add-hook 'emacs-startup-hook + (lambda () + (setq file-name-handler-alist sakomacs--file-name-handler-alist))) +#+end_src +** Reset gc once init has finished +#+begin_src emacs-lisp + (defun doom-defer-garbage-collection-h () + "Disable garbage collection." + (setq gc-cons-threshold most-positive-fixnum)) + +(defun doom-restore-garbage-collection-h () + "Restore garbage collection." + (run-at-time + 1 nil (lambda () (setq gc-cons-threshold 16777216)))) + +(add-hook 'minibuffer-setup-hook #'doom-defer-garbage-collection-h) +(add-hook 'minibuffer-exit-hook #'doom-restore-garbage-collection-h) +#+end_src +** Read more +#+begin_src emacs-lisp +(setq read-process-output-max (* 1024 1024)) ;; 1mb +#+end_src * Keybinds Ill use this later eventually #+begin_src emacs-lisp