diff options
author | Thomas F. K. Jorna <[email protected]> | 2022-09-27 16:32:13 +0200 |
---|---|---|
committer | GitHub <[email protected]> | 2022-09-27 16:32:13 +0200 |
commit | 6f783297f37e95d083b32a7160afcb55e309e883 (patch) | |
tree | af9fdc3db50ecbc61036d88c81eeea3703ff17cc /org-roam-ui.el | |
parent | 16a8da9e5107833032893bc4c0680b368ac423ac (diff) | |
parent | 1936250b99b8747d841edd83002ed20ec12aa793 (diff) |
feat: add ability to add/remove nodes to/from the local graph from emacs
Adds the commands `org-roam-ui-add-to-local-graph` and `org-roam-ui-remove-from-local-graph`
Diffstat (limited to 'org-roam-ui.el')
-rw-r--r-- | org-roam-ui.el | 24 |
1 files changed, 24 insertions, 0 deletions
diff --git a/org-roam-ui.el b/org-roam-ui.el index ce2eeec..e13349b 100644 --- a/org-roam-ui.el +++ b/org-roam-ui.el @@ -690,6 +690,30 @@ Optionally with ID (string), SPEED (number, ms) and PADDING (number, px)." (padding . ,padding)))))) (message "No node found."))) + +(defun org-roam-ui-change-local-graph (&optional id manipulation) + "Add or remove current node to the local graph. If not in local mode, open local-graph for this node." + (interactive) + (if-let ((node (or id (org-roam-id-at-point)))) + (websocket-send-text org-roam-ui-ws-socket + (json-encode `((type . "command") + (data . ((commandName . "change-local-graph") + (id . ,node) + (manipulation . ,(or manipulation "add"))))))) + (message "No node found."))) + +;;;###autoload +(defun org-roam-ui-add-to-local-graph (&optional id) + "Add current node to the local graph. If not in local mode, open local-graph for this node." + (interactive) + (org-roam-ui-change-local-graph id "add")) + +;;;###autoload +(defun org-roam-ui-remove-from-local-graph (&optional id) + "Remove current node from the local graph. If not in local mode, open local-graph for this node." + (interactive) + (org-roam-ui-change-local-graph id "remove")) + ;;;###autoload (defun org-roam-ui-sync-theme () "Sync your current Emacs theme with org-roam-ui." |