Initial extract

This commit is contained in:
Jethro Kuan
2020-01-05 17:04:37 +08:00
commit 393ceea575
2 changed files with 41 additions and 0 deletions

14
README.org Normal file
View File

@ -0,0 +1,14 @@
* Org-roam
Rudimentary Roam replica in org-mode. Dependent on deft being setup properly.
** Usage
#+begin_src emacs-lisp
(use-package org-roam
:after deft org
:straight (:host "github" :repo "jethrokuan/org-roam")
:bind
("C-c n l" . org-roam-get-linked-files)
("C-c n i" . org-roam-insert))
#+end_src

27
org-roam.el Normal file
View File

@ -0,0 +1,27 @@
(require 'deft)
(defcustom org-roam-zettel-indicator "§"
"Indicator in front of a zettel.")
(defun org-roam-insert (file-name)
"Finds a file, inserts it as a link with the base file name as the link name, and adds the zd-link-indicator I use to the front."
(interactive (list (completing-read "File: " (deft-find-all-files-no-prefix))))
(let ((org-link-file-type 'relative))
(org-insert-link nil (concat "file:" (concat deft-directory file-name))
(concat org-roam-zettel-indicator (file-name-base file-name)))))
(defun org-roam-get-linked-files ()
"Show links to this file."
(interactive)
(let* ((search-term (file-name-nondirectory buffer-file-name))
(files deft-all-files)
(tnames (mapcar #'file-truename files)))
(multi-occur
(mapcar (lambda (x)
(with-current-buffer
(or (get-file-buffer x) (find-file-noselect x))
(widen)
(current-buffer)))
files)
search-term
3)))