(ehancement): Improve org-roam-graph (#559)

Allow showing/building the whole graph from any buffer.
Allow programatically specifying connected component path.
This commit is contained in:
N V 2020-05-03 18:03:02 -04:00 committed by GitHub
parent 69d4f05a13
commit 1bbfb0cdc9
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23

View file

@ -271,15 +271,16 @@ ARG may be any of the following values:
- `\\[universal-argument]' - build the graph for FILE.
- `\\[universal-argument]' -N build the graph for FILE limiting nodes to N steps."
(interactive "P")
(let ((file (or file (buffer-file-name))))
(unless file
(user-error "Cannot build graph for nil file. Is current buffer visiting a file?"))
(unless (org-roam--org-roam-file-p file)
(user-error "\"%s\" is not an org-roam file" file))
(let ((file (or file (buffer-file-name (buffer-base-buffer)))))
(unless (or (not arg) (equal arg '(16)))
(unless file
(user-error "Cannot build graph for nil file. Is current buffer visiting a file?"))
(unless (org-roam--org-roam-file-p file)
(user-error "\"%s\" is not an org-roam file" file)))
(pcase arg
('nil (org-roam-graph--open (org-roam-graph--build node-query)))
('(4) (org-roam-graph--open (org-roam-graph--build-connected-component file)))
((pred integerp) (let ((graph (org-roam-graph--build-connected-component (buffer-file-name) (abs arg))))
((pred integerp) (let ((graph (org-roam-graph--build-connected-component file (abs arg))))
(when (>= arg 0)
(org-roam-graph--open graph))))
('(16) (org-roam-graph--build node-query))