I showed you my source code, pls respond
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
 
 
 

5.4 KiB

Roam

Plain-text knowledge management system.

Setup

Make sure sqlite is available on your system:

RUN apt install sqlite

Config

Configure org-roam, a plain-text knowledge management system for Emacs built on top of org-mode. Here's a quick recap of the main principles:

  • Notes can be arbitrarily referened

  • Contexts created by linking topics and notes

(use-package org-roam
  :hook (after-init . org-roam-mode) ;; Lauch roam at startup, big performance cost.
  :custom (org-roam-encrypt-files t) ;; Encrypt all roam captures.
          (org-roam-directory org-directory)
          (org-roam-capture-templates '())
          (org-roam-dailies-capture-templates '()))

Files

The default behaviour of org-roam when creating a title slug is to replace any non alpha numerical (whitespace) to _. I wanted to change this to use _ and have done so here in my own definition. The only substantial difference from the original definition is the character used.

  • Define a new title-to-slug function

  • Override org-roam-title-to-slug-function

(with-eval-after-load 'org-roam
  (require 'cl-lib)
  (defun dotfiles/title-to-slug (title)
    "Convert TITLE to a filename-suitable slug."
    (cl-flet* ((nonspacing-mark-p (char)
                                  (eq 'Mn (get-char-code-property char 'general-category)))
               (strip-nonspacing-marks (s)
                                       (apply #'string (seq-remove #'nonspacing-mark-p
                                                                   (ucs-normalize-NFD-string s))))
               (cl-replace (title pair)
                           (replace-regexp-in-string (car pair) (cdr pair) title)))
      (let* ((pairs `(("[^[:alnum:][:digit:]]" . "-") ;; Convert anything not alphanumeric.
                      ("--*" . "-")                   ;; Remove sequential dashes.
                      ("^-" . "")                     ;; Remove starting dashes.
                      ("-$" . "")))                   ;; Remove ending dashes.
             (slug (-reduce-from #'cl-replace (strip-nonspacing-marks title) pairs)))
        (downcase slug))))
  (setq org-roam-title-to-slug-function #'dotfiles/title-to-slug))

Visualizer

Use the org-roam-server web application to visualize the org-roam database. It's available whenever the editor is running at http://localhost:8080.

(use-package org-roam-server
  :after org-roam
  :hook (org-roam-mode . org-roam-server-mode))

Dailies

Use the daily note feature of org-roam to capture daily notes. Create the default capture template with some preconfigured headers.

(with-eval-after-load 'org-roam
  (add-to-list 'org-roam-dailies-capture-templates
    '("d" "Default" entry (function org-roam-capture--get-point)
             "* %?"
             :file-name "docs/daily/%<%Y-%m-%d>"
             :head
"
,#+TITLE: %<%Y-%m-%d>
,#+AUTHOR: Christopher James Hayward

,#+OPTIONS: num:nil toc:nil todo:nil tasks:nil tags:nil
,#+OPTIONS: skip:nil author:nil email:nil creator:nil timestamp:nil
")))

Templates

Collection of capture templates for various contexts. Here is one for a generic document.

(with-eval-after-load 'org-roam
  (add-to-list 'org-roam-capture-templates
    '("d" "Default" entry (function org-roam-capture--get-point)
          "%?"
          :file-name "docs/${slug}"
          :unnarrowed t
          :head 
"
,#+TITLE: ${title}
,#+AUTHOR: Christopher James Hayward
,#+EMAIL: chris@chrishayward.xyz
")))

Course

Capture template for a new course. Capture with SPC r c c.

(with-eval-after-load 'org-roam
  (add-to-list 'org-roam-capture-templates
    '("c" "Course" plain (function org-roam-capture--get-point)
          "%?"
          :file-name "docs/courses/${slug}"
          :unnarrowed t
          :head
"
,#+TITLE: ${title}
,#+SUBTITLE:
,#+AUTHOR: Christopher James Hayward
,#+EMAIL: chris@chrishayward.xyz

,#+OPTIONS: num:nil toc:nil todo:nil tasks:nil tags:nil
,#+OPTIONS: skip:nil author:nil email:nil creator:nil timestamp:nil
")))

Shortcuts

Configure custom keybindings for org-roam behind SPC r:

  • Find with f

  • Insert with i

  • Buffer with b

  • Capture with c

(dotfiles/leader
  "r"  '(:ignore t :which-key "Roam")
  "ri" '(org-roam-insert :which-key "Insert")
  "rf" '(org-roam-find-file :which-key "Find")
  "rc" '(org-roam-capture :which-key "Capture")
  "rb" '(org-roam-buffer-toggle-display :which-key "Buffer"))

Place keybindings for daily notes behind SPC r d:

  • Date with d

  • Today with t

  • Tomorrow with m

  • Yesterday with y

(dotfiles/leader
  "rd" '(:ignore t :which-key "Dailies")
  "rdd" '(org-roam-dailies-find-date :which-key "Date")
  "rdt" '(org-roam-dailies-find-today :which-key "Today")
  "rdm" '(org-roam-dailies-find-tomorrow :which-key "Tomorrow")
  "rdy" '(org-roam-dailies-find-yesterday :which-key "Yesterday"))

Footnotes