Optimize init startup time
This commit is contained in:
parent
b2b46c04a6
commit
b387c1abb2
@ -10,7 +10,44 @@ Enables lexical binding for everything in init.el:
|
||||
;;; -*- lexical-binding: t; -*-
|
||||
#+END_SRC
|
||||
|
||||
Variables:
|
||||
** Garbage collection
|
||||
Some GC tweaks [[https://github.com/hlissner/doom-emacs/blob/develop/docs/faq.org#how-does-doom-start-up-so-quickly]["borrowed" from Doom emacs]].
|
||||
|
||||
Turn off GC during init and restore it afterwards:
|
||||
#+BEGIN_SRC emacs-lisp
|
||||
(setq gc-cons-threshold most-positive-fixnum
|
||||
gc-cons-percentage 0.6)
|
||||
|
||||
(add-hook 'emacs-startup-hook
|
||||
(lambda ()
|
||||
(setq gc-cons-threshold 16777216
|
||||
gc-cons-percentage 0.1)))
|
||||
#+END_SRC
|
||||
|
||||
Also suppress GC for 1 second after the minibuffer is active to avoid stuttering autocompletion and other GC hangups:
|
||||
#+BEGIN_SRC emacs-lisp
|
||||
(defun defer-garbage-collection ()
|
||||
(setq gc-cons-threshold most-positive-fixnum))
|
||||
|
||||
(defun restore-garbage-collection ()
|
||||
(run-at-time
|
||||
1 nil (lambda () (setq gc-cons-threshold 16777216))))
|
||||
|
||||
(add-hook 'minibuffer-setup-hook #'defer-garbage-collection)
|
||||
(add-hook 'minibuffer-exit-hook #'restore-garbage-collection)
|
||||
#+END_SRC
|
||||
|
||||
** Unset file-handler-alist during initialization
|
||||
Another optimization from [[https://github.com/hlissner/doom-emacs/blob/develop/docs/faq.org#how-does-doom-start-up-so-quickly][Doom Emacs]].
|
||||
#+BEGIN_SRC emacs-lisp
|
||||
(defvar file-name-handler-alist-backup file-name-handler-alist)
|
||||
(setq file-name-handler-alist nil)
|
||||
(add-hook 'emacs-startup-hook
|
||||
(lambda ()
|
||||
(setq file-name-handler-alist file-name-handler-alist-backup)))
|
||||
#+END_SRC
|
||||
|
||||
** Variables
|
||||
#+BEGIN_SRC emacs-lisp
|
||||
(setq vc-follow-symlinks t)
|
||||
#+END_SRC
|
||||
@ -1745,17 +1782,17 @@ Integrate Google calendar with org-mode:
|
||||
* Mode line
|
||||
* UI
|
||||
Get rid of the janky buttons:
|
||||
#+BEGIN_SRC emacs-lisp
|
||||
#+BEGIN_SRC emacs-lisp :tangle ~/.emacs.d/early-init.el
|
||||
(tool-bar-mode -1)
|
||||
#+END_SRC
|
||||
|
||||
And the menu bar:
|
||||
#+BEGIN_SRC emacs-lisp
|
||||
#+BEGIN_SRC emacs-lisp :tangle ~/.emacs.d/early-init.el
|
||||
(menu-bar-mode -1)
|
||||
#+END_SRC
|
||||
|
||||
And the ugly scroll bars:
|
||||
#+BEGIN_SRC emacs-lisp
|
||||
#+BEGIN_SRC emacs-lisp :tangle ~/.emacs.d/early-init.el
|
||||
(set-scroll-bar-mode nil)
|
||||
#+END_SRC
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user