This page is not created by, affiliated with, or supported by Slack Technologies, Inc.
2023-09-27
Channels
- # announcements (1)
- # asami (10)
- # babashka (12)
- # beginners (26)
- # biff (4)
- # calva (42)
- # cider (1)
- # clj-commons (2)
- # cljs-dev (2)
- # clojure (179)
- # clojure-dev (2)
- # clojure-europe (45)
- # clojure-norway (16)
- # clojure-uk (3)
- # clojurescript (5)
- # datahike (1)
- # datascript (2)
- # events (3)
- # exercism (1)
- # fulcro (13)
- # funcool (3)
- # graalvm (23)
- # helix (3)
- # honeysql (1)
- # hyperfiddle (3)
- # lsp (51)
- # malli (2)
- # off-topic (27)
- # portal (18)
- # reagent (3)
- # reitit (3)
- # releases (8)
- # sci (5)
- # shadow-cljs (11)
- # xtdb (5)
I have Emacs 29.1 compiled with xwidgets support - but launching portal with (portal/open {:launcher :emacs})
doesn't seem to do anything - any idea how to debug this? Nothing in *Messages*
buffer as far as I can see
The implementation looks like
(defmethod browser/-open :emacs [{:keys [portal server]}]
(let [url (str "http://" (:host server) ":" (:port server) "?" (:session-id portal))]
(sh "emacsclient" "--no-wait" "--eval"
(str "(xwidget-webkit-browse-url " (pr-str url) ")"))))
Interesting - let me dig through it. Does portal have some sort of debug-level logging? I noticed yesterday when I was trying it out for the first time - it wouldn't launch in Chrome because... I never use Chrome, so the profiles were not setup there, so the browser would crash with no feedback sent back to Portal.
No, unfortunately no debug logging, although shell calls should print out stuff if there are errors https://github.com/djblue/portal/blob/master/src/portal/runtime/shell.cljc#L8-L12
Ah, I see what's up - I don't run emacs server. I suppose I can hack around it and start the webserver on a known port and then pass that to xwdigets-browse-url
somehow
@U1G869VNV last question (for now 😉 ) - any reason why host and port are not included in the data returned by (portal.api/sessions)
? Or is there a way to find host + port for session ID? With that it would be easy to do something like:
• (portal/open {:some :opt}) #> {:session-id ... :host ... :port ... }
• write the URL to a file
• make Emacs read it and launch the browser
I use Monroe nREPL client so it's all nicely doable from there.
Ohh, I think you want to do this then
(portal.api/url (portal.api/open {:launcher false}))
I think the main reason a host + port aren't included is that they can change independently of a session
https://cljdoc.org/d/djblue/portal/0.48.0/doc/editors/emacs would be a good place to add any discoveries if you would like 👌
Was easier than expected, at least the quick and dirty version:
(defun lk/monroe-portal ()
(interactive)
;; initiate portal session
(let* ((project-root (projectile-acquire-root))
(default-directory project-root)
(portal-url-file (format "%s.portal-url" project-root)))
(monroe-input-sender
(get-buffer-process (monroe-repl-buffer))
(format "(require 'portal.api) (spit \"%s\" (portal.api/url (portal.api/open {:launcher false})))"
portal-url-file))
(sleep-for 1) ;; uh... this is a hack
(let ((url (with-temp-buffer
(insert-file-contents portal-url-file)
(buffer-string))))
(xwidget-webkit-browse-url url))))
I'm curious if the nrepl client can return the value directly, is there a reason a file is required?
Good point, I'll dig into that when I have some more time later this week - if I find a way, I'll update the docs pull request. I remember looking into this a while back (for different reasons) and I think Monroe can only print back to the REPL buffer - unless I drop down to the nrepl protocol and do it there I suppose.
I wonder if https://github.com/sanel/monroe/blob/master/monroe.el#L247C8-L254 might work better. I assume the callback is called after a value is returned :thinking_face: