improve performance
This commit is contained in:
parent
95f6e1b85d
commit
5f11b92b72
133
init.el
133
init.el
@ -4,21 +4,54 @@
|
||||
;; Emacs!!!
|
||||
|
||||
;;; Code:
|
||||
(package-initialize)
|
||||
;; Without this comment emacs25 adds (package-initialize) here
|
||||
;; (package-initialize)
|
||||
|
||||
(when (version<= emacs-version "24")
|
||||
(error "This is made form Emacs >=24"))
|
||||
(let* ((minver "24.4"))
|
||||
(when (version< emacs-version minver)
|
||||
(error "Emacs v%s or higher is required" minver)))
|
||||
|
||||
;;; Welcome message
|
||||
(setq-default initial-scratch-message
|
||||
(concat ";; Happy hacking, " user-login-name " - Emacs loves you!\n\n"))
|
||||
|
||||
(defconst emacs-start-time (current-time))
|
||||
(add-to-list 'load-path (concat user-emacs-directory "modules"))
|
||||
;;; Modules directory
|
||||
(push (concat user-emacs-directory "modules") load-path)
|
||||
|
||||
;;; Raise garbage collection threshold after init
|
||||
(add-hook 'after-init-hook
|
||||
(lambda () (setq gc-cons-threshold local/gc-cons-threshold)))
|
||||
(defvar best-gc-cons-threshold
|
||||
4000000
|
||||
"Best default gc threshold value. Should NOT be too big!")
|
||||
|
||||
;; don't GC during startup to save time
|
||||
(setq gc-cons-threshold most-positive-fixnum)
|
||||
|
||||
(setq emacs-load-start-time (current-time))
|
||||
|
||||
;;----------------------------------------------------------------------------
|
||||
;; Which functionality to enable (use t or nil for true and false)
|
||||
;;----------------------------------------------------------------------------
|
||||
(setq *is-a-mac* (eq system-type 'darwin))
|
||||
(setq *win64* (eq system-type 'windows-nt))
|
||||
(setq *cygwin* (eq system-type 'cygwin) )
|
||||
(setq *linux* (or (eq system-type 'gnu/linux) (eq system-type 'linux)) )
|
||||
(setq *unix* (or *linux* (eq system-type 'usg-unix-v) (eq system-type 'berkeley-unix)) )
|
||||
(setq *emacs24* (>= emacs-major-version 24))
|
||||
(setq *emacs25* (>= emacs-major-version 25))
|
||||
(setq *emacs26* (>= emacs-major-version 26))
|
||||
(setq *no-memory* (cond
|
||||
(*is-a-mac*
|
||||
(< (string-to-number (nth 1 (split-string (shell-command-to-string "sysctl hw.physmem")))) 4000000000))
|
||||
(*linux* nil)
|
||||
(t nil)))
|
||||
|
||||
;; @see https://www.reddit.com/r/emacs/comments/55ork0/is_emacs_251_noticeably_slower_than_245_on_windows/
|
||||
;; Emacs 25 does gc too frequently
|
||||
(when *emacs25*
|
||||
;; (setq garbage-collection-messages t) ; for debug
|
||||
(setq best-gc-cons-threshold (* 64 1024 1024))
|
||||
(setq gc-cons-percentage 0.5)
|
||||
(run-with-idle-timer 5 t #'garbage-collect))
|
||||
|
||||
;;; Custom variables
|
||||
(setq custom-file (expand-file-name "custom.el" user-emacs-directory))
|
||||
@ -28,65 +61,75 @@
|
||||
;;; Loads settings file
|
||||
(when (file-exists-p custom-file)
|
||||
(load settings-file))
|
||||
|
||||
;;;------------------------------
|
||||
;;; Features
|
||||
;;;------------------------------
|
||||
;;; https://stackoverflow.com/questions/2816019/in-lisp-avoid-cannot-open-load-file-when-using-require
|
||||
|
||||
;; @see https://www.reddit.com/r/emacs/comments/3kqt6e/2_easy_little_known_steps_to_speed_up_emacs_start/
|
||||
;; Normally file-name-handler-alist is set to
|
||||
;; (("\\`/[^/]*\\'" . tramp-completion-file-name-handler)
|
||||
;; ("\\`/[^/|:][^/|]*:" . tramp-file-name-handler)
|
||||
;; ("\\`/:" . file-name-non-special))
|
||||
;; Which means on every .el and .elc file loaded during start up, it has to runs those regexps against the filename.
|
||||
(let* ((file-name-handler-alist nil))
|
||||
;; `package-initialize' takes 35% of startup time
|
||||
;; need check https://github.com/hlissner/doom-emacs/wiki/FAQ#how-is-dooms-startup-so-fast for solution
|
||||
(require 'init-security nil 'noerror)
|
||||
(require 'init-elpa nil 'noerror)
|
||||
(require 'init-security)
|
||||
(require 'init-elpa)
|
||||
;; theme
|
||||
(require 'init-theme nil 'noerror)
|
||||
(require 'init-theme)
|
||||
;; Utils
|
||||
(require 'init-utils nil 'noerror)
|
||||
(require 'init-utils)
|
||||
;; GUI
|
||||
(require 'init-nlinum nil 'noerror)
|
||||
(require 'init-gui nil 'noerror)
|
||||
(require 'init-editing-utils nil 'noerror)
|
||||
(require 'init-diminish nil 'noerror)
|
||||
(require 'init-ecb nil 'noerror)
|
||||
(require 'init-modeline nil 'noerror)
|
||||
(require 'init-indent-guides nil 'noerror)
|
||||
(require 'init-icons nil 'noerror)
|
||||
(require 'init-neotree nil 'noerror)
|
||||
(require 'init-nlinum)
|
||||
(require 'init-gui)
|
||||
(require 'init-editing-utils)
|
||||
(require 'init-diminish)
|
||||
(require 'init-ecb)
|
||||
(require 'init-modeline)
|
||||
(require 'init-indent-guides)
|
||||
(require 'init-icons)
|
||||
(require 'init-neotree)
|
||||
;; Tools
|
||||
(require 'init-apache nil 'noerror)
|
||||
(require 'init-company nil 'noerror)
|
||||
(require 'init-flycheck nil 'noerror)
|
||||
(require 'init-helm nil 'noerror)
|
||||
(require 'init-log4j nil 'noerror)
|
||||
(require 'init-whitespace nil 'noerror)
|
||||
(require 'init-emmet-mode nil 'noerror)
|
||||
(require 'init-nginx nil 'noerror)
|
||||
(require 'init-git nil 'noerror)
|
||||
(require 'init-apache)
|
||||
(require 'init-company)
|
||||
(require 'init-flycheck)
|
||||
(require 'init-helm)
|
||||
(require 'init-log4j)
|
||||
(require 'init-whitespace)
|
||||
(require 'init-emmet-mode)
|
||||
(require 'init-nginx)
|
||||
(require 'init-git)
|
||||
;;(require 'init-editorconfig nil 'noerror)
|
||||
;; Languages
|
||||
(require 'init-ccc nil 'noerror)
|
||||
(require 'init-crystal nil 'noerror)
|
||||
(require 'init-html nil 'noerror)
|
||||
(require 'init-markdown nil 'noerror)
|
||||
(require 'init-php nil 'noerror)
|
||||
(require 'init-python nil 'noerror)
|
||||
(require 'init-pkgbuild nil 'noerror)
|
||||
(require 'init-less nil 'noerror)
|
||||
(require 'init-sass nil 'noerror)
|
||||
(require 'init-scss nil 'noerror)
|
||||
(require 'init-yaml nil 'noerror)
|
||||
(require 'init-ccc)
|
||||
(require 'init-crystal)
|
||||
(require 'init-html)
|
||||
(require 'init-markdown)
|
||||
(require 'init-php)
|
||||
(require 'init-python)
|
||||
(require 'init-pkgbuild)
|
||||
(require 'init-less)
|
||||
(require 'init-sass)
|
||||
(require 'init-scss)
|
||||
(require 'init-yaml)
|
||||
;; Plus
|
||||
(require 'init-rainbow nil 'noerror)
|
||||
(require 'init-web-mode nil 'noerror)
|
||||
(require 'init-ready nil 'noerror)
|
||||
(require 'init-dokuwiki nil 'noerror))
|
||||
(require 'init-rainbow)
|
||||
(require 'init-web-mode)
|
||||
(require 'init-ready)
|
||||
(require 'init-dokuwiki))
|
||||
|
||||
;;; Loads custom file
|
||||
(when (file-exists-p custom-file)
|
||||
(load custom-file))
|
||||
|
||||
(setq gc-cons-threshold best-gc-cons-threshold)
|
||||
|
||||
(when window-system
|
||||
(let ((elapsed (float-time (time-subtract (current-time)
|
||||
emacs-start-time))))
|
||||
emacs-load-start-time))))
|
||||
(message "[STARTUP] Loading %s ... done (%.3fs)" load-file-name elapsed)))
|
||||
|
||||
(provide 'init)
|
||||
|
@ -3,14 +3,9 @@
|
||||
|
||||
;;; Code:
|
||||
|
||||
;; Make startup faster by reducing the frequency of garbage
|
||||
;; collection. The default is 800 kilobytes. Measured in bytes.
|
||||
(setq local/gc-cons-threshold (* 50 1000 1000))
|
||||
|
||||
(setq user-full-name "Jesús E.")
|
||||
(setq user-mail-address "heckyel@hyperbola.info")
|
||||
(set-language-environment "UTF-8")
|
||||
(setq large-file-warning-threshold (* 15 1024 1024))
|
||||
(prefer-coding-system 'utf-8)
|
||||
(setq-default buffer-file-coding-system 'utf-8-auto-unix)
|
||||
|
||||
|
Loading…
x
Reference in New Issue
Block a user