Fixed issue where emacs was crashing

This commit is contained in:
Joseph Ferano 2022-08-20 17:38:20 +07:00
parent 73679a610d
commit 3a15c740fd
2 changed files with 56 additions and 32 deletions

View File

@ -5,14 +5,14 @@
#+TOC: true #+TOC: true
** Early Init ** Early Init
*** Garbage Collection *** Garbage Collection
The default Garbage Collector is triggered at 800 KB, way too conservative, let's bump to 512 MB. The default Garbage Collector is triggered at 800 KB, way too conservative, let's bump to 512 MB.
Garbage collection is a big contributor to startup times. This fends it off, then is reset later by Garbage collection is a big contributor to startup times. This fends it off, then is reset later by enabling `gcmh-mode'. Not resetting it will cause stuttering/freezes.
enabling `gcmh-mode'. Not resetting it will cause stuttering/freezes.
#+begin_src emacs-lisp :tangle ./early-init.el #+begin_src emacs-lisp :tangle ./early-init.el
;; -*- lexical-binding: t; -*- ;; -*- lexical-binding: t -*-
(defvar default-file-name-handler-alist file-name-handler-alist) (defvar default-file-name-handler-alist file-name-handler-alist)
(setq file-name-handler-alist nil) (setq file-name-handler-alist nil)
(setq gc-cons-threshold (expt 2 32)) (setq gc-cons-threshold (expt 2 32))
@ -28,22 +28,24 @@ enabling `gcmh-mode'. Not resetting it will cause stuttering/freezes.
(garbage-collect)))) (garbage-collect))))
(add-hook 'focus-out-hook 'garbage-collect)))) (add-hook 'focus-out-hook 'garbage-collect))))
(setq native-comp-deferred-compilation nil) (setq native-comp-async-report-warnings-errors nil)
(setq native-comp-deferred-compilation t)
#+end_src #+end_src
Disabling these classic visual options during early-init seems to net a 0.04 ms boost in init time
#+begin_src emacs-lisp :tangle ./early-init.el #+begin_src emacs-lisp :tangle ./early-init.el
(setq max-specpdl-size 1200) (setq max-specpdl-size 1200)
(setq max-lisp-eval-depth 800) (setq max-lisp-eval-depth 800)
(add-hook 'window-setup-hook (scroll-bar-mode -1)
(lambda () (tool-bar-mode -1)
(setq-default inhibit-redisplay nil (menu-bar-mode -1)
inhibit-message nil) (tooltip-mode -1)
(redisplay)))
#+end_src #+end_src
*** Setup *** Straight.el Prep
Disable package.el, since we will be using straight.el. According to the straight.el Disable package.el, since we will be using straight.el. According to the straight.el
documentation; documentation;
@ -64,11 +66,10 @@ Prioritize old byte-compiled source files over newer sources. It saves us a litt
#+begin_src emacs-lisp :tangle ./early-init.el #+begin_src emacs-lisp :tangle ./early-init.el
(setq load-prefer-newer nil) (setq load-prefer-newer nil)
#+end_src #+end_src
*** UTF-8 Support
#+begin_src emacs-lisp :tangle ./early-init.el #+begin_src emacs-lisp :tangle ./early-init.el
(set-language-environment "UTF-8") (set-language-environment "UTF-8")
(setq default-input-method nil) (setq default-input-method nil)
;;; early-init.el ends here ;;; early-init.el ends here
#+end_src #+end_src
@ -94,17 +95,23 @@ Then bootstrap
(load bootstrap-file nil 'nomessage)) (load bootstrap-file nil 'nomessage))
#+END_SRC #+END_SRC
** Misc Stuff ** Benchmarking
#+begin_SRC emacs-lisp
This is commented out since it adds ever so slightly to init time, but keep it around in case we
need to benchmark slow init times later.
#+begin_src emacs-lisp
;; (straight-use-package 'benchmark-init) ;; (straight-use-package 'benchmark-init)
;; (require 'benchmark-init) ;; (require 'benchmark-init)
;; (add-hook 'after-init-hook 'benchmark-init/deactivate) ;; (add-hook 'after-init-hook 'benchmark-init/deactivate)
#+end_src
** Misc Stuff
#+begin_SRC emacs-lisp
(setq vc-follow-symlinks t) ; Visit real file when editing a symlink without prompting. (setq vc-follow-symlinks t) ; Visit real file when editing a symlink without prompting.
(global-auto-revert-mode t) ; Revert buffer's file when the file changes on disk (global-auto-revert-mode t) ; Revert buffer's file when the file changes on disk
(setq confirm-kill-emacs 'y-or-n-p) ;; (setq confirm-kill-emacs 'y-or-n-p)
(setq use-dialog-box nil) (setq use-dialog-box nil)
(fset 'yes-or-no-p 'y-or-n-p) (fset 'yes-or-no-p 'y-or-n-p)
@ -153,10 +160,10 @@ Setup other stuff
(global-hl-line-mode +1) (global-hl-line-mode +1)
(column-number-mode +1) (column-number-mode +1)
(scroll-bar-mode -1) ;; (scroll-bar-mode -1)
(tool-bar-mode -1) ;; (tool-bar-mode -1)
(menu-bar-mode -1) ;; (menu-bar-mode -1)
(tooltip-mode -1) ;; (tooltip-mode -1)
(modify-all-frames-parameters (modify-all-frames-parameters
'((right-divider-width . 5) '((right-divider-width . 5)
@ -197,15 +204,17 @@ Setup other stuff
** Org Mode ** Org Mode
#+begin_src emacs-lisp #+begin_src emacs-lisp
(require 'org) (eval-after-load 'org (lambda ()
(setq org-todo-keywords '((sequence "TODO" "IN-PROGRESS" "|" "DONE" "BACKLOG"))) (setq org-todo-keywords '((sequence "TODO" "IN-PROGRESS" "|" "DONE" "BACKLOG")))
(setq org-agenda-files '("~/todo.org")) (setq org-agenda-files '("~/todo.org"))
(straight-use-package 'org-bullets)
(defun joe/org-hook () (org-bullets-mode) (org-indent-mode)) (straight-use-package 'org-bullets)
(add-hook 'org-mode-hook 'joe/org-hook) (org-bullets-mode)
(require 'org-tempo) (org-indent-mode)
(add-to-list 'org-structure-template-alist '("el" . "src emacs-lisp"))
(setq org-edit-src-content-indentation 0) (require 'org-tempo)
(add-to-list 'org-structure-template-alist '("el" . "src emacs-lisp"))
(setq org-edit-src-content-indentation 0)))
#+end_src #+end_src
** VEMCO (Vertico Embark Marginalia Consult Orderless) ** VEMCO (Vertico Embark Marginalia Consult Orderless)
@ -272,7 +281,12 @@ Setup other stuff
(setq undo-tree-history-directory-alist `(("." . ,(expand-file-name "undo" user-emacs-directory)))) (setq undo-tree-history-directory-alist `(("." . ,(expand-file-name "undo" user-emacs-directory))))
#+end_src #+end_src
** Text Editor ** Text Editor
#+begin_src emacs-lisp
Emacs is an amazing operating system, if only it had a good text editor...
Meow
#+begin_src emacs-lisp :tangle no
(straight-use-package 'meow) (straight-use-package 'meow)
(require 'meow) (require 'meow)
(defun meow-setup () (defun meow-setup ()
@ -361,12 +375,22 @@ Setup other stuff
'("'" . repeat) '("'" . repeat)
'("<escape>" . ignore))) '("<escape>" . ignore)))
(meow-setup) (meow-setup)
;; (meow-global-mode t) (meow-global-mode t)
#+end_src
Boon
#+begin_src emacs-lisp
(straight-use-package boon)
#+end_src #+end_src
** Magit ** Magit
#+begin_src emacs-lisp #+begin_src emacs-lisp
(straight-use-package 'magit) (straight-use-package 'magit)
#+end_src #+end_src
** Finish up
#+begin_src emacs-lisp
#+end_src
* COMMENT Local variables * COMMENT Local variables
;; Local Variables: ;; Local Variables:
;; eval: (add-hook 'after-save-hook '(lambda () (org-babel-tangle)) nil t) ;; eval: (add-hook 'after-save-hook '(lambda () (org-babel-tangle)) nil t)

View File

@ -132,7 +132,7 @@ all of the evil keybindings in buffers like magit, without compromises."
nil t))) nil t)))
'(org-agenda-files '("~/todo.org")) '(org-agenda-files '("~/todo.org"))
'(package-selected-packages '(package-selected-packages
'(org-kanban embark-consult embark olivetti vertico-posframe orderless vertico eglot-fsharp consult-eglot eglot nano-modeline mini-modeline pdf-tools consult all-the-icons-completion kind-icon mini-modeline shelldon pcomplete-extension corfu-doc esh-autosuggest fish-completion cape corfu highlight-quoted dirvish ranger magit multi-vterm evil-collection smartparens vterm all-the-icons org-bullets fsharp-mode fish-mode find-file-in-project helpful ahk-mode rainbow-delimiters doom-themes marginalia avy evil-commentary evil-surround undo-tree which-key dashboard)) '(macrostep org-kanban embark-consult embark olivetti vertico-posframe orderless vertico eglot-fsharp consult-eglot eglot nano-modeline mini-modeline pdf-tools consult all-the-icons-completion kind-icon mini-modeline shelldon pcomplete-extension corfu-doc esh-autosuggest fish-completion cape corfu highlight-quoted dirvish ranger magit multi-vterm evil-collection smartparens vterm all-the-icons org-bullets fsharp-mode fish-mode find-file-in-project helpful ahk-mode rainbow-delimiters doom-themes marginalia avy evil-commentary evil-surround undo-tree which-key dashboard))
'(safe-local-variable-values '(safe-local-variable-values
'((eval add-hook 'after-save-hook '((eval add-hook 'after-save-hook
'(lambda nil '(lambda nil