summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorDamien Pollet <[email protected]>2021-08-17 21:35:31 +0200
committerGitHub <[email protected]>2021-08-17 21:35:31 +0200
commit188210e37ca1fe4a776135424798da5073e35402 (patch)
treeee6891079d3c150b6102857b33fdc8127e23244d
parentbd31703d8627d3c8e046d62223a08d295f0e9578 (diff)
Extract org-roam-ui-open command from minor mode (#69)
* Extract org-roam-ui-open command from minor mode The new command allows reopening the web UI without toggling the whole mode off and on again. Eliminates hardcoded port in URL string, using org-roam-ui-port variable instead. IMHO a better distribution of responsibilities: - org-roam-ui-open opens the web UI (and that may require enabling the minor mode) - org-roam-ui-mode makes web service and websocket available * misc: change function prefix to orui Co-authored-by: Thomas F. K. Jorna <[email protected]>
-rw-r--r--org-roam-ui.el12
1 files changed, 9 insertions, 3 deletions
diff --git a/org-roam-ui.el b/org-roam-ui.el
index 98cf5a6..3bca5cd 100644
--- a/org-roam-ui.el
+++ b/org-roam-ui.el
@@ -158,8 +158,6 @@ This serves the web-build and API over HTTP."
(setq-local httpd-port org-roam-ui-port)
(setq httpd-root org-roam-ui/app-build-dir)
(httpd-start)
- (when org-roam-ui-open-on-start
- (funcall org-roam-ui-browser-function "http://localhost:35901"))
(setq org-roam-ui-ws
(websocket-server
35903
@@ -197,7 +195,8 @@ This serves the web-build and API over HTTP."
:on-close (lambda (_websocket)
(remove-hook 'after-save-hook #'org-roam-ui--on-save)
(org-roam-ui-follow-mode -1)
- (message "Connection with org-roam-ui closed.")))))
+ (message "Connection with org-roam-ui closed."))))
+ (when org-roam-ui-open-on-start (orui-open)))
(t
(progn
(websocket-server-close org-roam-ui-ws)
@@ -404,6 +403,13 @@ ROWS is the sql result, while COLUMN-NAMES is the columns to use."
;;;; commands
;;;###autoload
+(defun orui-open ()
+ "Ensure `org-roam-ui-mode' is enabled, then open the `org-roam-ui' webpage."
+ (interactive)
+ (or org-roam-ui-mode (org-roam-ui-mode))
+ (funcall org-roam-ui-browser-function (format "http://localhost:%d" org-roam-ui-port)))
+
+;;;###autoload
(defun orui-node-zoom (&optional id speed padding)
"Move the view of the graph to current node.
or optionally a node of your choosing.