Merge pull request #19 from jethrokuan/feat/org-roam-find-file

Add function org-roam-find-file
This commit is contained in:
Jethro Kuan
2020-02-06 16:15:45 +08:00
committed by GitHub
2 changed files with 14 additions and 3 deletions

View File

@ -60,10 +60,11 @@ package manager.
(use-package org-roam
:after deft org
:hook (org-mode . org-roam-mode)
:straight (:host "github" :repo "jethrokuan/org-roam")
:straight (:host github :repo "jethrokuan/org-roam")
:bind
("C-c n l" . org-roam)
("C-c n t" . org-roam-today)
("C-c n f" . org-roam-find-file)
("C-c n i" . org-roam-insert)
("C-c n g" . org-roam-show-graph))
```

View File

@ -104,7 +104,7 @@ Valid states are 'visible, 'exists and 'none."
(file-truename org-roam-directory))))
(defun org-roam-insert (id)
"Find file `FILE-NAME', insert it as a link with the base file name as the link name."
"Find `ID', and insert a relative org link to it at point."
(interactive (list (completing-read "File: "
(mapcar #'org-roam--get-id
(org-roam--find-all-files)))))
@ -115,6 +115,16 @@ Valid states are 'visible, 'exists and 'none."
(concat "file:" file-path)
(concat org-roam-zettel-indicator id)))))
(defun org-roam-find-file (id)
"Find and open file with id `ID'."
(interactive (list (completing-read "File: "
(mapcar #'org-roam--get-id
(org-roam--find-all-files)))))
(let ((file-path (org-roam--get-file-path id)))
(unless (file-exists-p file-path)
(make-empty-file file-path))
(find-file file-path)))
(defun org-roam--build-cache-async ()
"Builds the cache asychronously, saving it into `org-roam-cache'."
(interactive)