Fork me on GitHub
#portal
<
2022-02-15
>
Carlo13:02:03

hey, I'm finally ready to try portal, and I have two questions: 1. I usually start my workflow by doing cider-jack-in-clj in a deps.edn project. The way I should use portal is including it in deps.edn and then use the API to open one, right? (I ask because the readme gives instructions to fire up a standalone repl, but maybe I should use the cider one? 2. Is there a way of changing the keybindings for some of the portal UI shortcuts? It doesn't seems so for now.

rfhayashi15:02:59

If you have portal in deps.edn you can either start the repl from cider or externally. If you don't want to add portal to every project, you can also create an alias containing portal in your ~/.clojure/deps.edn file and set cider-clojure-cli-global-options to "-M:your-alias" and in that case you need to start the repl from cider (or remember to add the alias when firing the standalone repl).

πŸ™Œ 1
Carlo16:02:21

Is there a way to call the portal.ui.commands commands from emacs itself? That way I wouldn't need more shortcuts because I can just script the behavior via emacs (and that would allow me to never move focus)

user=>   (require '[portal.ui.commands :as ui])
Execution error (FileNotFoundException) at user/eval2242 (REPL:1).
Could not locate portal/ui/commands__init.class, portal/ui/commands.clj or portal/ui/commands.cljc on classpath.
edit: maybe I wasn't clear, sorry, I'll rephrase; we can already do something like:
(defun portal.api/open ()
  (interactive)
  (cider-nrepl-sync-request:eval
   "(require 'portal.api) (portal.api/tap) (portal.api/open)"))
to open a portal window from emacs. It would be cool if I could just call, via cider-nrepl-sync-request:eval, portal.ui.commands/select-next (bound to a key in emacs) and see the portal UI change focus.

1
seancorfield16:02:58

Looks like you didn't have Portal on the classpath used when starting that REPL.

Carlo16:02:57

I see, I did start the repl with:

$ clj -Sdeps '{:deps {djblue/portal {:mvn/version "0.20.1"}}}'
and I though that gave me access to all of portal. What am I missing?

seancorfield16:02:15

Oh, I misread the require. Yeah, that part is in the ClojureScript frontend of Portal. There is a way to run commands... let me dig that up...

seancorfield16:02:05

Ah, I think you can only do things exposed through portal.api...

seancorfield16:02:17

...and that's pretty limited, as I recall.

seancorfield16:02:15

I have a key bound to evaluate (portal.api/clear) for example but I don't think much of the navigation is exposed yet?

seancorfield16:02:14

Oh, you can use (portal.api/eval-str "...") to evaluate strings in the cljs UI -- that'll do what you need I think

Carlo16:02:29

let me try 😍

Carlo16:02:16

what's wrong with:

(portal.api/eval-str "(do (require 'portal.ui.commands) (portal.ui.commands/select-parent))")

Carlo16:02:30

it returns nil but doesn't change the UI

Carlo16:02:05

even (portal.api/eval-str "(+ 3 3)") has the same behavior

seancorfield16:02:59

No idea. I've never tried eval-str -- I think it was a recent addition? @djblue?

πŸ™Œ 1
djblue16:02:15

So eval-str is the correct path, however the main issue is I can't seem to access the the reagent atom via sci :thinking_face:

djblue16:02:07

(portal.api/eval-str "(do (require 'portal.ui.commands) (portal.ui.commands/select-parent portal.ui.state/state))")
Is more like it. I'll look into why this doesn't want to work.

πŸ™Œ 1
djblue03:02:19

@UA7E6DU04 I think the latest release https://github.com/djblue/portal/releases/tag/0.21.0 should allow you to control the Portal UI via emacs πŸ™Œ

djblue03:02:52

The code above should work as expected πŸ‘Œ

Carlo23:02:27

This is awesome @djblue! Your last command surely works for me the first time, but if I try to do it two times in a row, nothing happens and then I get Portal request timeout

djblue23:02:51

Try:

(portal.api/eval-str "(portal.ui.commands/select-parent portal.ui.state/state)")
instead

Carlo00:02:32

I still get the Portal request timeout , unfortunately. Does it work locally for you?

djblue00:02:45

Yup, just did it again to make sure :thinking_face:

djblue00:02:07

Are you using the latest version?

Carlo00:02:16

yes, {djblue/portal {:mvn/version "0.21.1"}}

1
Carlo00:02:07

user=> (portal.api/eval-str "(portal.ui.commands/select-parent portal.ui.state/state)")

Execution error (ExceptionInfo) at portal.runtime.jvm.client/request (client.clj:53).
Portal request timeout
I'm on linux (nixOS) if this might help

Carlo00:02:34

it's the same result both in the cli and via emacs

djblue00:02:44

I've been using my local dev version, but can reproduce when I switch to the production build :thumbsup:

πŸ™Œ 1
djblue00:02:53

@UA7E6DU04 I have another https://github.com/djblue/portal/runs/5225480116?check_suite_focus=true going out that should fix this

πŸ™Œ 1
😍 1
πŸ₯³ 1
Carlo01:02:50

just tried, but it's still the same for me 😒

Carlo01:02:34

oh no wait I'm dumb

Carlo01:02:37

it works perfectly πŸ₯³ πŸ₯³ πŸ₯³ πŸ₯³

djblue01:02:00

Awesome, thanks for testing it out! πŸŽ‰

Benjamin C05:04:12

@UA7E6DU04 If it is alright with you, I would be very interested in seeing your emacs config. Sounds like you'd have a lot of the things configured that I've been wanting to do!

Benjamin C05:04:27

(And haven't yet justified the time to configure.) I'm pretty overdue for a "sharpening the axe" session with emacs.

Carlo13:04:28

sure, I'll share as I go back to my desktop ☺️

Benjamin C03:04:29

Looking forward to it πŸ™‚

Carlo11:04:03

πŸ™Œ 1
Carlo11:04:19

Ok, sorry for the delay, here we are ^: this is my newest config.el (I use doom emacs). I distilled it down from a more bloated config.el which I was a bit unsatisfied about. Also this new is almost entirely clojure-related, so that's a plus

Benjamin C18:04:07

Thank you! πŸ˜„ I use doom also.

πŸ™Œ 1