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
|
;;; -*- lexical-binding: t; -*-
;;; garbage collection threshold maneuvre
(setq gc-cons-threshold (* 512 1024 1024))
;;; tell me the start time at start-up
;;;###autoload
(defun message-start-time ()
"Tell me the start time at start-up."
(interactive)
(message "%s" (emacs-init-time)))
(add-hook 'emacs-startup-hook #'message-start-time)
;;; Macro to conveniently load files
;;;###autoload
(defvar load-file-directory (cond ((stringp load-file-name) (file-name-directory load-file-name))
(t default-directory))
"The directory to load files")
;;;###autoload
(defsubst load-config (file-name)
"Conviently load configuration files in the same directory as this file."
(load-file (expand-file-name file-name load-file-directory)))
;;;###autoload
(defun load-config-later (file-name seconds)
"Load FILE-NAME SECONDS later."
(run-with-idle-timer seconds nil (lambda () (load-config file-name))))
;;;###autoload
(defmacro prepare-in-hook-once (entry-name hook file)
"Define a function called ENTRY-NAME that loads FILE in HOOK once."
`(progn
(defun ,entry-name ()
(interactive)
(remove-hook ',hook ',entry-name)
(load-config ,file))
(add-hook ',hook ',entry-name)))
;;;###autoload
(defmacro load-after-function (function-name file-path doc redefine-p &rest def)
"Load FILE-PATH after FUNCTION-NAME.
After loading, execute DEF.
Finally if REDEFINE-P is non-nil,
then FUNCTION-NAME will be defined as DEF after loading.
If FUNCTION-NAME is already a valid function, this won't do anything."
(cond
((fboundp function-name))
(t
`(defun ,function-name ()
,doc
(interactive)
(load-config ,file-path)
,@def
,(cond
(redefine-p
`(defun ,function-name ()
,doc
(interactive)
,@def)))))))
(load-config "common.el")
(load-config "basic.el")
(load-config "backup-conf.el")
(load-config "recentf-conf.el")
(load-config "dashboard.el")
(load-config "theme.el")
(load-config "modeline.el")
(add-hook 'emacs-lisp-mode-hook
(lambda () (set 'mode-name "ELisp")))
(prepare-in-hook-once prepare-elisp emacs-lisp-mode-hook "elisp.el")
(prepare-in-hook-once prepare-org org-mode-hook "org-conf.el")
(add-hook 'org-mode-hook #'prepare-org)
(define-key global-map (vector 3 97) #'prepare-org)
(define-key global-map (vector 3 99) #'prepare-org)
(define-key global-map (vector 3 ?l) #'prepare-org)
;;;###autoload
(load-after-function durand-mu4e "mail.el" "Open mu4e." t (mu4e))
(add-to-list 'auto-mode-alist (cons "pdf$" #'pdf-view-mode))
;;;###autoload
(load-after-function pdf-view-mode "pdf.el" "Fake mode that loads the pacakge." nil
(pdf-view-mode))
;;; bongo
;;;###autoload
(load-after-function bongo "bongo.el" "Listen to music in Emacs." nil
(bongo))
;;; My PDF facilities
(use-package "durand-chercher-pdf" 'durand-chercher-pdf
(define-key durand-pdf-mode-map (vector ?q) 'quit-window)
(define-key durand-pdf-mode-map (vector ?x) #'durand-chercher-pdf-exit)
(define-key durand-pdf-mode-map (vector ?N) 'forward-line)
(define-key durand-pdf-mode-map (vector ?n) 'durand-pdf-next-pdf-line)
(define-key durand-pdf-mode-map (vector ?P) (lambda () (interactive) (forward-line -1)))
(define-key durand-pdf-mode-map (vector ?p) 'durand-pdf-previous-pdf-line)
(define-key durand-pdf-mode-map (vector 'return) 'durand-pdf-open-pdf)
(define-key durand-pdf-mode-map (vector 32) 'durand-pdf-open-or-scroll-up)
(define-key durand-pdf-mode-map (vector 'backspace) 'durand-pdf-open-or-scroll-down)
(define-key durand-pdf-mode-map (vector ?o) 'kill-other-buffer-window)
(define-key durand-pdf-mode-map (vector ?k) 'kill-current-buffer)
(cond
((assoc durand-chercher-pdf-buffer-name display-buffer-alist #'string-match)
(setcdr (assoc durand-chercher-pdf-buffer-name
display-buffer-alist #'string-match)
'((display-buffer-in-tab durand-display-in-one-window)
(tab-name . "chercher pdf"))))
(t
(add-to-list 'display-buffer-alist
`(,(rx-to-string `(seq bos ,durand-chercher-pdf-buffer-name eos))
(display-buffer-in-tab durand-display-in-one-window)
(tab-name . "chercher pdf"))))))
;;; gnus
(load-config "gnus-conf.el")
;;; comb
;; (load-config "comb/comb.el")
;; (load-config "comb/comb-annotation.el")
;;; Completion framework configurations
;; TODO: Write my own completion styles library
;; (load-config "comb/orderless-conf.el")
(load-config "completion-conf.el")
;;; dired configurations
(prepare-in-hook-once prepare-dired dired-mode-hook "dired-conf.el")
(add-hook 'dired-mode-hook 'dired-hide-details-mode)
;;; ibuffer
(load-config "ibuffer.el")
;;; center buffer
(load-config "center-buffer.el")
;;; tab configurations
(load-config "tab-conf.el")
;;; Save sessions
(load-config "desktop-conf.el")
;;; Text Configurations
(prepare-in-hook-once prepare-text text-mode-hook "text-conf.el")
;;; embark
;; (load-config "embark-conf.el")
;;; magit
(load-after-function magit "magit-conf.el" "Load magit and launch it." nil
(defalias 'magit 'magit-status)
(magit))
(define-key global-map (vector ?\C-x ?g) 'magit)
;;; eww
(load-config "eww-conf.el")
;;; Viewing things
(load-config "view-conf.el")
;;; flymake
(prepare-in-hook-once prepare-flymake prog-mode-hook "flymake-conf.el")
;;; Don't let s-q quit as I oft press that by accident.
(define-key global-map (vector ?\s-q) #'window-toggle-side-windows)
;;; My simple utilities
(use-package "durand-simple" 'durand-simple
(define-key global-map (vector ?\C-\M-\s) #'durand-simple-mark-dwim)
(define-key global-map (vector ?\C-o) #'durand-simple-open-line)
(define-key global-map (vector ?\C-') #'durand-simple-insert-pair))
;;; Searches
(load-config "search-conf.el")
;;; Transpose frame
(use-package "transpose-frame" 'transpose-frame
(define-key global-map (vector ?\C-\s-r) #'rotate-frame-clockwise)
(define-key global-map (vector ?\C-\s-t) #'transpose-frame))
;;; server
;; (cond
;; ((bound-and-true-p server-process))
;; ((server-start)))
(setq gc-cons-threshold (* 2 1024 1024))
|