2021-10-17 20:01:45 +02:00
|
|
|
:PROPERTIES:
|
|
|
|
:ID: 18476d68-cccb-48f4-aa77-caefe213d8bd
|
|
|
|
:END:
|
|
|
|
#+title: Org Roam
|
|
|
|
#+filetags: emacs-load
|
|
|
|
|
2022-07-31 11:03:59 +02:00
|
|
|
# SPDX-FileCopyrightText: 2022 Richard Brežák <richard@brezak.sk>
|
|
|
|
#
|
|
|
|
# SPDX-License-Identifier: LGPL-3.0-or-later
|
|
|
|
|
2021-10-21 00:33:25 +02:00
|
|
|
#+BEGIN_NOTE
|
|
|
|
When exporting, running ~(org-id-update-id-locations (directory-files-recursively org-roam-directory ".org"))~
|
|
|
|
#+END_NOTE
|
|
|
|
|
|
|
|
#+BEGIN_SRC emacs-lisp :tangle no :results none
|
|
|
|
(defun replace-in-string (what with in)
|
|
|
|
(replace-regexp-in-string (regexp-quote what) with in nil 'literal))
|
|
|
|
|
|
|
|
(defun org-html--format-image (source attributes info)
|
|
|
|
(progn
|
|
|
|
(setq source (replace-in-string "%20" " " source))
|
|
|
|
(format "<img src=\"data:image/%s+xml;base64,%s\"%s />"
|
|
|
|
(or (file-name-extension source) "")
|
|
|
|
(base64-encode-string
|
|
|
|
(with-temp-buffer
|
|
|
|
(insert-file-contents-literally source)
|
|
|
|
(buffer-string)))
|
|
|
|
(file-name-nondirectory source))))
|
|
|
|
#+END_SRC
|
2021-10-17 20:01:45 +02:00
|
|
|
|
|
|
|
#+BEGIN_QUOTE
|
|
|
|
Org-roam is a plain-text knowledge management system. It brings some of Roam's more powerful features into the Org-mode ecosystem.
|
|
|
|
#+END_QUOTE
|
|
|
|
|
|
|
|
#+BEGIN_WARNING
|
|
|
|
SQLite3 must be on Emacs' PATH!
|
|
|
|
#+END_WARNING
|
|
|
|
|
|
|
|
#+BEGIN_SRC emacs-lisp :results none
|
|
|
|
(use-package org-roam
|
2022-08-29 22:19:10 +02:00
|
|
|
:straight
|
|
|
|
(org-roam
|
|
|
|
:type git
|
|
|
|
:host github
|
|
|
|
:repo "org-roam/org-roam"
|
|
|
|
:branch "main")
|
2021-10-17 20:01:45 +02:00
|
|
|
:init
|
|
|
|
(setq org-roam-v2-ack t)
|
|
|
|
:config
|
|
|
|
(add-hook 'after-init-hook 'org-roam-setup)
|
2022-03-12 23:06:42 +01:00
|
|
|
|
2021-10-29 12:54:28 +02:00
|
|
|
;; Add ignore for SyncThing
|
|
|
|
(setq org-roam-file-exclude-regexp "\\.stversions")
|
|
|
|
|
2021-10-17 20:01:45 +02:00
|
|
|
(setq org-roam-directory "~/roam")
|
2022-05-23 08:31:53 +02:00
|
|
|
;; Add more informative completion interface
|
2022-06-07 17:08:31 +02:00
|
|
|
(setq org-roam-node-display-template (concat "${title:*} " (propertize "${tags:30}" 'face 'org-tag)))
|
2022-03-12 23:06:42 +01:00
|
|
|
|
|
|
|
(defun magic_rb/org-roam-buffer-hook ()
|
|
|
|
(when (org-roam-buffer-p)
|
|
|
|
(make-local-variable 'org-link-frame-setup)
|
|
|
|
(add-to-list 'org-link-frame-setup '(file . find-file))))
|
|
|
|
(add-hook 'org-mode-hook 'magic_rb/org-roam-buffer-hook)
|
|
|
|
|
|
|
|
(defun magic_rb/org-roam-hook ()
|
|
|
|
(visual-line-mode))
|
|
|
|
(add-hook 'org-roam-mode-hook 'magic_rb/org-roam-hook))
|
|
|
|
|
|
|
|
(use-package shackle
|
|
|
|
:straight t
|
|
|
|
:init
|
|
|
|
(shackle-mode))
|
|
|
|
|
2022-08-29 22:19:10 +02:00
|
|
|
(setq shackle-rules
|
|
|
|
'((org-roam-mode
|
|
|
|
:align right
|
|
|
|
:size 0.25
|
|
|
|
:popup t)))
|
2021-10-17 20:01:45 +02:00
|
|
|
#+END_SRC
|
|
|
|
|
|
|
|
* Ref Capture
|
|
|
|
|
|
|
|
Using ~org-protocol~, one can capture a website from their browser directly into Org Roam.
|
|
|
|
|
2022-08-29 22:19:10 +02:00
|
|
|
#+BEGIN_SRC emacs-lisp :tangle no
|
2021-10-17 20:01:45 +02:00
|
|
|
(with-eval-after-load "org-roam"
|
|
|
|
(require 'org-roam-protocol)
|
|
|
|
(setq org-roam-capture-ref-templates
|
|
|
|
`(("r" "ref" plain "%?"
|
|
|
|
:target (file+head "%<%Y%m%d%H%M%S>-${slug}.org" "#+title: ${title}\n\n${body}")
|
|
|
|
:unnarrowed t))))
|
|
|
|
#+END_SRC
|
|
|
|
|
|
|
|
Then you need a desktop entry for ~org-protocol~. Such as:
|
|
|
|
|
2022-07-31 11:03:59 +02:00
|
|
|
#+BEGIN_SRC conf-desktop
|
2021-10-17 20:01:45 +02:00
|
|
|
[Desktop Entry]
|
|
|
|
Name=org-protocol
|
|
|
|
Exec=emacsclient %u
|
|
|
|
Type=Application
|
|
|
|
Terminal=false
|
|
|
|
Categories=System;
|
|
|
|
MimeType=x-scheme-handler/org-protocol;
|
|
|
|
#+END_SRC
|
|
|
|
|
|
|
|
or in Nix form:
|
|
|
|
|
|
|
|
#+BEGIN_SRC nix
|
|
|
|
makeDesktopItem {
|
|
|
|
name = "Org-Protocol";
|
|
|
|
exec = "emacsclient %u";
|
|
|
|
comment = "Org protocol";
|
|
|
|
desktopName = "org-protocol";
|
|
|
|
type = "Application";
|
|
|
|
mimeType = "x-scheme-handler/org-protocol";
|
|
|
|
}
|
|
|
|
#+END_SRC
|
|
|
|
|
|
|
|
Lastly a bookmarklet in Firefox.
|
|
|
|
|
|
|
|
#+BEGIN_SRC javascript
|
2022-08-29 22:19:10 +02:00
|
|
|
javascript:location.href ='org-protocol://roam-ref?template=rw&ref=' + encodeURIComponent(location.href) + '&title=' + encodeURIComponent(document.title) + '&body=' + encodeURIComponent(window.getSelection())
|
2021-10-17 20:01:45 +02:00
|
|
|
#+END_SRC
|
2022-06-07 17:08:31 +02:00
|
|
|
|
|
|
|
* Export
|
|
|
|
#+begin_src emacs-lisp :tangle no :results none
|
|
|
|
(require 'org-roam-export)
|
|
|
|
|
|
|
|
(setq org-publish-project-alist
|
|
|
|
'(("org"
|
|
|
|
:base-directory "~/roam/"
|
|
|
|
:publishing-function org-html-publish-to-html
|
|
|
|
:publishing-directory "~/roam/published"
|
|
|
|
:section-numbers nil
|
|
|
|
:with-toc t
|
|
|
|
)))
|
|
|
|
|
|
|
|
(org-publish "org" t)
|
|
|
|
#+end_src
|