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
1001
1002
1003
1004
|
;;; -*- lexical-binding: t; -*-
;;; init.el
;;
;; Main configuration file for MMOSMacs.
;; ---------------------------------------------------------------------
;;; Package & Configuration Management
;; -----------------------------------
;; MMOSMacs uses `straight.el' for package management and `use-package'
;; for configuration management to make things more consistent.
;; ---------------------------------------------------------------------
;; ---------------------------------
;; Bootstrap `straight.el'
;; -----------------------
;; This is some pre-written magic
;; provided by `straight.el'. Dont
;; ask me what it does.
;; ---------------------------------
(defvar bootstrap-version)
(let ((bootstrap-file
(expand-file-name "straight/repos/straight.el/bootstrap.el" user-emacs-directory))
(bootstrap-version 6))
(unless (file-exists-p bootstrap-file)
(with-current-buffer
(url-retrieve-synchronously
"https://raw.githubusercontent.com/radian-software/straight.el/develop/install.el"
'silent 'inhibit-cookies)
(goto-char (point-max))
(eval-print-last-sexp)))
(load bootstrap-file nil 'nomessage))
;; ---------------------------------
;; `use-package'
;; -------------
;; This makes sure `use-package' is
;; installed and loaded.
;; ---------------------------------
(straight-use-package 'use-package)
;; ---------------------------------
;; Don't load outdated code
;; ------------------------
;; MMOSMacs is under highly active
;; development and undergoes
;; freuqent changes. The newest code
;; should always be loaded
;; ---------------------------------
;; if a `.el' file is newer than its corresponding `.elc', load the `.el'
(setq load-prefer-newer t)
;; ---------------------------------------------------------------------
;; Performance hacks
;; -----------------
;; These hacks subjectively make Emacs perform "better"
;; ---------------------------------------------------------------------
;; ---------------------------------
;; GCMH
;; ----
;; Garbage Collector Magic Hack
;; ---------------------------------
(use-package gcmh
:straight t
:defer t
:init
(setq gcmh-idle-delay 15
gcmh-idle-delay-factor 10
gcmh-high-cons-threshold (* 16 (* 1024 1024))) ;16mb
:hook (after-init-hook . gcmh-mode))
;; ---------------------------------
;; Async
;; -----
;; Asynchronous processing of things
;; ---------------------------------
;; Async package
(use-package async
:straight t
:config
(setq async-bytecomp-package-mode t))
;; ---------------------------------------------------------------------
;;; Graphical Environment
;; ----------------------
;; MMOSMacs is intended to be my entire Desktop Environment.
;; ---------------------------------------------------------------------
;; ---------------------------------
;; Disable superfluous UI elements
;; -------------------------------
;; These UI elements are not useful
;; for the system I am trying to
;; make MMOSMacs into.
;;
;; Some of these were disabled in
;; Early Init, but for completion's
;; sake I disable them here as well.
;; ---------------------------------
(scroll-bar-mode -1)
(tool-bar-mode -1)
(tooltip-mode -1)
(menu-bar-mode -1)
(set-fringe-mode 5)
(setq ring-bell-function 'ignore)
(setq use-dialog-box nil
inhibit-startup-message t
initial-scratch-message "")
;; ---------------------------------
;; Emacs X Window Manager (EXWM)
;; -----------------------------
;; EXWM is a fully-featured
;; X Window Manager.
;; ---------------------------------
(use-package exwm
:straight t
:config
(require 'exwm-config)
(setq exwm-workspace-number 1)
(exwm-enable))
;; ---------------------------------
;; Temporary theme
;; ---------------
;; MMOSMacs has a planned custom
;; theme, but for now I'll use a
;; temporary theme so I can bear to
;; look at Emacs.
;; ---------------------------------
(use-package jazz-theme
:straight t)
(load-theme 'jazz t)
(set-background-color "black")
;; ---------------------------------
;; Fonts
;; -----
;; For now I use Iosevka and Exo
;; ---------------------------------
(set-face-attribute 'default nil :font "JetBrains Mono" :height 100)
(set-face-attribute 'fixed-pitch nil :font "JetBrains Mono" :height 100)
(set-face-attribute 'variable-pitch nil :font "Noto Sans" :height 110 :weight 'regular)
;; ---------------------------------
;; Icons
;; -----
;; Icons make it easy to recongnize
;; things with memorable logos.
;; ---------------------------------
;; All the icons
(use-package all-the-icons
:straight t)
;; Add icons to dired buffers
(use-package all-the-icons-dired
:straight t
:hook (dired-mode . all-the-icons-dired-mode))
;; Add icons to completion candidates
(use-package all-the-icons-completion
:straight t)
(add-hook 'marginalia-mode-hook #'all-the-icons-completion-marginalia-setup)
;; Add icons to ivy menus
(use-package all-the-icons-ivy
:straight t
:init (add-hook 'after-init-hook 'all-the-icons-ivy-setup))
;; ---------------------------------------------------------------------
;;; Completion
;; -----------
;; Completion refers to the suggestions you get when you type a few
;; characters in almost any modern IDE. MMOSMacs attempts to have
;; completion in as many places as possible.
;; ---------------------------------------------------------------------
;; ---------------------------------
;; Minibuffer completion
;; ---------------------
;; Vertico provides minibuffer when
;; typing commands and stuff like
;; that.
;; ---------------------------------
(use-package vertico
:straight t
:config
(setq vertico-count 5
vertico-cycle nil)
(vertico-mode))
;; ---------------------------------
;; Text completion
;; ---------------
;; Corfu provides in-buffer text
;; completion, and is the
;; counterpart to vertico.
;; ---------------------------------
(use-package corfu
:straight (corfu :files (:defaults "extensions/*")
:includes (corfu-info corfu-history))
:config
(setq corfu-auto t
corfu-auto-prefix 2
corfu-auto-delay 0.1
corfu-min-width 40
corfu-max-width corfu-min-width
corfu-count 8
corfu-scroll-margin 3
corfu-cycle nil
corfu-popupinfo-delay 0.15
corfu-quit-at-boundary t
corfu-separator ?\s
corfu-quit-no-match 'separator)
:init
(global-corfu-mode)
(corfu-popupinfo-mode)
(corfu-indexed-mode))
;; ---------------------------------
;; Minibuffer hints
;; ----------------
;; Add descriptions and keybind
;; hints to minibuffer completions.
;; ---------------------------------
(use-package marginalia
:straight t
:config
(setq marginalia-field-width 120)
:bind ("M-a" . marginalia-cycle)
:init (marginalia-mode))
;; ---------------------------------
;; Orderless completion
;; --------------------
;; A different ordering method for
;; completion suggestions
;; ---------------------------------
(use-package orderless
:straight t
:config
(setq completion-styles '(orderless)
completion-category-defaults nil
completion-category-overrides '((file (styles partial-completion)))))
;; ---------------------------------------------------------------------
;;; Text Editor
;; ------------
;; These tweaks are meant to make the text editor more convenient.
;; ---------------------------------------------------------------------
;; ---------------------------------
;; Line and column numbers
;; -----------------------
;; It helps to know where you are
;; ---------------------------------
;; Display line/column numbers
(column-number-mode)
(global-display-line-numbers-mode t)
;; Disable line numbers in specific modes
(dolist (mode '(org-mode-hook
org-agenda-mode-hook
helpful-mode-hook))
(add-hook mode (lambda () (display-line-numbers-mode 0))))
;; ---------------------------------
;; Highlight stuff
;; ---------------
;; Sometimes it's hard to find
;; things. Highlighting makes it a
;; little easier.
;; ---------------------------------
;; Highlight current line
(when window-system (add-hook 'prog-mode-hook 'hl-line-mode))
;; ---------------------------------
;; Scrolling
;; ---------
;; This makes the scrolling behavior
;; smoother and easier to follow.
;; ---------------------------------
;; Small scroll margin makes it
;; easier to see when to stop when
;; scrolling fast.
(setq scroll-margin 2)
;; Make mouse scroll smoother
(setq mouse-wheel-scroll-amount '(2)
mouse-wheel-progressive-speed nil
mouse-wheel-follow-mouse t)
;; Prevent jumpy scrolling
(setq scroll-conservatively 10
auto-window-vscroll nil
scroll-preserve-screen-position t)
;; Move point to beginning/end of
;; buffer if attempting to scroll
;; when already at the beginning/end
;; of buffer
(setq scroll-error-top-bottom t)
;; ---------------------------------
;; Whitespace
;; ----------
;; Spaces, tabs, indentation,
;; newlines, and text-wrapping.
;; ---------------------------------
;; Show stray whitespace
(setq-default show-trailing-whitespace t
indicate-empty-lines t
indicate-buffer-boundaries 'left)
;; Make files end with newline
(setq-default require-final-newline t)
;; Sentences end with ONE space
(setq-default sentence-end-double-space nil)
;; Use spaces for indentation
(setq-default indent-tabs-mode nil
tab-width 2)
;; Wrap words at buffer edge
(global-visual-line-mode)
;; ---------------------------------
;; Delimiters
;; ----------
;; Parentheses, brackets, and other
;; open-close type things
;; ---------------------------------
;; Auto-close delimiters
(electric-pair-mode)
;; ---------------------------------
;; Selection
;; -----------------------
;; Efficient selection is one of the
;; 47 totems of efficiency.
;; ---------------------------------
;; Typing over selected text deletes
;; the selected text
(delete-selection-mode t)
;; Expand region by semantic units
(use-package expand-region
:straight t
:config
(setq expand-region-subword-enabled t)
:bind ("M-=" . er/expand-region))
;; ---------------------------------------------------------------------
;;; File, project, & repository management
;; ---------------------------------------
;; This section contains everything to do with file, project, & repo
;; management. This includes `magit' and `projectile'.
;; ---------------------------------------------------------------------
;; ---------------------------------
;; Disable backups
;; ---------------
;; By default, Emacs saves backup
;; files, adding a `~' to the name.
;; Stop saving them.
;; ---------------------------------
(setq backup-inhibited t)
;; ---------------------------------
;; Disable auto-saves
;; ------------------
;; Auto-saves are the files with
;; hashes before and after the name.
;; They should not exist.
;; ---------------------------------
(setq auto-save-default nil ; don't create auto-saves
auto-save-list-file-prefix nil) ; don't create auto-save-list dir
;; ---------------------------------
;; Disable lockfiles
;; -----------------
;; Sometimes I want to edit a locked
;; file. I can handle myself, let me
;; do what I want.
;; ---------------------------------
(setq create-lockfiles nil)
;; --------------------------------
;; Auto-reload changed files
;; -------------------------
;; When files are changed on disk
;; externally, emacs should reload
;; those files.
;; ---------------------------------
(global-auto-revert-mode t)
;; ---------------------------------
;; Project management
;; ------------------
;; `Projectile' provides features
;; for operating on a project level.
;; ---------------------------------
(use-package projectile
:straight t
:config
(add-hook 'after-init-hook 'projectile-global-mode)
(setq projectile-project-search-path '("~/Projects")
projectile-known-projects-file "~/.emacs.d/projectile-known-projects.eld"
projectile-cache-file "~/.emacs.d/projectile.cache")
:bind-keymap ("C-c p" . projectile-command-map))
;; ---------------------------------
;; `Magit' - A git porcelain
;; -------------------------
;; Magit provides a state-of-the-art
;; interface for managing `git'
;; repositories.
;; ---------------------------------
(use-package magit
:straight t
:custom
(magit-display-buffer-function #'magit-display-buffer-same-window-except-diff-v1)
:config
(setq magit-diff-refine-hunk t
magit-diff-paint-whitespace t
magit-diff-paint-whitespace-lines t
magit-diff-highlight-trailing t))
;; ---------------------------------
;; Highlight diff in fringe
;; ------------------------
;; In buffers for git-controlled
;; files, highlight changed lines in
;; the fringe.
;; ---------------------------------
(use-package diff-hl
:straight t
:hook
(prog-mode . diff-hl-mode)
(diff-hl-mode . diff-hl-flydiff-mode))
;; ---------------------------------------------------------------------
;;; Personal Knowledge Management System (PKMS)
;; --------------------------------------------
;; Using `org', `org-roam', and a note-hierarchy I've developed over
;; several years of trial-and-error, I keep all my notes in a logical
;; organized collection. I feel this knowledgebase system can handle
;; almost any bit of information I can throw at it, and it is flexible
;; enough to adapt when I find new things it can't handle.
;; ---------------------------------------------------------------------
;; ---------------------------------
;; `org'
;; -----
;; `org' is a versatile format for
;; note-taking and other stuff. It
;; is the core of my PKMS system.
;; ---------------------------------
;; Setup run every time a buffer
;; is opened.
(defun mm/org-mode-setup ()
(org-indent-mode)
(visual-line-mode)
(variable-pitch-mode))
;; Org font stuff
(defun mm/org-font-setup ()
;; Replace hyphens in lists with dots
(font-lock-add-keywords 'org-mode
'(("^ *\\([-]\\) "
(0 (prog1 () (compose-region (match-beginning 1) (match-end 1) "•"))))))
;; Set font sizes
(dolist (face '((org-level-1 . 1.1)
(org-level-2 . 1.1)
(org-level-3 . 1.1)
(org-level-4 . 1.1)
(org-level-5 . 1.1)
(org-level-6 . 1.1)
(org-level-7 . 1.1)
(org-level-8 . 1.1)))
(set-face-attribute (car face) nil
:font "Noto Sans"
:weight 'regular
:height (cdr face))
;; Ensure anything that should be
;; fixed-pitch actually is.
(set-face-attribute 'org-block nil :foreground nil :inherit 'fixed-pitch)
(set-face-attribute 'org-table nil :inherit 'fixed-pitch)
(set-face-attribute 'org-formula nil :inherit 'fixed-pitch)
(set-face-attribute 'org-code nil :inherit '(shadow fixed-pitch))
(set-face-attribute 'org-table nil :inherit '(shadow fixed-pitch))
(set-face-attribute 'org-verbatim nil :inherit '(shadow fixed-pitch))
(set-face-attribute 'org-special-keyword nil :inherit '(font-lock-comment-face fixed-pitch))
(set-face-attribute 'org-meta-line nil :inherit '(font-lock-comment-face fixed-pitch))
(set-face-attribute 'org-checkbox nil :inherit 'fixed-pitch)
(set-face-attribute 'org-time-grid nil :inherit 'fixed-pitch)
(set-face-attribute 'org-scheduled nil :inherit 'fixed-pitch)
(set-face-attribute 'org-agenda-structure nil :inherit 'fixed-pitch)
(set-face-attribute 'org-agenda-date nil :inherit 'fixed-pitch)
(set-face-attribute 'org-agenda-date-today nil :inherit 'fixed-pitch)
(set-face-attribute 'org-agenda-current-time nil :inherit 'fixed-pitch)
(set-face-attribute 'org-agenda-calendar-event nil :inherit 'fixed-pitch)))
;; `org' configuration
(use-package org
:straight t
:hook (org-mode . mm/org-mode-setup)
:config
(mm/org-font-setup)
(setq org-startup-folded t
org-ellipsis " ►"
org-hide-leading-stars t
org-adapt-indentation t
org-support-shift-select 'always
org-return-follows-link t)
(advice-add 'org-refile :after 'org-save-all-org-buffers)
:bind
("C-c t l" . org-toggle-link-display))
;; Make org heading bullets look nicer
(use-package org-bullets
:straight t
:hook (org-mode . org-bullets-mode)
:custom
(org-bullets-bullet-list '("•")))
;; Auto-show emphasis markers on hover
(use-package org-appear
:straight t
:hook (org-mode . org-appear-mode)
:config
(setq org-hide-emphasis-markers t
org-appear-autolinks t
org-appear-autosubmarkers t))
;; Show link hints to make following links easier
(use-package link-hint
:straight t
:bind
("C-c n l o" . link-hint-open-link))
;; ---------------------------------
;; `org-roam'
;; ----------
;; Org roam adds a ton of PKMS
;; functionality to org.
;; ---------------------------------
;; Define function to insert a link to a node without opening it
(defun mm/org-roam-node-insert-immediate (arg &rest args)
"This version of `org-roam-node-insert' inserts a node without opening it."
(interactive "P")
(let ((args (cons arg args))
(org-roam-capture-templates (list (append (car org-roam-capture-templates)
'(:immediate-finish)))))
(apply #'org-roam-node-insert args)))
;; Add Dendron-like note refactoring functionality
;; This was taken from https://github.com/vicrdguez/dendroam
(cl-defmethod mm/org-roam-node-current-file (node)
(file-name-base (org-roam-node-file node)))
(cl-defmethod mm/org-roam-node-hierarchy-title (node)
(capitalize (car (last (split-string (org-roam-node-title node)
"\\.")))))
(defun mm/org-roam-refactor-file ()
(interactive)
(let* ((initial-file (buffer-file-name))
(initial-slug (file-name-base initial-file))
(new-slug (read-string "Refactor: " initial-slug))
(new-file (concat
(expand-file-name new-slug org-roam-directory)
".org")))
(rename-file initial-file new-file)
(kill-current-buffer)
(find-file new-file)))
(cl-defmethod mm/org-roam-node-hierarchy (node)
(funcall 'mm/org-roam-format-hierarchy (org-roam-node-file node)))
(cl-defmethod mm/org-roam-node-current-file (node)
(file-name-base (buffer-file-name)))
(defun mm/org-roam-get-same-hierarchy-files (hierarchy)
"Gets all the nodes that share the same HIERARCHY totally or partially"
(let ((files (mapcar #'car (org-roam-db-query [:select [file]
:from nodes
:where (like file $r1)]
(concat "%" hierarchy "%"))))) files))
(defun mm/org-roam-refactor-hierarchy (&optional current)
(interactive)
(let*
((initial-file (file-name-nondirectory (buffer-file-name)))
(initial-slug (file-name-base initial-file))
(new-slug (file-name-base (read-string "Refactor: " initial-slug)))
(initial-slug-no-title
(file-name-base initial-slug))
(files-to-upd (if current `(,initial-file)
(mm/org-roam-get-same-hierarchy-files
initial-slug-no-title))))
(dolist (file files-to-upd)
(let ((new-file
(replace-regexp-in-string initial-slug-no-title new-slug file)))
(rename-file file new-file)
(if (equal buffer-file-name file)
(progn
(kill-current-buffer)
(find-file new-file)))))))
;; `org-roam' configuration
(use-package org-roam
:straight t
:custom
(org-roam-directory (file-truename "~/kb"))
(make-directory org-roam-directory 'parents)
(org-roam-db-location (concat user-emacs-directory "/org-roam.db"))
(org-roam-capture-templates
'(("d" "default" plain "%?"
:unnarrowed t
:if-new (file+head "${title}.org"
"#+TITLE:"))))
(org-roam-dailies-capture-templates
'(("d" "default" plain "%?"
:unnarrowed t
:if-new (file+head "daily.%<%Y.%m.%d>.org"
"#+TITLE: Daily Log for %<%Y-%m-%d>\n"))))
(org-roam-complete-everywhere t)
:config
(org-roam-setup)
(org-roam-db-autosync-mode)
(require 'org-roam-dailies)
(setq org-roam-dailies-directory "")
:bind (("C-c n f" . org-roam-node-find)
("C-c n c" . org-roam-capture)
("C-c n d t" . org-roam-dailies-goto-today)
("C-c n d y" . org-roam-dailies-goto-yesterday)
("C-c n i" . mm/org-roam-node-insert-immediate)
("C-c n I" . org-roam-node-insert)
("C-c n u" . org-roam-update-org-id-locations)
("C-c n r h" . mm/org-roam-refactor-hierarchy)
("C-c n r f" . mm/org-roam-refactor-file)))
;; ---------------------------------
;; Task / Time Management
;; ----------------------
;; I track everything in org. It
;; makes it easier to remember
;; things, which is handy because I
;; am quite forgetful.
;; ---------------------------------
;; Agenda configuration
(use-package org
:config
(setq org-agenda-start-with-log-mode t
org-agenda-files '("~/kb/agenda.org")
org-todo-keywords'((sequence "TODO(t)" "IN-PROGRESS(i)" "WAITING(w)" "HOLD(h)"
"REVIEW(re)" "|" "DONE(d)" "CANCELED(ca)")
(sequence "EVENT(e)" "|" "MISSED_EVENT(me)" "ATTENDED_EVENT(ae)")
(sequence "APPT(ap)" "|" "MISSED_APPT(ma)" "ATTENDED_APPT(aa)")
(sequence "CLASS(cl)" "|" "ATTENDED_CLASS(ac)"
"MISSED_CLASS(mc)" "CANCELED_CLASS(cc)")
(sequence "REMINDER(rm)"))
org-agenda-span 7
org-agenda-start-day "0d"
org-agenda-start-on-weekday nil
org-agenda-use-time-grid t
org-agenda-time-grid (quote ((daily today remove-match)
(0 100 200 300 400 500 600 700 800 900
1000 1100 1200 1300 1400 1500 1600
1700 1800 1900 2000 2100 2200 2300)
"......." "."))
org-agenda-include-diary t
org-agenda-show-future-repeats nil
org-agenda-repeating-timestamp-show-all nil
org-agenda-skip-scheduled-if-done t
org-agenda-skip-deadline-if-done t
org-agenda-show-done-always-green nil
org-agenda-compact-blocks t
org-log-done 'time
org-log-into-drawer t)
(require 'org-habit)
(add-to-list 'org-modules 'org-habit)
(setq org-habit-show-habits t
org-habit-show-habits-only-for-today nil
org-habit-show-all-today nil
org-habit-graph-column 60
org-habit-following-days 1
org-habit-preceding-days 21)
:bind (("C-c a" . org-agenda-list)
("C-c n a" . (lambda () (interactive) (find-file "~/kb/agenda.org")))))
;; Update agenda periodically every `mm/refresh-agenda-time-seconds' seconds.
;; This was taken from https://emacs.stackexchange.com/a/68767/38877
(defvar mm/refresh-agenda-time-seconds 15)
(defvar mm/refresh-agenda-timer nil
"Timer for `mm/refresh-agenda-timer-function' to reschedule itself, or NIL")
(defun mm/refresh-agenda-timer-function ()
"If the user types a command while `mm/refresh-agenda-timer' is active, the next time this function is called from it's main idle timer, deactivate `mm/refresh-agenda-timer'."
(when mm/refresh-agenda-timer
(cancel-timer mm/refresh-agenda-timer))
;;(lambda () (save-window-excursion (org-agenda nil "a")))
(save-window-excursion (org-agenda nil "a"))
(setq mm/refresh-agenda-timer
(run-with-idle-timer
(time-add (current-idle-time) mm/refresh-agenda-time-seconds)
nil
'mm/refresh-agenda-timer-function)))
(run-with-idle-timer mm/refresh-agenda-time-seconds t 'mm/refresh-agenda-timer-function)
;; ---------------------------------------------------------------------
;;; Development Environment
;; ------------------------
;; MMOSMacs is intended to serve as a full-featured IDE
;; ---------------------------------------------------------------------
;; ---------------------------------
;; Syntax checking
;; ---------------
;; I'd like to know when I'm making
;; a mistake.
;; ---------------------------------
;; Flycheck is activated by specific language modes.
;; See `:hook's in language modes below to see which ones use it.
(use-package flycheck
:straight t
:defer t)
;; ---------------------------------
;; Language Server Protocol (LSP)
;; ------------------------------
;; Protocol for interaction between
;; Emacs and language servers.
;; ---------------------------------
(use-package lsp-mode
:straight t
:init (setq lsp-keymap-prefix "C-c l"))
;; ---------------------------------
;; Emacs Lisp
;; ----------
;; The language we all know and love
;; ---------------------------------
(use-package elisp-mode
:straight (:type built-in)
:commands (emacs-lisp-mode)
:hook (emacs-lisp-mode . flycheck-mode))
;; ---------------------------------
;; Common Lisp
;; -----------
;; The programmable language
;; ---------------------------------
;; Sly REPL
(use-package sly
:straight t
:config
(setq inferior-lisp-program "/usr/bin/sbcl"))
;; Quicklisp integration for Sly
(use-package sly-quicklisp
:straight t)
;; ---------------------------------
;; sh / Bash
;; ----------
;; Scripts for POSIX Shell and Bash.
;;
;; NOTE: The first time you use this
;; configuration, you must run
;; `M-x lsp-install-server RET bash-ls RET'
;; ---------------------------------
;; Configure sh-mode
(use-package sh-mode
:hook (sh-mode . flycheck-mode))
;; Configure LSP for sh / Bash
(use-package lsp-mode
:config
(setq lsp-bash-highlight-parsing-errors t))
;; ---------------------------------------------------------------------
;;; Keybinds
;; ---------
;; For now, just a few simple changes.
;; In the future there will be whole custom keybind system.
;; ---------------------------------------------------------------------
;; ---------------------------------
;; Keybind hints
;; -------------
;; Show hints for available keybinds
;; as you type them.
;; ---------------------------------
(use-package which-key
:straight t
:init (which-key-mode)
:config
(setq which-key-idle-delay 1.5))
;; ---------------------------------
;; Fix ESC behavior
;; ----------------
;; The default behavior of the ESC
;; key is atrocious. Why in God's
;; name would I want it to close all
;; my windows when I press it twice?
;;
;; This fixes the behavior to do
;; what ESC should do: "escape" the
;; current thing I'm doing, like the
;; minibuffer or a popup window.
;; ---------------------------------
;; Define fixed version of `keyboard-escape-quit' which does not close
;; windows or change their layout.
(defun mm/keyboard-escape-quit-keep-windows ()
"Alternative version of `keyboard-escape-quit' that does not change window layout."
(interactive)
(cond ((eq last-command 'mode-exited) nil)
((region-active-p)
(deactivate-mark))
((> (minibuffer-depth) 0)
(abort-recursive-edit))
(current-prefix-arg
nil)
((> (recursion-depth) 0)
(exit-recursive-edit))
(buffer-quit-function
(funcall buffer-quit-function))
;; The following lines are from `keyboard-escape-quit'.
;; They have been commented to disable the unwanted behavior
;; ((not (one-window-p t))
;; (delete-other-windows)
((string-match "^ \\*" (buffer-name (current-buffer)))
bury-buffer)))
;; Fix the keybinds for the ESC key
(global-set-key (kbd "<escape>") 'mm/keyboard-escape-quit-keep-windows)
(global-unset-key (kbd "C-x ESC ESC"))
;; ---------------------------------
;; Replace yes/no prompts with y/n
;; -------------------------------
;; It's too much to ask for me to
;; type 3 whole letters to confirm
;; something. I demand to only have
;; to press a single key.
;; ---------------------------------
(defalias 'yes-or-no-p 'y-or-n-p)
;; ---------------------------------
;; Improved HOME key behavior
;; --------------------------
;; Something bugs me about HOME
;; moving POINT to the actual
;; beginning of the line. I want it
;; to go to the beginning of the
;; text (i.e. follow indentation)
;; ---------------------------------
;; Make home key respect indentation
(global-set-key (kbd "<home>") 'beginning-of-line-text)
;; Use Shift + HOME for old behavior
(global-set-key (kbd "C-<home>") 'beginning-of-visual-line)
;; ---------------------------------
;; Insert date/time at POINT
;; -------------------------
;; [YYYY-MM-DD HH:mm]
;; ---------------------------------
(defvar mm/date-time-format "[%Y-%m-%d %H:%M]"
"Format of the date to insert with `mm/insert-date-time' function. See help of `format-time-string' for alternative formats.")
(defun mm/insert-date-time ()
"Insert the current date time in the format of `mm/date-time-format' at POINT."
(interactive)
(insert (format-time-string mm/date-time-format (current-time))))
(global-set-key (kbd "C-c d") (lambda () (interactive) (mm/insert-date-time)))
;; ---------------------------------
;; Improved Help buffer
;; --------------------
;; Helpful provides a more
;; informative Help buffer.
;; ---------------------------------
(use-package helpful
:straight t
:bind (("C-h f" . helpful-callable)
("C-h k" . helpful-key)
("C-h p" . helpful-at-point)
("C-h v" . helpful-variable)
("C-h x" . helpful-command)))
|