aboutsummaryrefslogtreecommitdiff
path: root/init.el
diff options
context:
space:
mode:
Diffstat (limited to 'init.el')
-rw-r--r--init.el129
1 files changed, 65 insertions, 64 deletions
diff --git a/init.el b/init.el
index 76cc321..d92ff6f 100644
--- a/init.el
+++ b/init.el
@@ -1,21 +1,24 @@
1;;; -*- lexical-binding: t; -*- 1;;; init.el --- Init file for MMOSMacs -*- lexical-binding: t; -*-
2;;; init.el
3;; 2;;
3;;; Commentary:
4;; Main configuration file for MMOSMacs. 4;; Main configuration file for MMOSMacs.
5 5
6;;; Code:
6 7
7;; --------------------------------------------------------------------- 8;; ---------------------------------------------------------------------
8;;; Startup 9;;; Startup
9;; -------- 10;; --------
10;; These items need to be done first 11;; These items need to be done first.
11;; --------------------------------------------------------------------- 12;; ---------------------------------------------------------------------
12 13
13;; -------------------------------- 14;; --------------------------------
14;; Produce backtraces when errors 15;; Debug on error
15;; occur. Can be helpful to 16;; --------------
16;; diagnose startup issues. 17;; Can be helpful to diagnose
18;; startup issues.
17;; --------------------------------- 19;; ---------------------------------
18 20
21;; Produce backtraces when errors occur
19(setq debug-on-error t) 22(setq debug-on-error t)
20 23
21 24
@@ -53,7 +56,7 @@
53;; --------------------------------- 56;; ---------------------------------
54;; `use-package' 57;; `use-package'
55;; ------------- 58;; -------------
56;; This makes sure `use-package' is 59;; Makes sure `use-package' is
57;; installed and loaded. 60;; installed and loaded.
58;; --------------------------------- 61;; ---------------------------------
59 62
@@ -63,10 +66,10 @@
63;; --------------------------------- 66;; ---------------------------------
64;; Don't load outdated code 67;; Don't load outdated code
65;; ------------------------ 68;; ------------------------
66;; MMOSMacs is under highly active 69;; MMOSMacs is under active
67;; development and undergoes 70;; development and undergoes
68;; freuqent changes. The newest code 71;; freuqent changes. The newest code
69;; should always be loaded 72;; should always be loaded.
70;; --------------------------------- 73;; ---------------------------------
71 74
72;; if a `.el' file is newer than its corresponding `.elc', load the `.el' 75;; if a `.el' file is newer than its corresponding `.elc', load the `.el'
@@ -102,6 +105,7 @@
102;; Garbage Collector Magic Hack 105;; Garbage Collector Magic Hack
103;; --------------------------------- 106;; ---------------------------------
104 107
108;; Configure GCMH
105(use-package gcmh 109(use-package gcmh
106 :straight t 110 :straight t
107 :defer t 111 :defer t
@@ -109,7 +113,9 @@
109 :init 113 :init
110 (setq gcmh-idle-delay 15 114 (setq gcmh-idle-delay 15
111 gcmh-idle-delay-factor 10 115 gcmh-idle-delay-factor 10
112 gcmh-high-cons-threshold (* 16 1024))) ;16kb 116 gcmh-high-cons-threshold (* 16 1024))) ;16kb
117
118;; Start GCMH after init is complete
113(add-hook 'after-init-hook 'gcmh-mode) 119(add-hook 'after-init-hook 'gcmh-mode)
114 120
115 121
@@ -119,11 +125,12 @@
119;; Asynchronous processing of things 125;; Asynchronous processing of things
120;; --------------------------------- 126;; ---------------------------------
121 127
122;; Async package 128;; Configure Async package
123(use-package async 129(use-package async
124 :straight t 130 :straight t
125 :config 131 :config
126 (setq async-bytecomp-package-mode t)) 132 (setq async-bytecomp-package-mode t ;Enable byte-compiled Emacs Lisp
133 warning-suppress-types '((comp)))) ;Don't steal focus while doing Async compilation
127 134
128 135
129 136
@@ -182,15 +189,13 @@
182 ([?\s-d] . windmove-down) 189 ([?\s-d] . windmove-down)
183 ([?\s-s] . windmove-left) 190 ([?\s-s] . windmove-left)
184 ([?\s-f] . windmove-right) 191 ([?\s-f] . windmove-right)
185 ;; Launch applications via shell command 192 ;; Launch applications via shell command with `s-x'
186 ([?\s-x] . (lambda (command) 193 ([?\s-x] . (lambda (command)
187 (interactive (list (read-shell-command "$ "))) 194 (interactive (list (read-shell-command "$ ")))
188 (start-process-shell-command 195 (start-process-shell-command
189 command nil command))) 196 command nil command)))
190 ;; Switch workspace 197 ;; Switch workspace with `s-w'
191 ([?\s-w] . exwm-workspace-switch) 198 ([?\s-w] . exwm-workspace-switch)))
192 ([?\s-`] . (lambda () (interactive)
193 (exwm-workspace-switch-create 0)))))
194 (exwm-enable)) 199 (exwm-enable))
195 200
196 201
@@ -203,7 +208,9 @@
203;; look at Emacs. 208;; look at Emacs.
204;; --------------------------------- 209;; ---------------------------------
205 210
206;; Jazz Theme 211;; Jazz Theme is the nicest-looking
212;; theme I've found so far. Really
213;; easy on the eyes.
207(use-package jazz-theme 214(use-package jazz-theme
208 :straight t) 215 :straight t)
209(load-theme 'jazz t) 216(load-theme 'jazz t)
@@ -244,7 +251,8 @@
244;; --------------------------------- 251;; ---------------------------------
245;; Fonts 252;; Fonts
246;; ----- 253;; -----
247;; For now I use Iosevka and Exo 254;; For now I use JetBrains Mono and
255;; Noto Sans.
248;; --------------------------------- 256;; ---------------------------------
249 257
250(set-face-attribute 'default nil :font "JetBrains Mono" :height 100) 258(set-face-attribute 'default nil :font "JetBrains Mono" :height 100)
@@ -389,10 +397,10 @@
389 :straight (:type built-in) 397 :straight (:type built-in)
390 :config 398 :config
391 (setq isearch-lazy-count t 399 (setq isearch-lazy-count t
392 lazy-count-prefix-format nil 400 lazy-count-prefix-format nil ;don't show match count before search
393 lazy-count-suffix-format " (%s/%S)" 401 lazy-count-suffix-format " (%s/%S)" ;show match count at end of search
394 search-whitespace-regexp ".*" 402 search-whitespace-regexp ".*"
395 isearch-lax-whitespace t 403 isearch-lax-whitespace t ;match any number of spaces
396 isearch-regexp-lax-whitespace t)) 404 isearch-regexp-lax-whitespace t))
397 405
398 406
@@ -512,7 +520,6 @@
512;; the selected text 520;; the selected text
513(delete-selection-mode t) 521(delete-selection-mode t)
514 522
515
516;; Expand region by semantic units 523;; Expand region by semantic units
517(use-package expand-region 524(use-package expand-region
518 :straight t 525 :straight t
@@ -532,7 +539,7 @@
532 :straight t 539 :straight t
533 :bind (("s-m" . mc/mark-more-like-this-extended)) 540 :bind (("s-m" . mc/mark-more-like-this-extended))
534 :config 541 :config
535 (setq mc/cmds 542 (setq mc/cmds-to-run-for-all
536 '(electric-pair-delete-pair 543 '(electric-pair-delete-pair
537 end-of-visual-line 544 end-of-visual-line
538 beginning-of-visual-line 545 beginning-of-visual-line
@@ -665,7 +672,7 @@
665(use-package diff-hl 672(use-package diff-hl
666 :straight t 673 :straight t
667 :config 674 :config
668 (set-fringe-mode '(10 . 0)) 675 (set-fringe-mode '(10 . 0)) ;fringe width
669 :hook 676 :hook
670 (prog-mode . diff-hl-mode) 677 (prog-mode . diff-hl-mode)
671 (diff-hl-mode . diff-hl-flydiff-mode)) 678 (diff-hl-mode . diff-hl-flydiff-mode))
@@ -698,14 +705,17 @@
698 (visual-line-mode) 705 (visual-line-mode)
699 (variable-pitch-mode)) 706 (variable-pitch-mode))
700 707
701
702;; Org font stuff 708;; Org font stuff
703(defun mm/org-font-setup () 709(defun mm/org-font-setup ()
704 ;; Replace hyphens in lists with dots 710 ;; Replace hyphens in lists with dots
705 (font-lock-add-keywords 'org-mode 711 (font-lock-add-keywords 'org-mode
706 '(("^ *\\([-]\\) " 712 '(("^ *\\([-]\\) "
707 (0 (prog1 () (compose-region (match-beginning 1) (match-end 1) "•")))))) 713 (0 (prog1 ()
708 ;; Set font sizes 714 (compose-region
715 (match-beginning 1)
716 (match-end 1)
717 "•"))))))
718 ;; Set font sizes for org headings
709 (dolist (face '((org-level-1 . 1.1) 719 (dolist (face '((org-level-1 . 1.1)
710 (org-level-2 . 1.1) 720 (org-level-2 . 1.1)
711 (org-level-3 . 1.1) 721 (org-level-3 . 1.1)
@@ -737,7 +747,6 @@
737 (set-face-attribute 'org-agenda-current-time nil :inherit 'fixed-pitch) 747 (set-face-attribute 'org-agenda-current-time nil :inherit 'fixed-pitch)
738 (set-face-attribute 'org-agenda-calendar-event nil :inherit 'fixed-pitch))) 748 (set-face-attribute 'org-agenda-calendar-event nil :inherit 'fixed-pitch)))
739 749
740
741;; `org' configuration 750;; `org' configuration
742(use-package org 751(use-package org
743 :straight t 752 :straight t
@@ -755,7 +764,6 @@
755 ("C-c n l t" . org-toggle-link-display) 764 ("C-c n l t" . org-toggle-link-display)
756 ("C-c t" . org-agenda-todo)) 765 ("C-c t" . org-agenda-todo))
757 766
758
759;; Make org heading bullets look nicer 767;; Make org heading bullets look nicer
760(use-package org-bullets 768(use-package org-bullets
761 :straight t 769 :straight t
@@ -763,8 +771,7 @@
763 :custom 771 :custom
764 (org-bullets-bullet-list '("•"))) 772 (org-bullets-bullet-list '("•")))
765 773
766 774;; Auto-show emphasis markers and links on hover
767;; Auto-show emphasis markers on hover
768(use-package org-appear 775(use-package org-appear
769 :straight t 776 :straight t
770 :hook (org-mode . org-appear-mode) 777 :hook (org-mode . org-appear-mode)
@@ -773,8 +780,7 @@
773 org-appear-autolinks t 780 org-appear-autolinks t
774 org-appear-autosubmarkers t)) 781 org-appear-autosubmarkers t))
775 782
776 783;; Define keybinds to follow org links
777;; Show link hints to make following links easier
778(use-package link-hint 784(use-package link-hint
779 :straight t 785 :straight t
780 :bind 786 :bind
@@ -790,24 +796,24 @@
790 796
791;; Define function to insert a link to a node without opening it 797;; Define function to insert a link to a node without opening it
792(defun mm/org-roam-node-insert-immediate (arg &rest args) 798(defun mm/org-roam-node-insert-immediate (arg &rest args)
793 "This version of `org-roam-node-insert' inserts a node without opening it." 799 "Insert `org-roam' node without opening it."
794 (interactive "P") 800 (interactive "P")
795 (let ((args (cons arg args)) 801 (let ((args (cons arg args))
796 (org-roam-capture-templates (list (append (car org-roam-capture-templates) 802 (org-roam-capture-templates
797 '(:immediate-finish))))) 803 (list (append (car org-roam-capture-templates)
804 '(:immediate-finish)))))
798 (apply #'org-roam-node-insert args))) 805 (apply #'org-roam-node-insert args)))
799 806
800
801;; Add Dendron-like note refactoring functionality 807;; Add Dendron-like note refactoring functionality
802;; This was taken from https://github.com/vicrdguez/dendroam 808;; This was taken from https://github.com/vicrdguez/dendroam
803(cl-defmethod mm/org-roam-node-current-file (node) 809(cl-defmethod mm/org-roam-node-current-file (node)
804 (file-name-base (org-roam-node-file node))) 810 (file-name-base (org-roam-node-file node)))
805 811
806(cl-defmethod mm/org-roam-node-hierarchy-title (node) 812(cl-defmethod mm/org-roam-node-hierarchy-title (node)
807 (capitalize (car (last (split-string (org-roam-node-title node) 813 (capitalize (car (last (split-string (org-roam-node-title node) "\\.")))))
808 "\\.")))))
809 814
810(defun mm/org-roam-refactor-file () 815(defun mm/org-roam-refactor-file ()
816 "Refactor current `org-roam' node/file."
811 (interactive) 817 (interactive)
812 (let* ((initial-file (buffer-file-name)) 818 (let* ((initial-file (buffer-file-name))
813 (initial-slug (file-name-base initial-file)) 819 (initial-slug (file-name-base initial-file))
@@ -826,13 +832,14 @@
826 (file-name-base (buffer-file-name))) 832 (file-name-base (buffer-file-name)))
827 833
828(defun mm/org-roam-get-same-hierarchy-files (hierarchy) 834(defun mm/org-roam-get-same-hierarchy-files (hierarchy)
829 "Gets all the nodes that share the same HIERARCHY totally or partially" 835 "Get all the nodes that share the same HIERARCHY totally or partially."
830 (let ((files (mapcar #'car (org-roam-db-query [:select [file] 836 (let ((files (mapcar #'car (org-roam-db-query [:select [file]
831 :from nodes 837 :from nodes
832 :where (like file $r1)] 838 :where (like file $r1)]
833 (concat "%" hierarchy "%"))))) files)) 839 (concat "%" hierarchy "%"))))) files))
834 840
835(defun mm/org-roam-refactor-hierarchy (&optional current) 841(defun mm/org-roam-refactor-hierarchy (&optional current)
842 "Refactor all `org-roam' nodes/files under CURRENT hierarchy."
836 (interactive) 843 (interactive)
837 (let* 844 (let*
838 ((initial-file (file-name-nondirectory (buffer-file-name))) 845 ((initial-file (file-name-nondirectory (buffer-file-name)))
@@ -857,9 +864,12 @@
857(use-package org-roam 864(use-package org-roam
858 :straight t 865 :straight t
859 :custom 866 :custom
867 ;; Keep all notes in `~/kb', which should be synced between all computers
860 (org-roam-directory (file-truename "~/kb")) 868 (org-roam-directory (file-truename "~/kb"))
861 (make-directory org-roam-directory 'parents) 869 (make-directory org-roam-directory 'parents)
870 ;; Do not sync `org-roam.db', it is ephemeral.
862 (org-roam-db-location (concat user-emacs-directory "/org-roam.db")) 871 (org-roam-db-location (concat user-emacs-directory "/org-roam.db"))
872 ;; Customize results display when running `org-roam-node-find'
863 (org-roam-node-display-template (concat 873 (org-roam-node-display-template (concat
864 (propertize "${title:48} " 'face 'org-document-title) 874 (propertize "${title:48} " 'face 'org-document-title)
865 (propertize "${file:*}" 'face 'org-roam-dim))) 875 (propertize "${file:*}" 'face 'org-roam-dim)))
@@ -889,7 +899,7 @@
889 ("C-c n r h" . mm/org-roam-refactor-hierarchy) 899 ("C-c n r h" . mm/org-roam-refactor-hierarchy)
890 ("C-c n r f" . mm/org-roam-refactor-file))) 900 ("C-c n r f" . mm/org-roam-refactor-file)))
891 901
892;; Graph UI for org-roam. 902;; Web-served graph UI for org-roam.
893(use-package org-roam-ui 903(use-package org-roam-ui
894 :straight t 904 :straight t
895 :config 905 :config
@@ -916,13 +926,14 @@
916 :config 926 :config
917 (setq org-agenda-start-with-log-mode t 927 (setq org-agenda-start-with-log-mode t
918 org-agenda-files '("~/kb/agenda.org") 928 org-agenda-files '("~/kb/agenda.org")
919 org-todo-keywords'((sequence "TODO(t)" "IN-PROGRESS(i)" "WAITING(w)" "HOLD(h)" 929 org-todo-keywords
920 "REVIEW(re)" "|" "DONE(d)" "CANCELED(ca)") 930 '((sequence "TODO(t)" "IN-PROGRESS(i)" "WAITING(w)" "HOLD(h)"
921 (sequence "EVENT(e)" "|" "MISSED_EVENT(me)" "ATTENDED_EVENT(ae)") 931 "REVIEW(re)" "|" "DONE(d)" "CANCELED(ca)")
922 (sequence "APPT(ap)" "|" "MISSED_APPT(ma)" "ATTENDED_APPT(aa)") 932 (sequence "EVENT(e)" "|" "MISSED_EVENT(me)" "ATTENDED_EVENT(ae)")
923 (sequence "CLASS(cl)" "|" "ATTENDED_CLASS(ac)" 933 (sequence "APPT(ap)" "|" "MISSED_APPT(ma)" "ATTENDED_APPT(aa)")
924 "MISSED_CLASS(mc)" "CANCELED_CLASS(cc)") 934 (sequence "CLASS(cl)" "|" "ATTENDED_CLASS(ac)"
925 (sequence "REMINDER(rm)")) 935 "MISSED_CLASS(mc)" "CANCELED_CLASS(cc)")
936 (sequence "REMINDER(rm)"))
926 org-agenda-span 7 937 org-agenda-span 7
927 org-agenda-start-day "0d" 938 org-agenda-start-day "0d"
928 org-agenda-start-on-weekday nil 939 org-agenda-start-on-weekday nil
@@ -957,7 +968,7 @@
957;; This was taken from https://emacs.stackexchange.com/a/68767/38877 968;; This was taken from https://emacs.stackexchange.com/a/68767/38877
958(defvar mm/refresh-agenda-time-seconds 15) 969(defvar mm/refresh-agenda-time-seconds 15)
959(defvar mm/refresh-agenda-timer nil 970(defvar mm/refresh-agenda-timer nil
960 "Timer for `mm/refresh-agenda-timer-function' to reschedule itself, or NIL") 971 "Timer for `mm/refresh-agenda-timer-function' to reschedule itself, or NIL.")
961(defun mm/refresh-agenda-timer-function () 972(defun mm/refresh-agenda-timer-function ()
962 "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'." 973 "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'."
963 (when mm/refresh-agenda-timer 974 (when mm/refresh-agenda-timer
@@ -990,7 +1001,7 @@
990(use-package vterm 1001(use-package vterm
991 :straight t 1002 :straight t
992 :config 1003 :config
993 (setq vterm-always-compile-module t)) 1004 (setq vterm-always-compile-module t)) ;don't ask about compiling module on startup
994 1005
995 1006
996;; --------------------------------- 1007;; ---------------------------------
@@ -1003,8 +1014,7 @@
1003;; Eldoc shows function definition hints in the echo area 1014;; Eldoc shows function definition hints in the echo area
1004(use-package eldoc 1015(use-package eldoc
1005 :straight (:type built-in) 1016 :straight (:type built-in)
1006 :delight 1017 :delight)
1007 :config)
1008 1018
1009;; Flycheck is activated by specific language modes. 1019;; Flycheck is activated by specific language modes.
1010;; See `:hook's in language modes below to see which ones use it. 1020;; See `:hook's in language modes below to see which ones use it.
@@ -1174,17 +1184,6 @@
1174 1184
1175 1185
1176;; --------------------------------- 1186;; ---------------------------------
1177;; Improved HOME key behavior
1178;; --------------------------
1179;; Something bugs me about HOME
1180;; moving POINT to the actual
1181;; beginning of the line. I want it
1182;; to go to the beginning of the
1183;; text (i.e. follow indentation)
1184;; ---------------------------------
1185
1186
1187;; ---------------------------------
1188;; Movement 1187;; Movement
1189;; -------- 1188;; --------
1190;; MMOSMacs uses s-IJKLUO keybinds 1189;; MMOSMacs uses s-IJKLUO keybinds
@@ -1250,6 +1249,8 @@
1250;; Fix "IK" M-arrow movement for org-mode 1249;; Fix "IK" M-arrow movement for org-mode
1251(define-key org-mode-map (kbd "s-M-i") (kbd "M-<up>")) 1250(define-key org-mode-map (kbd "s-M-i") (kbd "M-<up>"))
1252(define-key org-mode-map (kbd "s-M-k") (kbd "M-<down>")) 1251(define-key org-mode-map (kbd "s-M-k") (kbd "M-<down>"))
1252(define-key org-mode-map (kbd "s-M-j") (kbd "M-<left>"))
1253(define-key org-mode-map (kbd "s-M-l") (kbd "M-<right>"))
1253 1254
1254 1255
1255;; --------------------------------- 1256;; ---------------------------------