-
Notifications
You must be signed in to change notification settings - Fork 0
/
init.el
262 lines (190 loc) · 6.56 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
; -------------------------------------------
; ███████╗███╗ ███╗ █████╗ ██████╗███████╗
; ██╔════╝████╗ ████║██╔══██╗██╔════╝██╔════╝
; █████╗ ██╔████╔██║███████║██║ ███████╗
; ██╔══╝ ██║╚██╔╝██║██╔══██║██║ ╚════██║
; ███████╗██║ ╚═╝ ██║██║ ██║╚██████╗███████║
; ╚══════╝╚═╝ ╚═╝╚═╝ ╚═╝ ╚═════╝╚══════╝
; ------------ THE EDITOR OF A LIFETIME -----
; https://www.gnu.org/software/emacs/manual/html_node/elisp/Idle-Timers.html
; https://stackoverflow.com/questions/2321904/elisp-how-to-save-data-in-a-file
(random t)
; '(browse-url-browser-function (quote browse-url-chrome))
; '(browse-url-chrome-program
; "/mnt/c/Program Files (x86)/Google/Chrome/Application/chrome.exe")
; Customizations file
; git update-index --assume-unchanged local-customizations.el
(setq custom-file "~/.emacs.d/local-customizations.el")
(load custom-file)
(defgroup joegle nil
"Namespace for my stuff"
:group 'emacs)
(defcustom joegle-enable-cs-timeout t
"Enable to random alert for cheatsheet review"
:type 'boolean
:group 'joegle)
(defcustom joegle-cs-do-repeat t
"Enable for cheatsheet alert timeout to repeat"
:type 'boolean
:group 'joegle)
(defcustom joegle-timeout-seconds 3
"idle time limit to trigger prompt"
:type 'integer
:group 'joegle)
(defcustom joegle-chance-factor 200
"set chance of prompt to be 1/n"
:type 'integer
:group 'joegle)
(defcustom joegle-prompt-file "~/.prompts"
"each line of this file is a prompt"
:type 'file
:group 'joegle)
(defun read-lines (filePath)
"Return a list of lines of a file at filePath."
(with-temp-buffer
(insert-file-contents filePath)
(split-string (buffer-string) "\n" t)))
(defun random-pick-from-list (m lst)
"pick m non-repeating elements from list
burubaxair.wordpress.com"
(let ((lng-lst (length lst)))
(if (or (<= m 0) (> m lng-lst))
nil
(loop
with el
until (= (length rand-lst) m)
when (not (find
(setf el (nth (random lng-lst) lst))
rand-lst))
append (list el) into rand-lst
finally (return rand-lst)))))
(defun r-prompt ()
"Return random prompt from prompt set"
(interactive)
(car (random-pick-from-list 1 (read-lines joegle-prompt-file))))
(defun chance-n (n)
"Random chance out of n"
(eq 0 (random n)))
(defun ff ()
"Prompt user to enter a file name, with completion and history support."
(interactive)
(if (y-or-n-p-with-timeout "Would you like to review cheatsheet?" 3 nil)
(cheatsheet-show)))
(defun maybe-ask-cheatsheet ()
(if (chance-n joegle-chance-factor)
(ff)))
(if joegle-enable-cs-timeout
(run-with-idle-timer joegle-timeout-seconds joegle-cs-do-repeat 'maybe-ask-cheatsheet))
;; Define package repositories
(require 'package)
(setq package-archives '(("melpa" . "http://melpa.org/packages/")
("melpa-stable" . "http://stable.melpa.org/packages/")
("org" . "http://orgmode.org/elpa/")))
(package-initialize)
;; Load and activate emacs packages. Do this first so that the
;; packages are loaded before you start trying to modify them.
;; This also sets the load path.
(when (not package-archive-contents)
(package-refresh-contents))
;; Download the ELPA archive description if needed.
;; This informs Emacs about the latest versions of all packages, and
;; makes them available for download.
; When you have trouble getting packages:
;(package-refresh-contents)
; This adds a lot of start up delay
;(when (not package-archive-contents)
; (package-refresh-contents))
;; The packages you want installed. You can also install these
;; manually with M-x package-install
(defvar my-packages
'(
;; Enhances M-x to allow easier execution of commands. Provides
;; a filterable list of possible commands in the minibuffer
;; http://www.emacswiki.org/emacs/Smex
smex
rg
rjsx-mode
projectile
multi-web-mode
dash-at-point
fix-word
fill-column-indicator
;; colorful parenthesis matching
rainbow-delimiters
;; git integration
magit
;; sidebar / file explorer
neotree
goto-last-change
god-mode
move-text
auto-complete
guide-key
moe-theme
all-the-icons
markdown-mode
dockerfile-mode
openwith
yaml-mode
ob-ipython
sublimity
expand-region
js2-mode
ace-jump-mode
json-mode
use-package
ein
go-mode))
(dolist (p my-packages)
(when (not (package-installed-p p))
(package-install p)))
;; Place downloaded elisp files in ~/.emacs.d/vendor. You'll then be able
;; to load them.
;;
;; For example, if you download yaml-mode.el to ~/.emacs.d/vendor,
;; then you can add the following code to this file:
;;
;; (require 'yaml-mode)
;; (add-to-list 'auto-mode-alist '("\\.yml$" . yaml-mode))
;;
;; Adding this code will make Emacs enter yaml mode whenever you open
;; a .yml file
(add-to-list 'load-path "~/.emacs.d/vendor")
;; Customization qq
;; Add a directory to our load path so that when you `load` things
;; below, Emacs knows where to look for the corresponding file.
(add-to-list 'load-path "~/.emacs.d/customizations")
(load "ui.el")
(load "editing.el")
(load "misc.el")
(load "uncommitted-dmz-todo-changes-DO-NOT-SAVE" 'ignore-if-missing)
(load "setup-fci.el")
(load "setup-grep.el")
(load "setup-moe.el")
(load "setup-deft.el")
(load "setup-daypage.el")
(load "setup-org.el")
(load "setup-guide-key.el")
(load "cheatsheet-groups.el")
(load "setup-auto-complete.el")
(load "setup-expand-region.el")
(load "setup-ace-jump-mode.el")
(load "setup-god-mode.el")
(load "setup-sublimity.el")
(load "setup-javascript.el")
(load "setup-go.el")
(load "setup-bookmarks.el")
(load "setup-python.el")
(load "setup-magit.el")
(if (eq system-type 'darwin)
(load "setup-mac.el"))
;; Language-specific
;(load "setup-clojure.el")
;(load "setup-js.el")
(message "🔸🔸 dot-emacs git status 🔷🔷")
(message (shell-command-to-string "git -C ~/.emacs.d/ status -s "))
(message (format "Load time: %s" (emacs-init-time)))
(with-eval-after-load 'rjsx-mode
(define-key rjsx-mode-map "<" nil)
(define-key rjsx-mode-map (kbd "C-d") nil)
(define-key rjsx-mode-map ">" nil))