-
Notifications
You must be signed in to change notification settings - Fork 1
/
more-settings.el
338 lines (280 loc) · 11.8 KB
/
more-settings.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
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
(defun add-menu-item (key command)
(global-set-key (kbd (concat "C-; " key)) command))
(defun find-init-file () (interactive) (find-file user-init-file))
(add-menu-item "i" 'find-init-file)
(add-menu-item "p" 'proced)
(setq external-pdf-viewer "zathura")
(setq custom-file "~/.emacs.d/custom.el")
(load-file custom-file)
(defun neofetch () (interactive) (async-shell-command "neofetch" "*Neofetch*"))
(setq inhibit-startup-screen t)
(neofetch)
(defun latex-init-settings ()
(setq TeX-parse-self t)
(add-to-list 'TeX-command-list
'("latexmk lualatex compile" "latexmk -lualatex %s" TeX-run-command nil t))
(add-to-list 'TeX-command-list
'("latexmk lualatex preview" "latexmk -lualatex -pvc -view=none %s" TeX-run-command nil t))
(add-to-list 'TeX-command-list
'("latexindent" "latexindent -w %s" TeX-run-command nil t))
(setq TeX-view-program-selection '((output-pdf "Okular")))
(setq cdlatex-math-modify-alist
'((98 "\\mathbb" nil t nil nil)
(102 "\\mathfrak" nil t nil nil)))
(setq cdlatex-math-symbol-alist
'((120 "\\chi" "\\otimes")
(62 "\\geq" "\\geqsim")
(60 "\\leq" "\\lesssim"))))
(defun latex-hook ()
(cdlatex-mode 1)
(reftex-mode 1)
(prettify-symbols-mode 1))
(use-package latex
:defer t
:ensure auctex
:config (latex-init-settings))
(add-hook 'LaTeX-mode-hook 'latex-hook)
(defun latex-in-org-settings ()
(progn
(require 'ox-bibtex)
(setq org-highlight-latex-and-related '(latex script entities))
(plist-put org-format-latex-options :scale 2.0)
))
(defun org-indent-paragraph () (interactive)
(org-backward-paragraph)
(push-mark)
(org-forward-paragraph)
(org-indent-region
(mark) (point)))
(defun org-insert-block (type header-args) (interactive "sBlock Type: \nsHeader Arguments: ")
(insert "\n#+BEGIN_" type " " header-args "\n\n#+END_" type)
(previous-line))
(defun org-init-settings ()
(latex-in-org-settings)
(setq org-agenda-start-on-weekday 0)
(require 'org-ref-ivy)
(setq org-ref-insert-link-function 'org-ref-insert-link-hydra/body
org-ref-insert-cite-function 'org-ref-cite-insert-ivy
org-ref-insert-label-function 'org-ref-insert-label-link
org-ref-insert-ref-function 'org-ref-insert-ref-link)
(require 'org-ref)
(require 'org-noter)
(setq org-todo-keywords
'((sequence "IN" "NEXT ACTIONS" "WAITING FOR" "EVENTUALLY" "|" "DONE" "CANCELLED"))))
(defun org-hook () ()
(visual-line-mode)
(local-set-key (kbd "C-c ]") 'org-ref-insert-link-hydra)
(local-set-key (kbd "C-c b") 'org-insert-block)
(org-cdlatex-mode))
(use-package org
:defer t
:config (org-init-settings))
(add-menu-item "a" 'org-agenda)
(add-hook 'org-mode-hook 'org-hook)
(setq bibtex-completion-pdf-field "file"
bibtex-completion-bibliography "~/zoterolib.bib"
bibtex-completion-pdf-open-function
(lambda (fpath) (call-process external-pdf-viewer nil 0 nil fpath))
bibtex-completion-library-path '("~/pdfs"))
(add-menu-item "b" 'ivy-bibtex)
(defun machine-uptime () (interactive) (shell-command "uptime"))
(defun pacman-update () (interactive) (async-shell-command "sudo pacman -Syu"))
(defun get-weather () (interactive)
(async-shell-command "curl -s 'https://wttr.in/chicago?0p'" "*wttr.in*" nil))
(defun smart-kill-word () (interactive)
(forward-word)
(kill-word -1))
(defun my-editing-keybindings () (interactive)
(setq sentence-end-double-space nil)
(global-set-key (kbd "C-x s") 'swiper)
(global-set-key (kbd "C-k") 'crux-smart-kill-line)
(global-set-key (kbd "M-d") 'smart-kill-word)
(unbind-key "C-z")
(global-set-key (kbd "C-z p") 'ping)
(global-set-key (kbd "C-z t") 'machine-uptime)
(global-set-key (kbd "C-z b") 'battery)
(global-set-key (kbd "C-z u") 'pacman-update)
(global-set-key (kbd "C-z w") 'get-weather)
)
(use-package magit)
(use-package projectile
:config (progn
(projectile-mode 1)
(define-key projectile-mode-map (kbd "C-x p") 'projectile-command-map)))
(use-package dired-x
:config (progn
(setq dired-listing-switches "-ahl")
(setq dired-guess-shell-alist-user
`(("\\.bib$" "~/.local/bin/bibly")
("\\.pdf$" ,(concat external-pdf-viewer " *"))))))
(defun counsel-keybindings () (interactive)
(global-set-key (kbd "M-o") 'ace-window)
(setq aw-keys '(?a ?s ?d ?f ?g ?h ?j ?k ?l))
(global-set-key (kbd "M-s m") 'counsel-imenu)
(global-set-key (kbd "M-s b") 'counsel-ibuffer)
(global-set-key (kbd "C-x b") 'counsel-switch-buffer)
(global-set-key (kbd "C-x 4 b") 'counsel-switch-buffer-other-window)
(global-set-key (kbd "M-z") 'counsel-linux-app))
(use-package counsel
:config (progn
(counsel-mode 1)
(counsel-projectile-mode 1)
(ivy-mode 1)
(counsel-keybindings)))
(use-package crux
:config (my-editing-keybindings))
(repeat-mode)
(defun xmonad-tree-navigator (tree)
(if (windowp tree) tree
(if (listp tree) (xmonad-tree-navigator (car (last tree)))
(error "Encountered a non-list or non window argument"))))
(defun xmonad-tall (curr-win)
(if (one-window-p) (split-window-right)
(progn
(select-window (xmonad-tree-navigator (car (window-tree))))
(split-window-below))))
(defun bsp-tree-navigator (tree)
(if (windowp tree) tree
(if (listp tree) (bsp-tree-navigator (car (last tree)))
(error "Encountered a non-list or non-window argument"))))
(defun bspwm (curr-win)
(let ((to-window (bsp-tree-navigator (car (window-tree)))))
(progn
(select-window to-window)
(if (window-combined-p to-window t)
(split-window-below)
(split-window-right)))))
(defun bspwm-vert (curr-win)
(let ((to-window (bsp-tree-navigator (car (window-tree)))))
(progn
(select-window to-window)
(if (window-combined-p to-window)
(split-window-right)
(split-window-below)))))
(setq layout-list '(split-window-sensibly xmonad-tall bspwm bspwm-vert))
(defun select-window-layout (symbol) (interactive "Slayout: ")
(if (member symbol layout-list) (setq split-window-preferred-function symbol)
(error "Not a layout in layout-list")))
(defun current-window-layout () (interactive)
(message split-window-preferred-function))
(defun my-avy-keybindings () (interactive)
(global-set-key (kbd "M-g g") 'avy-goto-char-2)
(global-set-key (kbd "M-g c") 'avy-goto-char)
(global-set-key (kbd "M-g M-g") 'avy-goto-line)
(global-set-key (kbd "M-g f") 'avy-goto-char-in-line)
(global-set-key (kbd "M-g e") 'avy-goto-end-of-line))
(use-package avy
:config (my-avy-keybindings))
(defvar make-window-repeat-map
(let ((map (make-sparse-keymap)))
(define-key map "2" 'split-window-below)
(define-key map "3" 'split-window-right)
(define-key map "0" 'delete-window)
(define-key map "=" 'balance-windows)
(define-key map "b" 'switch-to-buffer) map)
"making, breaking, and switching window. for use in repeat-mode")
(put 'split-window-below 'repeat-map 'make-window-repeat-map)
(put 'split-window-right 'repeat-map 'make-window-repeat-map)
(put 'delete-window 'repeat-map 'make-window-repeat-map)
(put 'balance-windows 'repeat-map 'make-window-repeat-map)
(put 'switch-to-buffer 'repeat-map 'make-window-repeat-map)
(defvar move-map
(let ((map (make-sparse-keymap)))
(define-key map "n" 'next-line)
(define-key map "p" 'previous-line)
(define-key map "a" 'beginning-of-line-text)
(define-key map "e" 'end-of-line)
(define-key map "f" 'forward-word)
(define-key map "g" 'keyboard-quit)
(define-key map "b" 'backward-word)
(define-key map (kbd "SPC") 'set-mark-command)
(define-key map "w" 'kill-region)
(define-key map "y" 'yank) map)
"movement and editing commands. tiny vim normal mode.")
(put 'next-line 'repeat-map 'move-map)
(put 'previous-line 'repeat-map 'move-map)
(put 'beginning-of-line-text 'repeat-map 'move-map)
(put 'end-of-line 'repeat-map 'move-map)
(put 'set-mark-command 'repeat-map 'move-map)
(put 'kill-region 'repeat-map 'move-map)
(put 'yank 'repeat-map 'move-map)
(put 'forward-word 'repeat-map 'move-map)
(put 'backward-word 'repeat-map 'move-map)
(defvar cumulative-object-ring nil "An object to be repeatedly acted on by stick-cmd")
(defun cumulative-push-object (lisp-object) (interactive "XLisp Object:") (push lisp-object cumulative-object-ring))
(defvar cumulative-action-ring nil "A list of symbols to act on cumulative-object")
(defun cumulative-push-action (command) (interactive "CCumulative Action:") (push command cumulative-actions))
(defun cumulative-exec ()
(interactive)
(dolist (cmd cumulative-actions)
(dolist (cumulative-object cumulative-object-ring)
(eval `(,cmd ,cumulative-object))))
(setq cumulative-object nil)
(setq cumulative-actions nil))
(defun cumulative-push-buffer (buf) (interactive "bCumulative Buffer:") (push buf cumulative-object-ring))
(defun cumulative-push-file (fil) (interactive "FCumulative File:") (push buf cumulative-object-ring))
(defun cumulative-push-region (beg end) (interactive "r") (push (list beg end) cumulative-object-ring))
(defun cumulative-push-save-and-kill () (interactive) (cumulative-push-action 'save-buffer) (cumulative-push-action 'kill-buffer))
(defun cumulative-push-find-other-window () (interactive) (cumulative-push-action 'find-file-other-window))
(defun cumulative-push-kill () (interactive) (cumulative-push-action 'kill-region))
(defun cumulative-clear-actions () (interactive) (setq cumulative-action-ring nil))
(defun cumulative-clear-objects () (interactive) (setq cumulative-object-ring nil))
(defvar cumulative-map
(let ((map (make-sparse-keymap)))
(define-key map (kbd "M-c o") 'cumulative-push-object)
(define-key map (kbd "M-c a") 'cumulative-push-action)
(define-key map (kbd "M-c x") 'cumulative-exec)
(define-key map (kbd "M-c b") 'cumulative-push-buffer)
(define-key map (kbd "M-c f") 'cumulative-push-file)
(define-key map (kbd "M-c r") 'cumulative-push-region)
(define-key map (kbd "M-c s") 'cumulative-push-save-and-kill)
(define-key map (kbd "M-c 4 f") 'cumulative-push-find-other-window)
(define-key map (kbd "M-c k") 'cumulative-push-kill) map)
"keymap for some common cumulative commands")
(define-minor-mode cumulative-mode
"collect functions and targets for cumulative actions that can be executed."
:global t
:init-value nil
:lighter " cum"
:keymap cumulative-map)
(setq my-dark-themes [dracula
modus-vivendi
alect-black
alect-black-alt
alect-dark
alect-dark-alt
gruvbox-dark-hard
gruvbox-dark-medium
gruvbox-dark-medium])
(defun load-random-theme (theme-list) (interactive "XTheme List: ")
(load-theme (seq-random-elt theme-list) t))
(if (display-graphic-p)
(load-random-theme my-dark-themes))
(defun my-elfeed-settings () (interactive)
(global-set-key (kbd "C-; e") 'elfeed)
(setq elfeed-feeds
'(("https://api.quantamagazine.org/feed/" science)
("https://acoup.blog/feed" history)
("https://www.bloomberg.com/opinion/authors/ARbTQlRLRjE/matthew-s-levine.rss" finance)
("https://cvgmt.sns.it/papers/rss.xml" preprint)
("https://planet.emacslife.com/atom.xml" emacs)
("https://kbd.news/rss2.php" keyboard)
("https://thealexandrian.net/feed" dnd)
("http://blog.trilemma.com/feeds/posts/default" dnd)
("https://goblinpunch.blogspot.com/feeds/posts/default" dnd)
("https://sachachua.com/blog/feed/" emacs)
)))
(use-package elfeed
:config (my-elfeed-settings))
;; (use-package pdf-tools
;; :config (pdf-tools-install))
(defun wiki-search (search-term) (interactive "sSearch Wikipedia: ") (browse-url (concat "https://en.wikipedia.org/w/index.php?title=Special%3ASearch&search=" search-term)))
(defun init-mail-settings () ()
(setq
mu4e-get-mail-command "offlineimap -q -o"
mu4e-update-interval 30000))
(use-package mu4e
:load-path "/usr/share/emacs/site-lisp/mu4e"
:init (init-mail-settings))
(add-menu-item "m" 'mu4e)
(add-hook 'mu4e-compose-hook 'turn-off-autofill)