summaryrefslogtreecommitdiff
path: root/org-roam-ui.el
diff options
context:
space:
mode:
authorThomas F. K. Jorna <[email protected]>2022-09-27 16:13:44 +0200
committerThomas F. K. Jorna <[email protected]>2022-09-27 16:13:44 +0200
commitc4a9897fa15e6c576d26849f54daba4a4bc665a6 (patch)
treebbb3efac1f3098a7a99d9d735a7ac7fd03e980a7 /org-roam-ui.el
parentfb26ac08618339f113749ea85c88ea69d255402b (diff)
feat: add/remove note to local graph from emacs
Diffstat (limited to 'org-roam-ui.el')
-rw-r--r--org-roam-ui.el24
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."