Merge pull request #45 from jethrokuan/fix/check-cache
Add org-roam--ensure-cache-built
This commit is contained in:
commit
6f1938e1ac
1 changed files with 34 additions and 27 deletions
11
org-roam.el
11
org-roam.el
|
@ -99,6 +99,12 @@ If called interactively, then PARENTS is non-nil."
|
|||
"Currently displayed file in `org-roam' buffer.")
|
||||
|
||||
;;; Utilities
|
||||
(defun org-roam--ensure-cache-built ()
|
||||
"Ensures that org-roam cache is built."
|
||||
(unless org-roam-cache
|
||||
(org-roam--build-cache-async)
|
||||
(user-error "Your Org-Roam cache isn't built yet! Please wait")))
|
||||
|
||||
(defun org-roam--org-roam-file-p ()
|
||||
"Return t if file is part of org-roam system, false otherwise."
|
||||
(and (buffer-file-name (current-buffer))
|
||||
|
@ -460,7 +466,7 @@ This is equivalent to removing the node from the graph."
|
|||
|
||||
(defun org-roam-update (file-path)
|
||||
"Show the backlinks for given org file for file at `FILE-PATH'."
|
||||
(when org-roam-cache
|
||||
(org-roam--ensure-cache-built)
|
||||
(let ((buffer-title (org-roam--get-title-or-id file-path)))
|
||||
(with-current-buffer org-roam-buffer
|
||||
(let ((inhibit-read-only t))
|
||||
|
@ -486,7 +492,7 @@ This is equivalent to removing the node from the graph."
|
|||
backlinks))
|
||||
(insert "\n\n* No backlinks!")))
|
||||
(read-only-mode 1)))
|
||||
(setq org-roam-current-file file-path)))
|
||||
(setq org-roam-current-file file-path))
|
||||
|
||||
;;; Show/hide the org-roam buffer
|
||||
(define-inline org-roam--current-visibility ()
|
||||
|
@ -575,6 +581,7 @@ This needs to be quick/infrequent, because this is run at
|
|||
;;; Building the Graphviz graph
|
||||
(defun org-roam-build-graph ()
|
||||
"Build graphviz graph output."
|
||||
(org-roam--ensure-cache-built)
|
||||
(let ((forward-links (plist-get org-roam-cache :forward)))
|
||||
(with-temp-buffer
|
||||
(insert "digraph {\n")
|
||||
|
|
Loading…
Reference in a new issue