-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathinit.el
1313 lines (1192 loc) · 49.7 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
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
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
668
669
670
671
672
673
674
675
676
677
678
679
680
681
682
683
684
685
686
687
688
689
690
691
692
693
694
695
696
697
698
699
700
701
702
703
704
705
706
707
708
709
710
711
712
713
714
715
716
717
718
719
720
721
722
723
724
725
726
727
728
729
730
731
732
733
734
735
736
737
738
739
740
741
742
743
744
745
746
747
748
749
750
751
752
753
754
755
756
757
758
759
760
761
762
763
764
765
766
767
768
769
770
771
772
773
774
775
776
777
778
779
780
781
782
783
784
785
786
787
788
789
790
791
792
793
794
795
796
797
798
799
800
801
802
803
804
805
806
807
808
809
810
811
812
813
814
815
816
817
818
819
820
821
822
823
824
825
826
827
828
829
830
831
832
833
834
835
836
837
838
839
840
841
842
843
844
845
846
847
848
849
850
851
852
853
854
855
856
857
858
859
860
861
862
863
864
865
866
867
868
869
870
871
872
873
874
875
876
877
878
879
880
881
882
883
884
885
886
887
888
889
890
891
892
893
894
895
896
897
898
899
900
901
902
903
904
905
906
907
908
909
910
911
912
913
914
915
916
917
918
919
920
921
922
923
924
925
926
927
928
929
930
931
932
933
934
935
936
937
938
939
940
941
942
943
944
945
946
947
948
949
950
951
952
953
954
955
956
957
958
959
960
961
962
963
964
965
966
967
968
969
970
971
972
973
974
975
976
977
978
979
980
981
982
983
984
985
986
987
988
989
990
991
992
993
994
995
996
997
998
999
1000
;;; init.el --- Initializing Farlado's Illiterate GNU Emacs
;; This file is not part of GNU Emacs.
;; 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 this program. If not, see <https://www.gnu.org/licenses/>.
;;; Commentary:
;; This file has been automatically tangled from `literate-emacs.org'.
;; If you don't have a copy of that file, it is best not to use this file!
;; All relevant commentary is in `literate-emacs.org', not here.
;; There may not be any comments past this point.
;; Abandon all hope, ye who enter here.
;;; Code:
(unless (package-installed-p 'use-package)
(package-refresh-contents)
(package-install 'use-package))
(pdumper-require 'use-package)
(setq use-package-compute-statistics t)
(use-package async
:ensure t
:defer t
:init
(dired-async-mode 1)
(async-bytecomp-package-mode 1)
:custom (async-bytecomp-allowed-packages '(all)))
(use-package auto-package-update
:ensure t
:defer t
:custom ((auto-package-update-interval 2)
(auto-package-update-hide-results t)
(auto-package-update-delete-old-versions t))
:hook (after-init . auto-package-update-maybe))
(use-package try
:ensure t
:defer t)
(use-package dracula-theme
:if window-system
:ensure t
:defer t
:init
(if pdumper-dumped
(enable-theme 'dracula)
(load-theme 'dracula t))
(prefer-coding-system 'utf-8)
(setq locale-coding-system 'utf-8)
(set-language-environment "UTF-8")
(set-default-coding-systems 'utf-8)
(set-terminal-coding-system 'utf-8)
(set-keyboard-coding-system 'utf-8)
(set-selection-coding-system 'utf-8)
(when (member "Iosevka" (font-family-list))
(set-face-attribute 'default nil
:font "Iosevka"
:height 100))
(when (member "Noto Color Emoji" (font-family-list))
(set-fontset-font t 'symbol
(font-spec :family "Noto Color Emoji")
nil 'prepend))
(setq inhibit-compacting-font-caches t)
(set-face-background 'fringe (face-background 'default))
(fringe-mode 10)
(set-face-background 'line-number (face-background 'default))
(setq window-divider-default-right-width 3)
(let ((color (face-background 'mode-line)))
(dolist (face '(window-divider-first-pixel
window-divider-last-pixel
window-divider))
(set-face-foreground face color)))
(window-divider-mode 1)
(dolist (frame (frame-list))
(set-frame-parameter frame 'alpha 90))
(add-to-list 'default-frame-alist '(alpha . 90)))
(use-package mood-line
:ensure t
:defer t
:init
(mood-line-mode 1)
(line-number-mode 1)
(column-number-mode 1)
(display-time-mode 1)
(display-battery-mode 1)
:custom ((display-time-format "%a %m/%d %H:%M")
(display-time-day-and-date t)
(display-time-24hr-format t)))
(use-package dashboard
:ensure t
:defer t
:init
(defun dashboard-or-scratch ()
"Open either dashboard or the scratch buffer."
(or (get-buffer "*dashboard*")
(get-buffer "*scratch*")))
(defun dashboard-immortal ()
"Make the dashboard buffer immortal."
(emacs-lock-mode 'kill))
(dashboard-setup-startup-hook)
:custom ((inhibit-start-screen t)
(dashboard-set-footer nil)
(dashboard-startup-banner (locate-user-emacs-file "logo.png"))
(dashboard-items '((recents . 10)))
(initial-buffer-choice #'dashboard-or-scratch)
(dashboard-banner-logo-title
"Welcome to Farlado's Illiterate GNU Emacs!"))
:hook (dashboard-mode . dashboard-immortal))
(global-visual-line-mode 1)
(setq-default fill-column 80)
(add-hook 'text-mode-hook #'turn-on-auto-fill)
(tooltip-mode -1)
(setq use-dialog-box nil
use-file-dialog nil)
(setq-default cursor-type 'bar)
(use-package page-break-lines
:ensure t
:defer t
:hook (after-init . global-page-break-lines-mode))
(use-package display-line-numbers
:defer t
:custom ((indicate-empty-lines t)
(display-line-numbers-type 'relative))
:hook ((text-mode
prog-mode
conf-mode) . display-line-numbers-mode))
(use-package paren
:defer t
:init
(show-paren-mode 1)
:custom-face (show-paren-match ((t (:weight extra-bold
:underline t))))
:custom ((show-paren-style 'parentheses)
(show-paren-delay 0.00000001)))
(use-package rainbow-mode
:if window-system
:ensure t
:defer t
:hook (prog-mode . rainbow-mode))
(use-package rainbow-delimiters
:ensure t
:defer t
:hook (prog-mode . rainbow-delimiters-mode))
(pdumper-require 'server)
(unless (server-running-p)
(server-start))
(setq disabled-command-function nil)
(add-hook 'minibuffer-setup-hook #'garbage-collect-defer)
(add-hook 'minibuffer-exit-hook #'garbage-collect-restore)
(setq confirm-kill-emacs #'yes-or-no-p)
(setq scroll-margin 0
auto-window-vscroll nil
scroll-preserve-screen-position 1
scroll-conservatively most-positive-fixnum
mouse-wheel-scroll-amount '(1 ((shift) . 1))
mouse-wheel-progressive-speed nil
mouse-wheel-follow-mouse t)
(setq ring-bell-function 'ignore)
(defalias 'yes-or-no-p #'y-or-n-p
"Use `y-or-n-p' instead of a yes/no prompt.")
(use-package which-key
:ensure t
:defer t
:custom (echo-keystrokes 0.00000001)
:hook (after-init . which-key-mode))
(use-package company
:ensure t
:defer t
:custom ((company-idle-delay 0.75)
(company-minimum-prefix-length 3))
:hook (after-init . global-company-mode)
:bind (:map company-active-map
("M-n" . nil)
("M-p" . nil)
("C-n" . company-select-next)
("C-p" . company-select-previous)
("SPC" . company-abort)))
(use-package counsel
:ensure t
:defer t
:init
(ivy-mode 1)
(counsel-mode 1)
(setq ivy-initial-inputs-alist nil))
(use-package company-emoji
:after company
:ensure t
:defer t
:init
(add-to-list 'company-backends #'company-emoji))
(use-package ibuffer
:defer t
:init
(defun farl-ibuffer/use-default-filter-group ()
"Switch to the intended filter group."
(ibuffer-switch-to-saved-filter-groups "default"))
(with-current-buffer "*scratch*"
(emacs-lock-mode 'kill))
:custom ((ibuffer-saved-filter-groups
(quote (("default"
("exwm" (and (not (name . "Firefo[x<>1-9]+$"))
(or (name . "^\\*system-packages\\*$")
(name . "^\\*Wi-Fi Networks\\*$")
(name . "^\\*XELB-DEBUG\\*$")
(mode . exwm-mode))))
("firefox" (name . "Firefo[x<>1-9]+$"))
("emms" (or (mode . emms-playlist-mode)
(mode . emms-browser-mode)
(mode . emms-mode)))
("ebooks" (mode . nov-mode))
("magit" (name . "^magit.*:"))
("dired" (or (mode . dired-mode)
(mode . wdired-mode)))
("elisp" (mode . emacs-lisp-mode))
("haskell" (mode . haskell-mode))
("python" (mode . python-mode))
("org" (mode . org-mode))
("term" (mode . term-mode))
("emacs" (or (name . "^\\*package.*results\\*$")
(name . "^\\*Shell.*Output\\*$")
(name . "^\\*Compile-Log\\*$")
(name . "^\\*Completions\\*$")
(name . "^\\*Backtrace\\*$")
(name . "^\\*dashboard\\*$")
(name . "^\\*Messages\\*$")
(name . "^\\*scratch\\*$")
(name . "^\\*info\\*$")
(name . "^\\*Help\\*$")))))))
(uniquify-buffer-name-style 'forward)
(uniquify-after-kill-buffer-p t)
(initial-scratch-message ""))
:hook (ibuffer-mode . farl-ibuffer/use-default-filter-group)
:bind (("C-x b" . ibuffer)
("C-x C-b" . nil)
("C-x k" . kill-this-buffer)))
(use-package buffer-move
:ensure t
:defer t
:init
(defun split-and-follow-below ()
"Open a new window vertically."
(interactive)
(split-window-below)
(other-window 1)
(ibuffer))
(defun split-and-follow-right ()
"Open a new window horizontally."
(interactive)
(split-window-right)
(other-window 1)
(ibuffer))
(defun kill-this-buffer-and-window ()
"Perform `kill-buffer-and-window'. Altered to accomodate `exwm-mode'."
(interactive)
(let ((window-to-delete (selected-window))
(buffer-to-kill (current-buffer))
(delete-window-hook (lambda ()
(ignore-errors
(delete-window)))))
(unwind-protect
(progn
(add-hook 'kill-buffer-hook delete-window-hook t t)
(if (kill-buffer (current-buffer))
;; If `delete-window' failed before, we repeat
;; it to regenerate the error in the echo area.
(when (eq (selected-window) window-to-delete)
(delete-window)))))))
(defun kill-all-buffers-and-windows ()
"Kill all buffers and windows."
(interactive)
(when (yes-or-no-p "Really kill all buffers and windows? ")
(save-some-buffers)
(mapc 'kill-buffer (buffer-list))
(delete-other-windows)))
:custom ((focus-follows-mouse t)
(mouse-autoselect-window t))
:bind (("C-x o" . nil)
("C-x o w" . windmove-up)
("C-x o a" . windmove-left)
("C-x o s" . windmove-down)
("C-x o d" . windmove-right)
("C-x o C-w" . buf-move-up)
("C-x o C-a" . buf-move-left)
("C-x o C-s" . buf-move-down)
("C-x o C-d" . buf-move-right)
("C-x 2" . split-and-follow-below)
("C-x 3" . split-and-follow-right)
("C-c b" . balance-windows)
("C-x 4 0" . kill-this-buffer-and-window)
("C-x 4 q" . kill-all-buffers-and-windows)))
(global-set-key (kbd "C-c d") #'cd)
(defun config-visit ()
"Open the configuration file."
(interactive)
(find-file (locate-user-emacs-file "literate-emacs.org")))
(global-set-key (kbd "C-c e") #'config-visit)
(defun literate-dotfiles-visit ()
"Open the literate dotfiles."
(interactive)
(find-file "~/.config/dotfiles/literate-dotfiles.org"))
(when (file-exists-p "~/.config/dotfiles/literate-dotfiles.org")
(global-set-key (kbd "C-c M-e") #'literate-dotfiles-visit))
(defun sys-config-visit ()
"Open the literate system configuration."
(interactive)
(find-file "~/.config/dotfiles/literate-sysconfig.org"))
(when (file-exists-p "~/.config/dotfiles/literate-sysconfig.org")
(global-set-key (kbd "C-c C-M-e") #'sys-config-visit))
(use-package sudo-edit
:ensure t
:defer t
:bind ("C-x C-M-f" . sudo-edit))
(global-unset-key (kbd "C-x C-z"))
(global-unset-key (kbd "C-z"))
(use-package markdown-mode
:ensure t
:defer t
:mode ("\\.md\\'" . markdown-mode))
(use-package graphviz-dot-mode
:ensure t
:defer t
:mode ("\\.dot\\'" . graphviz-dot-mode))
(defun tangle-literate-program ()
"Tangle a file if it's a literate programming file."
(interactive)
(when (string-match-p "literate.*.org$" buffer-file-name)
(org-babel-tangle)))
(add-hook 'after-save-hook #'tangle-literate-program -100)
(defun byte-compile-config-files ()
"Byte-compile Emacs configuration files."
(when (string-match-p "literate-emacs.org" (buffer-file-name))
(byte-recompile-directory user-emacs-directory 0)))
(add-hook 'after-save-hook #'byte-compile-config-files 100)
(global-set-key (kbd "C-=") #'count-words)
(use-package flyspell
:if (executable-find "aspell")
:defer t
:custom ((ispell-program-name "aspell")
(ispell-dictionary "american"))
:hook ((flyspell-mode . flyspell-buffer)
((prog-mode
conf-mode) . flyspell-prog-mode)
(text-mode . flyspell-mode)))
(use-package swiper
:ensure t
:defer t
:bind ("C-s" . swiper))
(setq backup-inhibited t
make-backup-files nil
auto-save-default nil
auto-save-list-file-prefix nil)
(use-package autorevert
:defer t
:init
(global-auto-revert-mode 1)
:custom ((global-auto-revert-non-file-buffers t)
(auto-revert-remote-files t)
(auto-revert-verbose nil)))
(setq require-final-newline t)
(setq-default indent-tabs-mode nil
tab-width 4)
(use-package popup-kill-ring
:ensure t
:defer t
:custom ((save-interprogram-paste-before-kill t)
(mouse-drag-copy-region t)
(mouse-yank-at-point t))
:bind ("M-y" . popup-kill-ring))
(delete-selection-mode 1)
(use-package hungry-delete
:ensure t
:defer t
:init
(global-hungry-delete-mode 1))
(use-package avy
:ensure t
:defer t
:bind ("M-s" . avy-goto-char))
(global-subword-mode 1)
(use-package elec-pair
:defer t
:init
(electric-pair-mode 1)
(minibuffer-electric-default-mode 1)
:custom (electric-pair-pairs '((?\{ . ?\})
(?\( . ?\))
(?\[ . ?\])
(?\" . ?\"))))
(use-package magit
:ensure t
:defer t
:bind ("C-x g" . magit-status))
(use-package haskell-mode
:ensure t
:defer t
:custom (haskell-stylish-on-save t)
:hook ((haskell-mode . interactive-haskell-mode)
(haskell-mode . haskell-doc-mode)
(haskell-mode . haskell-indentation-mode)
(haskell-mode . haskell-auto-insert-module-template)))
(use-package lisp-mode
:defer t
:custom (inferior-lisp-program "sbcl"))
(use-package company-jedi
:after company
:ensure t
:defer t
:init
(add-to-list 'company-backends 'company-jedi))
(use-package flycheck
:ensure t
:defer t
:hook (prog-mode . flycheck-mode))
(use-package flycheck-package
:after flycheck
:ensure t
:defer t
:init
(flycheck-package-setup))
(use-package flycheck-posframe
:if window-system
:after flycheck
:ensure t
:defer t
:custom ((posframe-mouse-banish nil)
(flycheck-posframe-position 'window-bottom-left-corner))
:hook ((flycheck-mode . flycheck-posframe-mode)
(flycheck-posframe-mode . flycheck-posframe-configure-pretty-defaults)))
(use-package avy-flycheck
:after flycheck
:ensure t
:defer t
:bind (:map prog-mode-map
("C-c C-'" . avy-flycheck-goto-error)))
(use-package org
:defer t
:init
(pdumper-require 'org)
(set-face-attribute 'org-document-title nil
:weight 'extra-bold
:height 1.8)
(set-face-attribute 'org-level-1 nil
:height 1.3)
(set-face-attribute 'org-level-2 nil
:height 1.1)
(set-face-attribute 'org-level-3 nil
:height 1.0)
(set-face-attribute 'org-code nil
:inherit 'font-lock-string-face)
(use-package toc-org
:ensure t
:defer t
:hook ((org-mode . toc-org-mode)
(markdown-mode . toc-org-mode)))
(use-package org-bullets
:if window-system
:ensure t
:defer t
:hook (org-mode . org-bullets-mode))
(use-package epresent
:if window-system
:ensure t
:defer t
:bind (:map org-mode-map
("C-c r" . epresent-run)))
(org-babel-do-load-languages 'org-babel-load-languages '((dot . t)))
(defun farl-org/confirm-babel-evaluate (lang body)
"Don't ask to evaluate graphviz blocks or literate programming blocks."
(not (or (string= lang "dot")
(string-match-p "literate.*.org$" buffer-file-name))))
(use-package org-tempo
:defer t
:init
(add-to-list 'org-modules 'org-tempo)
:custom ((org-structure-template-alist '(;; General blocks
("c" . "center")
("C" . "comment")
("e" . "example")
("q" . "quote")
("v" . "verse")
;; Export blocks
("a" . "export ascii")
("h" . "export html")
("css" . "export css")
("l" . "export latex")
;; Code blocks
("s" . "src")
("sh" . "src sh")
("cf" . "src conf")
("cu" . "src conf-unix")
("cs" . "src conf-space")
("cx" . "src conf-xdefaults")
("cjp" . "src conf-javaprop")
("el" . "src emacs-lisp")
("py" . "src python")
("dot" . "src dot :file")
("txt" . "src text :tangle")))
(org-tempo-keywords-alist '(;; Title/subtitle/author
("t" . "title")
("st" . "subtitle")
("au" . "author")
;; Language
("la" . "language")
;; Name/caption
("n" . "name")
("ca" . "caption")
;; Property/options/startup
("p" . "property")
("o" . "options")
("su" . "startup")
;; Other
("L" . "latex")
("H" . "html")
("A" . "ascii")
("i" . "index")))))
(defun farl-org/disable-angle-bracket-syntax ()
"Disable angle bracket syntax."
(modify-syntax-entry ?< ".")
(modify-syntax-entry ?> "."))
(defun open-agenda-file ()
"Open the agenda file."
(interactive)
(find-file (ivy-read
"Open agenda: "
(all-completions "" org-agenda-files))))
:custom ((org-pretty-entities t)
(org-src-fontify-natively t)
(org-agenda-use-time-grid nil)
(org-fontify-done-headline t)
(org-src-tab-acts-natively t)
(org-enforce-todo-dependencies t)
(org-fontify-whole-heading-line t)
(org-agenda-skip-deadline-if-done t)
(org-agenda-skip-scheduled-if-done t)
(org-fontify-quote-and-verse-blocks t)
(org-src-window-setup 'current-window)
(org-highlight-latex-and-related '(latex))
(org-ellipsis (if window-system "⤵" "..."))
(org-hide-emphasis-markers window-system)
(org-confirm-babel-evaluate #'farl-org/confirm-babel-evaluate))
:hook ((org-mode . farl-org/disable-angle-bracket-syntax)
(org-babel-after-execute . org-redisplay-inline-images))
:bind (("C-c s-a" . open-agenda-file)
("C-c M-a" . org-agenda)))
(setq calendar-week-start-day 1)
(global-set-key (kbd "C-c l") #'calendar)
(use-package nov
:ensure t
:defer t
:custom (nov-text-width 80)
:mode ("\\.epub\\'" . nov-mode))
(use-package wdired
:defer t
:custom ((dired-listing-switches "-alh --group-directories-first")
(wdired-allow-to-change-permissions t)))
(use-package term
:defer t
:init
(defun farl-term/use-shell (force-bash)
"Force `term' to use the default shell, ignoring FORCE-BASH."
(interactive (list (getenv "SHELL"))))
(advice-add 'ansi-term :before #'farl-term/use-shell)
:bind ("C-c t" . ansi-term))
(global-set-key (kbd "C-h 4 m") #'man)
(global-set-key (kbd "C-h 4 w") #'woman)
(use-package wttrin
:ensure t
:defer t
:custom (wttrin-default-cities '("Indianapolis"))
:bind ("C-c w" . wttrin))
(use-package system-packages
:ensure t
:defer t
:init
(when (executable-find "yay")
(pdumper-require 'system-packages)
(add-to-list 'system-packages-supported-package-managers
'(yay .
((default-sudo . nil)
(install . "yay -S")
(search . "yay -Ss")
(uninstall . "yay -Rs")
(update . "yay -Syu")
(clean-cache . "yay -Sc")
(log . "car /var/log/pacman.log")
(get-info . "yay -Qi")
(get-info-remote . "yay -Si")
(list-files-provided-by . "yay -Ql")
(verify-all-packages . "yay -Qkk")
(verify-all-dependencies . "yay -Dk")
(remove-orphaned . "yay -Rns $(yay -Qtdq)")
(list-installed-packages . "yay -Qe")
(list-installed-packages-all . "yay -Q")
(list-dependencies-of . "yay -Qi")
(noconfirm . "--noconfirm"))))
(setq system-packages-use-sudo nil
system-packages-package-manager 'yay))
:custom (system-packages-noconfirm t)
:bind (("C-c p i" . system-packages-install)
("C-c p e" . system-packages-ensure)
("C-c p u" . system-packages-update)
("C-c p r" . system-packages-uninstall)
("C-c p o" . system-packages-remove-orphaned)
("C-c p c" . system-packages-clean-cache)
("C-c p l" . system-packages-log)
("C-c p s" . system-packages-search)
("C-c p g" . system-packages-get-info)
("C-c p d" . system-packages-list-dependencies-of)
("C-c p f" . system-packages-list-files-provided-by)
("C-c p p" . system-packages-list-installed-packages)
("C-c p f" . system-packages-verify-all-dependencies)
("C-c p v" . system-packages-verify-all-packages)))
(use-package emms
:if (executable-find "mpd")
:ensure t
:defer t
:init
(pdumper-require 'emms-setup)
(require 'emms-player-mpd)
(emms-all)
(defun mpd/start-music-daemon ()
"Start MPD, connect to it and sync the metadata cache"
(interactive)
(shell-command "mpd")
(mpd/update-database)
(emms-player-mpd-connect)
(emms-cache-set-from-mpd-all)
(message "MPD started!"))
(defun mpd/kill-music-daemon ()
"Stop playback and kill the music daemon."
(interactive)
(emms-stop)
(call-process "killall" nil nil nil "mpd")
(message "MPD killed!"))
(defun mpd/update-database ()
"Update the MPD database synchronously."
(interactive)
(call-process "mpc" nil nil nil "update")
(message "MPD database updated!"))
(defun farl-emms/shuffle-with-message ()
"Shuffle the playlist and say so in the echo area."
(interactive)
(emms-shuffle)
(message "Playlist has been shuffled."))
(setenv "MPD_HOST" "localhost")
(setenv "MPD_PORT" "6601")
:custom ((emms-seek-seconds 5)
(emms-player-list '(emms-player-mpd))
(emms-info-functions '(emms-info mpd))
(emms-completing-read #'ivy-completing-read)
(emms-player-mpd-server-name "localhost")
(emms-player-mpd-server-port "6601"))
:bind (;; Opening playlist and music browser
("C-c a v" . emms)
("C-c a b" . emms-smart-browse)
;; Track navigation
("C-c a C-n" . emms-next)
("C-c a C-p" . emms-previous)
("C-c a p" . emms-pause)
("C-c a C-s" . emms-stop)
;; Repeat/shuffle
("C-c a C-r" . emms-toggle-repeat-track)
("C-c a r" . emms-toggle-repeat-playlist)
("C-c a s" . farl-emms/shuffle-with-message)
;; Refreshing the emms cache
("C-c a c" . emms-player-mpd-update-all-reset-cache)
;; mpd related functions
("C-c a d" . mpd/start-music-daemon)
("C-c a q" . mpd/kill-music-daemon)
("C-c a u" . mpd/update-database)))
(global-unset-key (kbd "C-c g"))
(use-package yahtzee
:ensure t
:defer t
:bind ("C-c g y" . yahtzee))
(use-package sudoku
:ensure t
:defer t
:bind ("C-c g s" . sudoku))
(use-package tetris
:defer t
:bind (("C-c g t" . 'tetris)
:map tetris-mode-map
("w" . tetris-move-bottom)
("a" . tetris-move-left)
("s" . tetris-mode-down)
("d" . tetris-move-right)
([left] . tetris-rotate-next)
([right] . tetris-rotate-prev)
([?\t] . tetris-pause-game)
("r" . tetris-start-game)
("e" . tetris-end-game)))
(use-package chess
:ensure t
:defer t
:bind ("C-c g c" . chess))
(use-package 2048-game
:ensure t
:defer t
:bind ("C-c g 2" . 2048-game))
(use-package exwm
:if (getenv "_RUN_EXWM")
:ensure t
:defer t
:init
(setenv "_RUN_EXWM")
(pdumper-require 'exwm)
(pdumper-require 'exwm-xim)
(pdumper-require 'exwm-randr)
(pdumper-require 'exwm-config)
(pdumper-require 'exwm-systemtray)
(defun farl-exwm/name-buffer-after-window-title ()
"Rename the current `exwm-mode' buffer after the X window's title."
(exwm-workspace-rename-buffer exwm-title))
(setq exwm-floating-border-width window-divider-default-right-width
exwm-floating-border-color (face-background 'mode-line))
(defvar farl-exwm/workspace-names '("" "" "" "" ""
"" "" "" "" "")
"The names assigned to workspaces through `exwm-workspace-index-map'.")
(defun farl-exwm/workspace-index-map (index)
"Return either a workspace name for a given INDEX or INDEX itself."
(or (elt farl-exwm/workspace-names index) index))
(use-package minibuffer-line
:ensure t
:defer t
:init
(defun farl-exwm/list-workspaces ()
"List EXWM workspaces."
(exwm-workspace--update-switch-history)
(elt exwm-workspace--switch-history
(exwm-workspace--position exwm-workspace--current)))
:custom-face (minibuffer-line ((t (:inherit default))))
:custom (minibuffer-line-format '((:eval (farl-exwm/list-workspaces))))
:hook ((exwm-init . minibuffer-line-mode)
(exwm-workspace-switch . minibuffer-line--update)))
(defun farl-exwm/workspace-next ()
"Move forward one workspace."
(interactive)
(if (< exwm-workspace-current-index (1- exwm-workspace-number))
(exwm-workspace-switch (1+ exwm-workspace-current-index))
(message "No next workspace.")))
(defun farl-exwm/workspace-prev ()
"Move to the previous workspace."
(interactive)
(if (> exwm-workspace-current-index 0)
(exwm-workspace-switch (1- exwm-workspace-current-index))
(message "No previous workspace.")))
(defun get-connected-monitors ()
"Return a list of the currently connected monitors."
(split-string
(shell-command-to-string
"xrandr | grep ' connected ' | awk '{print $1}'")))
(defun display-setup-x230 ()
"Set up the connected monitors on a ThinkPad X230."
(let ((monitors (get-connected-monitors))
(possible '("LVDS1"
"VGA1")))
(dolist (monitor possible)
(if (member monitor monitors)
(start-process "xrandr" nil "xrandr"
"--output" monitor
"--mode" "1366x768"
"--pos" "0x0")
(start-process "xrandr" nil "xrandr"
"--output" monitor
"--off")))))
(defun display-setup-w541 ()
"Set up the connected monitors on a ThinkPad W541."
(let* ((connected-monitors (get-connected-monitors))
(docked-p (member "DP2-1" connected-monitors))
(possible-monitors '("eDP1"
"VGA1"
"DP2-1"
"DP2-2"
"DP2-3")))
(dolist (monitor possible-monitors)
(if (and (member monitor connected-monitors)
(not (and docked-p (string= "eDP1" monitor))))
(progn
(start-process "xrandr" nil "xrandr"
"--output" monitor
;; Any enabled monitor needs a resolution.
"--mode" "1920x1080"
;; DP2-1 and DP2-3 are rotated.
"--rotate" (if (string= "DP2-2" monitor)
"left"
(if (string= "DP2-3" monitor)
"right"
"normal"))
;; Every enabled monitor needs a position.
"--pos" (if (string-match-p "DP2-3" monitor)
"3000x0"
(if (string-match-p "DP2-1" monitor)
"1080x0"
"0x0")))
;; Setting a monitor as primary occurs outside enabling it.
;; This is due to how `start-process' takes arguments.
(when (or (string= "DP2-1" monitor)
(string= "eDP1" monitor))
(start-process "xrandr" nil "xrandr"
"--output" monitor
"--primary")))
(start-process "xrandr" nil "xrandr"
"--output" monitor
"--off")))))
(defun peripheral-setup ()
"Configure peripherals I connect to my dock."
(interactive)
;; Trackball
(let ((trackball-id (shell-command-to-string
(concat "xinput | grep ELECOM | head -n 1 "
"| sed -r 's/.*id=([0-9]+).*/\\1/' | "
"tr '\\n' ' '"))))
(start-process-shell-command
"Trackball Setup" nil (concat "xinput set-prop " trackball-id
"'libinput Button Scrolling Button' "
"10"))
(start-process-shell-command
"Trackball Setup" nil (concat "xinput set-prop " trackball-id
"'libinput Scroll Method Enabled' "
"0 0 1"))
(start-process-shell-command
"Trackball Setup" nil (concat "xinput set-button-map " trackball-id
"1 2 3 4 5 6 7 8 9 2 1 2")))
;; Keyboard
(start-process "Keyboard Setup" nil "setxkbmap"
"-option" "ctrl:nocaps"))
(defun display-and-dock-setup ()
"Configure displays and dock if applicable."
(interactive)
(unless (get-process "Monitor Settings")
(if (member "LVDS1" (get-connected-monitors))
(display-setup-x230)
(progn
(display-setup-w541)
(peripheral-setup)))))
(defun run-gimp ()
"Start GIMP."
(interactive)
(start-process "GIMP" nil "gimp"))
(defun run-steam ()
"Start Steam."
(interactive)
(start-process "Steam" nil "steam"))
(defun run-firefox ()
"Start Firefox."
(interactive)
(start-process "Firefox" nil "firefox"))
(defun run-discord ()
"Start Discord."
(interactive)
(start-process "Discord" nil "discord"))
(defun run-telegram ()
"Start Telegram."
(interactive)
(start-process "Telegram" nil "telegram-desktop"))
(defun run-musescore ()
"Start MuseScore."
(interactive)
(start-process "MuseScore" nil "musescore"))
(defun run-libreoffice ()
"Start LibreOffice."
(interactive)
(start-process "LibreOffice" nil "libreoffice"))
(defun run-transmission ()
"Start Transmission."
(interactive)
(start-process "Transmission" nil "transmission-gtk"))
(use-package desktop-environment
:ensure t
:defer t
:init
(defun farl-de/screenshot ()
"Take a screenshot and store it in a file."
(interactive)
(desktop-environment-screenshot)
(message "Screenshot saved in ~/screenshots."))
(defun farl-de/screenshot-part ()
"Take a capture of a portion of the screen and store it in a file."
(interactive)
(desktop-environment-screenshot-part)
(message "Screenshot saved in ~/screenshots."))
(defun farl-de/screenshot-clip ()
"Take a screenshot and put it in the clipboard."
(interactive)
(shell-command
(concat desktop-environment-screenshot-command
" && xclip $FILENAME -selection clipboard "
"-t image/png &> /dev/null && rm $FILENAME"))
(message "Screenshot copied to clipboard."))
(defun farl-de/screenshot-part-clip ()
"Take a shot of a portion of the screen and put it in the clipboard."