forked from redguardtoo/emacs.d
-
Notifications
You must be signed in to change notification settings - Fork 1
/
init.el
160 lines (140 loc) · 5.76 KB
/
init.el
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
;; -*- coding: utf-8; lexical-binding: t; -*-
;; (advice-add #'package-initialize :after #'update-load-path)
;; Without this comment emacs25 adds (package-initialize) here
;; (package-initialize)
(push (expand-file-name "~/.emacs.d/lisp") load-path)
(let* ((minver "24.4"))
(when (version< emacs-version minver)
(error "Emacs v%s or higher is required." minver)))
(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))
;; {{ emergency security fix
;; https://bugs.debian.org/766397
(eval-after-load "enriched"
'(defun enriched-decode-display-prop (start end &optional param)
(list start end)))
;; }}
;;----------------------------------------------------------------------------
;; 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))
(defmacro local-require (pkg)
`(unless (featurep ,pkg)
(load (expand-file-name
(cond
((eq ,pkg 'bookmark+)
(format "~/.emacs.d/site-lisp/bookmark-plus/%s" ,pkg))
((eq ,pkg 'go-mode-load)
(format "~/.emacs.d/site-lisp/go-mode/%s" ,pkg))
(t
(format "~/.emacs.d/site-lisp/%s/%s" ,pkg ,pkg))))
t t)))
;; *Message* buffer should be writable in 24.4+
(defadvice switch-to-buffer (after switch-to-buffer-after-hack activate)
(if (string= "*Messages*" (buffer-name))
(read-only-mode -1)))
;; @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-autoload)
(require 'init-modeline)
(require 'init-utils)
(require 'init-elpa)
(require 'init-exec-path) ;; Set up $PATH
;; Any file use flyspell should be initialized after init-spelling.el
(require 'init-spelling)
(require 'init-gui-frames)
(require 'init-uniquify)
(require 'init-ibuffer)
(require 'init-ivy)
(require 'init-hippie-expand)
(require 'init-windows)
(require 'init-markdown)
(require 'init-javascript)
(require 'init-org)
(require 'init-css)
(require 'init-python)
(require 'init-ruby-mode)
(require 'init-lisp)
(require 'init-elisp)
(require 'init-yasnippet)
;; Use bookmark instead
(require 'init-cc-mode)
(require 'init-gud)
(require 'init-linum-mode)
(require 'init-git) ;; git-gutter should be enabled after `display-line-numbers-mode' turned on
;; (require 'init-gist)
(require 'init-gtags)
;; init-evil dependent on init-clipboard
(require 'init-clipboard)
;; use evil mode (vi key binding)
(require 'init-evil)
(require 'init-ctags)
(require 'init-bbdb)
(require 'init-gnus)
(require 'init-lua-mode)
(require 'init-workgroups2)
(require 'init-term-mode)
(require 'init-web-mode)
(require 'init-company)
(require 'init-chinese) ;; cannot be idle-required
;; need statistics of keyfreq asap
(require 'init-keyfreq)
(require 'init-httpd)
;; projectile costs 7% startup time
;; misc has some crucial tools I need immediately
(require 'init-misc)
(require 'init-emacs-w3m)
(require 'init-hydra)
(require 'init-shackle)
(require 'init-dired)
(require 'init-writting)
;; @see https://github.com/hlissner/doom-emacs/wiki/FAQ
;; Adding directories under "site-lisp/" to `load-path' slows
;; down all `require' statement. So we do this at the end of startup
;; Neither ELPA package nor dependent on "site-lisp/".
(setq load-path (cdr load-path))
(load (expand-file-name "~/.emacs.d/lisp/init-site-lisp") t t)
;; my personal setup, other major-mode specific setup need it.
;; It's dependent on "~/.emacs.d/site-lisp/*.el"
(load (expand-file-name "~/.custom.el") t nil)
;; @see https://www.reddit.com/r/emacs/comments/4q4ixw/how_to_forbid_emacs_to_touch_configuration_files/
;; See `custom-file' for details.
(load (setq custom-file (expand-file-name "~/.emacs.d/custom-set-variables.el")) t t))
(setq gc-cons-threshold best-gc-cons-threshold)
(when (require 'time-date nil t)
(message "Emacs startup time: %d seconds."
(time-to-seconds (time-since emacs-load-start-time))))
;;; Local Variables:
;;; no-byte-compile: t
;;; End:
(put 'erase-buffer 'disabled nil)