Update buffer on completion of backlink building

This commit is contained in:
Jethro Kuan
2020-02-03 12:01:13 +08:00
parent 70b430df29
commit f6436d29a2

View File

@ -150,7 +150,8 @@ Valid states are 'visible, 'exists and 'none."
(prin1-to-string backlinks))) (prin1-to-string backlinks)))
(lambda (backlinks) (lambda (backlinks)
(setq org-roam-hash-backlinks (car (read-from-string (setq org-roam-hash-backlinks (car (read-from-string
backlinks)))))) backlinks)))
(org-roam-update org-roam-current-file t))))
(defun org-roam-new-file-named (slug) (defun org-roam-new-file-named (slug)
"Create a new file named `SLUG'. "Create a new file named `SLUG'.
@ -168,9 +169,11 @@ Valid states are 'visible, 'exists and 'none."
(interactive) (interactive)
(org-roam-new-file-named (format-time-string "%Y-%m-%d" (current-time)))) (org-roam-new-file-named (format-time-string "%Y-%m-%d" (current-time))))
(defun org-roam-update (file) (defun org-roam-update (file &optional no-check)
"Show the backlinks for given org file `FILE'." "Show the backlinks for given org file `FILE'."
(unless (string= org-roam-current-file file) (setq org-roam-current-file file)
(unless (or no-check
(string= org-roam-current-file file))
(when org-roam-hash-backlinks (when org-roam-hash-backlinks
(let ((backlinks (gethash file org-roam-hash-backlinks))) (let ((backlinks (gethash file org-roam-hash-backlinks)))
(with-current-buffer org-roam-buffer (with-current-buffer org-roam-buffer
@ -186,8 +189,7 @@ Valid states are 'visible, 'exists and 'none."
(dolist (content contents) (dolist (content contents)
(insert (format "\n\n%s\n\n" content)))) (insert (format "\n\n%s\n\n" content))))
backlinks)) backlinks))
(read-only-mode +1))) (read-only-mode +1))))))
(setq org-roam-current-file file))))
(defun org-roam () (defun org-roam ()
"Initialize `org-roam'. "Initialize `org-roam'.