forked from matbonora/prelude
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathinit.el
262 lines (220 loc) · 11.2 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
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
;'(setq mac-option-modifier 'meta)
;;; init.el --- Prelude's configuration entry point.
;;
;; Copyright (c) 2011-2018 Bozhidar Batsov
;;
;; Author: Bozhidar Batsov <[email protected]>
;; URL: http://batsov.com/prelude
;; Version: 1.0.0
;; Keywords: convenience
;; This file is not part of GNU Emacs.
;;; Commentary:
;; This file simply sets up the default load path and requires
;; the various modules defined within Emacs Prelude.
;;; License:
;; This program is free software; you can redistribute it and/or
;; modify it under the terms of the GNU General Public License
;; as published by the Free Software Foundation; either version 3
;; of the License, or (at your option) any later version.
;;
;; This program is distributed in the hope that it will be useful,
;; but WITHOUT ANY WARRANTY; without even the implied warranty of
;; MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
;; GNU General Public License for more details.
;;
;; You should have received a copy of the GNU General Public License
;; along with GNU Emacs; see the file COPYING. If not, write to the
;; Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor,
;; Boston, MA 02110-1301, USA.
;;; Code:
;; Added by Package.el. This must come before configurations of
;; installed packages. Don't delete this line. If you don't want it,
;; just comment it out by adding a semicolon to the start of the line.
;; You may delete these explanatory comments.
;(package-initialize)
(defvar current-user
(getenv
(if (equal system-type 'windows-nt) "USERNAME" "USER")))
(message "Prelude is powering up... Be patient, Master %s!" current-user)
(when (version< emacs-version "25.1")
(error "Prelude requires GNU Emacs 25.1 or newer, but you're running %s" emacs-version))
;; Always load newest byte code
(setq load-prefer-newer t)
(defvar prelude-dir (file-name-directory load-file-name)
"The root dir of the Emacs Prelude distribution.")
(defvar prelude-core-dir (expand-file-name "core" prelude-dir)
"The home of Prelude's core functionality.")
(defvar prelude-modules-dir (expand-file-name "modules" prelude-dir)
"This directory houses all of the built-in Prelude modules.")
(defvar prelude-personal-dir (expand-file-name "personal" prelude-dir)
"This directory is for your personal configuration.
Users of Emacs Prelude are encouraged to keep their personal configuration
changes in this directory. All Emacs Lisp files there are loaded automatically
by Prelude.")
(defvar prelude-personal-preload-dir (expand-file-name "preload" prelude-personal-dir)
"This directory is for your personal configuration, that you want loaded before Prelude.")
(defvar prelude-vendor-dir (expand-file-name "vendor" prelude-dir)
"This directory houses packages that are not yet available in ELPA (or MELPA).")
(defvar prelude-savefile-dir (expand-file-name "savefile" prelude-dir)
"This folder stores all the automatically generated save/history-files.")
(defvar prelude-modules-file (expand-file-name "prelude-modules.el" prelude-personal-dir)
"This file contains a list of modules that will be loaded by Prelude.")
(defvar prelude-deprecated-modules-file
(expand-file-name "prelude-modules.el" prelude-dir)
(format "This file may contain a list of Prelude modules.
This is DEPRECATED, use %s instead." prelude-modules-file))
(unless (file-exists-p prelude-savefile-dir)
(make-directory prelude-savefile-dir))
(defun prelude-add-subfolders-to-load-path (parent-dir)
"Add all level PARENT-DIR subdirs to the `load-path'."
(dolist (f (directory-files parent-dir))
(let ((name (expand-file-name f parent-dir)))
(when (and (file-directory-p name)
(not (string-prefix-p "." f)))
(add-to-list 'load-path name)
(prelude-add-subfolders-to-load-path name)))))
;; add Prelude's directories to Emacs's `load-path'
(add-to-list 'load-path prelude-core-dir)
(add-to-list 'load-path prelude-modules-dir)
(add-to-list 'load-path prelude-vendor-dir)
(prelude-add-subfolders-to-load-path prelude-vendor-dir)
;; reduce the frequency of garbage collection by making it happen on
;; each 50MB of allocated data (the default is on every 0.76MB)
(setq gc-cons-threshold 50000000)
;; warn when opening files bigger than 100MB
(setq large-file-warning-threshold 100000000)
;; preload the personal settings from `prelude-personal-preload-dir'
(when (file-exists-p prelude-personal-preload-dir)
(message "Loading personal configuration files in %s..." prelude-personal-preload-dir)
(mapc 'load (directory-files prelude-personal-preload-dir 't "^[^#\.].*el$")))
(message "Loading Prelude's core...")
;; the core stuff
(require 'prelude-packages)
(require 'prelude-custom) ;; Needs to be loaded before core, editor and ui
(require 'prelude-ui)
(require 'prelude-core)
(require 'prelude-mode)
(require 'prelude-editor)
(require 'prelude-global-keybindings)
;; macOS specific settings
(when (eq system-type 'darwin)
(require 'prelude-macos))
;; Linux specific settings
(when (eq system-type 'gnu/linux)
(require 'prelude-linux))
(message "Loading Prelude's modules...")
;; the modules
(if (file-exists-p prelude-modules-file)
(progn
(load prelude-modules-file)
(if (file-exists-p prelude-deprecated-modules-file)
(message "Loading new modules configuration, ignoring DEPRECATED prelude-module.el")))
(if (file-exists-p prelude-deprecated-modules-file)
(progn
(load prelude-deprecated-modules-file)
(message (format "The use of %s is DEPRECATED! Use %s instead!"
prelude-deprecated-modules-file
prelude-modules-file)))
(message "Missing modules file %s" prelude-modules-file)
(message "You can get started by copying the bundled example file from sample/prelude-modules.el")))
;; config changes made through the customize UI will be stored here
(setq custom-file (expand-file-name "custom.el" prelude-personal-dir))
;; load the personal settings (this includes `custom-file')
(when (file-exists-p prelude-personal-dir)
(message "Loading personal configuration files in %s..." prelude-personal-dir)
(mapc 'load (delete
prelude-modules-file
(directory-files prelude-personal-dir 't "^[^#\.].*\\.el$"))))
(message "Prelude is ready to do thy bidding, Master %s!" current-user)
;; Patch security vulnerability in Emacs versions older than 25.3
(when (version< emacs-version "25.3")
(with-eval-after-load "enriched"
(defun enriched-decode-display-prop (start end &optional param)
(list start end))))
(prelude-eval-after-init
;; greet the use with some useful tip
(run-at-time 5 nil 'prelude-tip-of-the-day))
;; enables hunspell for ispell
;;(on macos https://joelkuiper.eu/spellcheck_emacs, http://apple.stackexchange.com/questions/97811/where-are-the-system-spellchecking-dictionaries
;;brew install hunspell
;;cd /Library
;;sudo mkdir Spelling
;;cd Spelling
;;)
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
;; (when (executable-find "hunspell") ;;
;; (setq-default ispell-program-name "hunspell") ;;
;; (setq ispell-really-hunspell t)) ;;
;; ;;
;; (setq ispell-program-name "hunspell") ;;
;; ;; below two lines reset the the hunspell to it STOPS querying locale! ;;
;; (setq ispell-local-dictionary "en_GB") ; "en_US" is key to lookup in `ispell-local-dictionary-alist` ;;
;; (setq ispell-local-dictionary-alist ;;
;; '(("en_GB" "[[:alpha:]]" "[^[:alpha:]]" "[']" nil ("-d" "en_GB") nil utf-8))) ;;
;; ;;
;; (setenv "DICTIONARY" "en_GB") ;;
;; (getenv "LANG") ;;
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
;; if (aspell installed) { use aspell}
;; else if (hunspell installed) { use hunspell }
;; whatever spell checker I use, I always use English dictionary
;; I prefer use aspell because:
;; 1. aspell is older
;; 2. looks Kevin Atkinson still get some road map for aspell:
;; @see http://lists.gnu.org/archive/html/aspell-announce/2011-09/msg00000.html
(defun flyspell-detect-ispell-args (&optional run-together)
"if RUN-TOGETHER is true, spell check the CamelCase words."
(let (args)
(cond
((string-match "aspell$" ispell-program-name)
;; Force the English dictionary for aspell
;; Support Camel Case spelling check (tested with aspell 0.6)
(setq args (list "--sug-mode=ultra" "--lang=en_GB"))
(if run-together
(setq args (append args '("--run-together" "--run-together-limit=5" "--run-together-min=2")))))
((string-match "hunspell$" ispell-program-name)
;; Force the English dictionary for hunspell
(setq args "-d en_GB")))
args))
(cond
((executable-find "aspell")
;; you may also need `ispell-extra-args'
(setq ispell-program-name "aspell"))
; ((executable-find "hunspell")
; (setq ispell-program-name "hunspell")
;; Please note that `ispell-local-dictionary` itself will be passed to hunspell cli with "-d"
;; it's also used as the key to lookup ispell-local-dictionary-alist
;; if we use different dictionary
(setq ispell-local-dictionary "en_GB")
(setq ispell-local-dictionary-alist
'(("en_GB" "[[:alpha:]]" "[^[:alpha:]]" "[']" nil ("-d" "en_GB") nil utf-8))))
;((setq ispell-program-name nil))
;; ispell-cmd-args is useless, it's the list of *extra* arguments we will append to the ispell process when "ispell-word" is called.
;; ispell-extra-args is the command arguments which will *always* be used when start ispell process
;; Please note when you use hunspell, ispell-extra-args will NOT be used.
;; Hack ispell-local-dictionary-alist instead.
(setq-default ispell-extra-args (flyspell-detect-ispell-args t))
;; (setq ispell-cmd-args (flyspell-detect-ispell-args))
(defadvice ispell-word (around my-ispell-word activate)
(let ((old-ispell-extra-args ispell-extra-args))
(ispell-kill-ispell t)
(setq ispell-extra-args (flyspell-detect-ispell-args))
ad-do-it
(setq ispell-extra-args old-ispell-extra-args)
(ispell-kill-ispell t)
))
(defadvice flyspell-auto-correct-word (around my-flyspell-auto-correct-word activate)
(let ((old-ispell-extra-args ispell-extra-args))
(ispell-kill-ispell t)
;; use emacs original arguments
(setq ispell-extra-args (flyspell-detect-ispell-args))
ad-do-it
;; restore our own ispell arguments
(setq ispell-extra-args old-ispell-extra-args)
(ispell-kill-ispell t)
))
(defun text-mode-hook-setup ()
;; Turn off RUN-TOGETHER option when spell check text-mode
(setq-local ispell-extra-args (flyspell-detect-ispell-args)))
(add-hook 'text-mode-hook 'text-mode-hook-setup)
;;; init.el ends here