aboutsummaryrefslogtreecommitdiff
path: root/init.el
diff options
context:
space:
mode:
authorMountain Man <43313373+MountainMan1312@users.noreply.github.com>2023-05-12 23:37:53 -0400
committerMountain Man <43313373+MountainMan1312@users.noreply.github.com>2023-05-12 23:37:53 -0400
commitafdc9cf3d7963d971921546168a545e620daec33 (patch)
treec8d9547701b2c0cf7aec69824988f8d22f70b8a5 /init.el
parentModify .gitignore (diff)
downloadmmosmacs-afdc9cf3d7963d971921546168a545e620daec33.tar.gz
mmosmacs-afdc9cf3d7963d971921546168a545e620daec33.tar.bz2
mmosmacs-afdc9cf3d7963d971921546168a545e620daec33.zip
Bulk org/org-roam PKMS overhaul
This is a large set of changes to PKMS functionality in general. It was necessary to develop the whole thing as a unit like this, but I do not have the energy to refactor all this crap into separate atomic commit. Whoever finds this will just have to deal with it. I am sorry.
Diffstat (limited to 'init.el')
-rw-r--r--init.el246
1 files changed, 225 insertions, 21 deletions
diff --git a/init.el b/init.el
index 909e567..0c83c86 100644
--- a/init.el
+++ b/init.el
@@ -116,6 +116,8 @@
116 116
117(load-theme 'jazz t) 117(load-theme 'jazz t)
118 118
119(set-background-color "black")
120
119 121
120;; --------------------------------- 122;; ---------------------------------
121;; Fonts 123;; Fonts
@@ -125,7 +127,8 @@
125 127
126(set-face-attribute 'default nil :font "Iosevka" :height 120) 128(set-face-attribute 'default nil :font "Iosevka" :height 120)
127(set-face-attribute 'fixed-pitch nil :font "Iosevka" :height 120) 129(set-face-attribute 'fixed-pitch nil :font "Iosevka" :height 120)
128(set-face-attribute 'variable-pitch nil :font "DejaVu Sans" :height 120 :weight 'regular) 130;;(set-face-attribute 'variable-pitch nil :font "Exo" :height 120 :weight 'regular)
131(set-face-attribute 'variable-pitch nil :font "-UKWN-Exo 2-normal-normal-normal-*-*-*-*-*-*-0-iso10646-1" :height 120)
129 132
130 133
131 134
@@ -229,7 +232,8 @@
229(global-display-line-numbers-mode t) 232(global-display-line-numbers-mode t)
230 233
231;; Disable line numbers in specific modes 234;; Disable line numbers in specific modes
232(dolist (mode '(org-mode-hook)) 235(dolist (mode '(org-mode-hook
236 org-agenda-mode-hook))
233 (add-hook mode (lambda () (display-line-numbers-mode 0)))) 237 (add-hook mode (lambda () (display-line-numbers-mode 0))))
234 238
235 239
@@ -370,7 +374,9 @@
370;; -------------------------------------------- 374;; --------------------------------------------
371;; Using `org', `org-roam', and a note-hierarchy I've developed over 375;; Using `org', `org-roam', and a note-hierarchy I've developed over
372;; several years of trial-and-error, I keep all my notes in a logical 376;; several years of trial-and-error, I keep all my notes in a logical
373;; organized collection. 377;; organized collection. I feel this knowledgebase system can handle
378;; almost any bit of information I can throw at it, and it is flexible
379;; enough to adapt when I find new things it can't handle.
374;; --------------------------------------------------------------------- 380;; ---------------------------------------------------------------------
375 381
376;; --------------------------------- 382;; ---------------------------------
@@ -385,7 +391,6 @@
385;; is opened. 391;; is opened.
386(defun mm/org-mode-setup () 392(defun mm/org-mode-setup ()
387 (org-indent-mode) 393 (org-indent-mode)
388 (auto-fill-mode)
389 (visual-line-mode) 394 (visual-line-mode)
390 (variable-pitch-mode)) 395 (variable-pitch-mode))
391 396
@@ -396,32 +401,37 @@
396 (font-lock-add-keywords 'org-mode 401 (font-lock-add-keywords 'org-mode
397 '(("^ *\\([-]\\) " 402 '(("^ *\\([-]\\) "
398 (0 (prog1 () (compose-region (match-beginning 1) (match-end 1) "•")))))) 403 (0 (prog1 () (compose-region (match-beginning 1) (match-end 1) "•"))))))
399 404 ;; Set font sizes
400 ;; Set font size per heading level 405 (dolist (face '((org-level-1 . 1.5)
401 (dolist (face '((org-level-1 . 1.7) 406 (org-level-2 . 1.4)
402 (org-level-2 . 1.5)
403 (org-level-3 . 1.3) 407 (org-level-3 . 1.3)
404 (org-level-4 . 1.1) 408 (org-level-4 . 1.2)
405 (org-level-5 . 1.1) 409 (org-level-5 . 1.1)
406 (org-level-6 . 1.1) 410 (org-level-6 . 1.1)
407 (org-level-7 . 1.1) 411 (org-level-7 . 1.1)
408 (org-level-8 . 1.1))) 412 (org-level-8 . 1.1)))
409 (set-face-attribute (car face) nil :font "DejaVu Sans" :weight 'regular :height (cdr face))) 413 (set-face-attribute (car face) nil
410 414 :font "-UKWN-Exo 2-normal-normal-normal-*-*-*-*-*-*-0-iso10646-1"
411 415 :weight 'regular
416 :height (cdr face))
412 ;; Ensure anything that should be 417 ;; Ensure anything that should be
413 ;; fixed-pitch actually is. 418 ;; fixed-pitch actually is.
414 (set-face-attribute 'org-block nil :foreground nil :inherit 'fixed-pitch) 419 (set-face-attribute 'org-block nil :foreground nil :inherit 'fixed-pitch)
415 (set-face-attribute 'org-table nil :inherit 'fixed-pitch) 420 (set-face-attribute 'org-table nil :inherit 'fixed-pitch)
416 (set-face-attribute 'org-formula nil :inherit 'fixed-pitch) 421 (set-face-attribute 'org-formula nil :inherit 'fixed-pitch)
417 (set-face-attribute 'org-code nil :inherit '(shadow fixed-pitch)) 422 (set-face-attribute 'org-code nil :inherit '(shadow fixed-pitch))
418 (set-face-attribute 'org-table nil :inherit '(shadow fixed-pitch)) 423 (set-face-attribute 'org-table nil :inherit '(shadow fixed-pitch))
419 (set-face-attribute 'org-verbatim nil :inherit '(shadow fixed-pitch)) 424 (set-face-attribute 'org-verbatim nil :inherit '(shadow fixed-pitch))
420 (set-face-attribute 'org-special-keyword nil :inherit '(font-lock-comment-face fixed-pitch)) 425 (set-face-attribute 'org-special-keyword nil :inherit '(font-lock-comment-face fixed-pitch))
421 (set-face-attribute 'org-meta-line nil :inherit '(font-lock-comment-face fixed-pitch)) 426 (set-face-attribute 'org-meta-line nil :inherit '(font-lock-comment-face fixed-pitch))
422 (set-face-attribute 'org-checkbox nil :inherit 'fixed-pitch) 427 (set-face-attribute 'org-checkbox nil :inherit 'fixed-pitch)
423 (set-face-attribute 'line-number nil :inherit 'fixed-pitch) 428 (set-face-attribute 'org-time-grid nil :inherit 'fixed-pitch)
424 (set-face-attribute 'line-number-current-line nil :inherit 'fixed-pitch)) 429 (set-face-attribute 'org-scheduled nil :inherit 'fixed-pitch)
430 (set-face-attribute 'org-agenda-structure nil :inherit 'fixed-pitch)
431 (set-face-attribute 'org-agenda-date nil :inherit 'fixed-pitch)
432 (set-face-attribute 'org-agenda-date-today nil :inherit 'fixed-pitch)
433 (set-face-attribute 'org-agenda-current-time nil :inherit 'fixed-pitch)
434 (set-face-attribute 'org-agenda-calendar-event nil :inherit 'fixed-pitch)))
425 435
426 436
427;; `org' configuration 437;; `org' configuration
@@ -429,11 +439,15 @@
429 :straight t 439 :straight t
430 :hook (org-mode . mm/org-mode-setup) 440 :hook (org-mode . mm/org-mode-setup)
431 :config 441 :config
442 (mm/org-font-setup)
432 (setq org-ellipsis " ►" 443 (setq org-ellipsis " ►"
433 org-hide-leading-stars t 444 org-hide-leading-stars t
434 org-adapt-indentation t 445 org-adapt-indentation t
435 org-support-shift-select 'always) 446 org-support-shift-select 'always
436 (mm/org-font-setup)) 447 org-return-follows-link t)
448 (advice-add 'org-refile :after 'org-save-all-org-buffers)
449 :bind
450 ("C-c t l" . org-toggle-link-display))
437 451
438 452
439;; Make org heading bullets look nicer 453;; Make org heading bullets look nicer
@@ -444,6 +458,196 @@
444 (org-bullets-bullet-list '("•"))) 458 (org-bullets-bullet-list '("•")))
445 459
446 460
461;; Auto-show emphasis markers on hover
462(use-package org-appear
463 :straight t
464 :hook (org-mode . org-appear-mode)
465 :config
466 (setq org-hide-emphasis-markers t
467 org-appear-autolinks t
468 org-appear-autosubmarkers t))
469
470
471;; Show link hints to make following links easier
472(use-package link-hint
473 :straight t
474 :bind
475 ("C-c l o" . link-hint-open-link)
476 ("C-c l c" . link-hint-copy-link))
477
478
479;; ---------------------------------
480;; `org-roam'
481;; ----------
482;; Org roam adds a ton of PKMS
483;; functionality to org.
484;; ---------------------------------
485
486;; Define function to insert a link to a node without opening it
487(defun mm/org-roam-node-insert-immediate (arg &rest args)
488 "This version of `org-roam-node-insert' inserts a node without opening it."
489 (interactive "P")
490 (let ((args (cons arg args))
491 (org-roam-capture-templates (list (append (car org-roam-capture-templates)
492 '(:immediate-finish)))))
493 (apply #'org-roam-node-insert args)))
494
495
496;; Add Dendron-like note refactoring functionality
497;; This was taken from https://github.com/vicrdguez/dendroam
498(cl-defmethod mm/org-roam-node-current-file (node)
499 (file-name-base (org-roam-node-file node)))
500
501(cl-defmethod mm/org-roam-node-hierarchy-title (node)
502 (capitalize (car (last (split-string (org-roam-node-title node)
503 "\\.")))))
504
505(defun mm/org-roam-refactor-file ()
506 (interactive)
507 (let* ((initial-file (buffer-file-name))
508 (initial-slug (file-name-base initial-file))
509 (new-slug (read-string "Refactor: " initial-slug))
510 (new-file (concat
511 (expand-file-name new-slug org-roam-directory)
512 ".org")))
513 (rename-file initial-file new-file)
514 (kill-current-buffer)
515 (find-file new-file)))
516
517(cl-defmethod mm/org-roam-node-hierarchy (node)
518 (funcall 'mm/org-roam-format-hierarchy (org-roam-node-file node)))
519
520(cl-defmethod mm/org-roam-node-current-file (node)
521 (file-name-base (buffer-file-name)))
522
523(defun mm/org-roam-get-same-hierarchy-files (hierarchy)
524 "Gets all the nodes that share the same HIERARCHY totally or partially"
525 (let ((files (mapcar #'car (org-roam-db-query [:select [file]
526 :from nodes
527 :where (like file $r1)]
528 (concat "%" hierarchy "%"))))) files))
529
530(defun mm/org-roam-refactor-hierarchy (&optional current)
531 (interactive)
532 (let*
533 ((initial-file (file-name-nondirectory (buffer-file-name)))
534 (initial-slug (file-name-base initial-file))
535 (new-slug (file-name-base (read-string "Refactor: " initial-slug)))
536 (initial-slug-no-title
537 (file-name-base initial-slug))
538 (files-to-upd (if current `(,initial-file)
539 (mm/org-roam-get-same-hierarchy-files
540 initial-slug-no-title))))
541 (dolist (file files-to-upd)
542 (let ((new-file
543 (replace-regexp-in-string initial-slug-no-title new-slug file)))
544 (rename-file file new-file)
545 (if (equal buffer-file-name file)
546 (progn
547 (kill-current-buffer)
548 (find-file new-file)))))))
549
550
551;; `org-roam' configuration
552(use-package org-roam
553 :straight t
554 :custom
555 (org-roam-directory (file-truename "~/kb"))
556 (make-directory org-roam-directory 'parents)
557 (org-roam-db-location (concat org-roam-directory "/org-roam.db"))
558 (org-roam-capture-templates
559 '(("d" "default" plain "%?"
560 :unnarrowed t
561 :if-new (file+head "${title}.org"
562 "#+TITLE:"))))
563 (org-roam-dailies-capture-templates
564 '(("d" "default" plain "%?"
565 :unnarrowed t
566 :if-new (file+head "daily.%<%Y.%m.%d>.org"
567 "#+TITLE: Daily Log for %<%Y-%m-%d>\n"))))
568 (org-roam-complete-everywhere t)
569 :config
570 (org-roam-setup)
571 (org-roam-db-autosync-mode)
572 (require 'org-roam-dailies)
573 (setq org-roam-dailies-directory "")
574 :bind (("C-c n f" . org-roam-node-find)
575 ("C-c n c" . org-roam-capture)
576 ("C-c n d t" . org-roam-dailies-goto-today)
577 ("C-c n d y" . org-roam-dailies-goto-yesterday)
578 ("C-c n i" . mm/org-roam-node-insert-immediate)
579 ("C-c n I" . org-roam-node-insert)
580 ("C-c n u" . org-roam-update-org-id-locations)
581 ("C-c n r h" . mm/org-roam-refactor-hierarchy)
582 ("C-c n r f" . mm/org-roam-refactor-file)))
583
584
585;; ---------------------------------
586;; Task / Time Management
587;; ----------------------
588;; I track everything in org. It
589;; makes it easier to remember
590;; things, which is handy because I
591;; am quite forgetful.
592;; ---------------------------------
593
594;; Agenda configuration
595(use-package org
596 :config
597 (setq org-agenda-start-with-log-mode t
598 org-agenda-files '("~/kb/agenda.org")
599 org-todo-keywords'((sequence "TODO(t)" "IN-PROGRESS(i)" "WAITING(w)" "HOLD(h)" "REVIEW(re)" "|" "DONE(d)" "CANCELED(c)")
600 (sequence "EVENT(e)" "|" "MISSED_EVENT(me)" "ATTENDED_EVENT(ae)")
601 (sequence "APPT(ap)" "|" "MISSED_APPT(ma)" "ATTENDED_APPT(aa)")
602 (sequence "REMINDER(rm)"))
603 org-agenda-span 7
604 org-agenda-start-day "0d"
605 org-agenda-start-on-weekday nil
606 org-agenda-use-time-grid t
607 org-agenda-time-grid (quote ((daily today remove-match)
608 (0 100 200 300 400 500 600 700 800 900
609 1000 1100 1200 1300 1400 1500 1600
610 1700 1800 1900 2000 2100 2200 2300)
611 "......." "."))
612 org-agenda-include-diary t
613 org-agenda-show-future-repeats nil
614 org-agenda-repeating-timestamp-show-all nil
615 org-agenda-skip-scheduled-if-done t
616 org-agenda-skip-deadline-if-done t
617 org-agenda-show-done-always-green nil
618 org-agenda-compact-blocks t
619 org-log-done 'time
620 org-log-into-drawer t)
621 (require 'org-habit)
622 (add-to-list 'org-modules 'org-habit)
623 (setq org-habit-show-habits t
624 org-habit-show-habits-only-for-today nil
625 org-habit-show-all-today nil
626 org-habit-graph-column 60
627 org-habit-following-days 1
628 org-habit-preceding-days 21)
629 :bind (("C-c a" . org-agenda-list)))
630
631
632;; Update agenda periodically every `mm/refresh-agenda-time-seconds' seconds.
633;; This was taken from https://emacs.stackexchange.com/a/68767/38877
634(defvar mm/refresh-agenda-time-seconds 15)
635(defvar mm/refresh-agenda-timer nil
636 "Timer for `mm/refresh-agenda-timer-function' to reschedule itself, or NIL")
637(defun mm/refresh-agenda-timer-function ()
638 "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'."
639 (when mm/refresh-agenda-timer
640 (cancel-timer mm/refresh-agenda-timer))
641 ;;(lambda () (save-window-excursion (org-agenda nil "a")))
642 (save-window-excursion (org-agenda nil "a"))
643 (setq mm/refresh-agenda-timer
644 (run-with-idle-timer
645 (time-add (current-idle-time) mm/refresh-agenda-time-seconds)
646 nil
647 'mm/refresh-agenda-timer-function)))
648(run-with-idle-timer mm/refresh-agenda-time-seconds t 'mm/refresh-agenda-timer-function)
649
650
447 651
448 652
449;; --------------------------------------------------------------------- 653;; ---------------------------------------------------------------------