Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

SCI env improvements #357

Merged
merged 35 commits into from
Dec 22, 2022
Merged

SCI env improvements #357

merged 35 commits into from
Dec 22, 2022

Conversation

zampino
Copy link
Collaborator

@zampino zampino commented Dec 19, 2022

  • allow to require codemirror classes by their own name
  • expose namespaces from clojure-mode

@zampino
Copy link
Collaborator Author

zampino commented Dec 19, 2022

The following example consistently work, when building the render-fns step-by-step and using clerk/show! but fail when reloading the browser:

CleanShot 2022-12-19 at 19 21 37@2x

@zampino
Copy link
Collaborator Author

zampino commented Dec 19, 2022


(defmacro sci-copy-nss [& nss]
(into {} (for [[_ ns] nss]
[(list 'quote ns) `(sci.core/copy-ns ~ns (sci.core/create-ns '~ns))])))
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@borkdude any interest in getting such a convenience macro or something similar into sci?

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

or would it be possible to write this as a function if sci.core/copy-ns also accepted a quoted symbol as the first arg?

Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I don't intend to add this macro today since it hides the ability to pass in the result of sci/create-ns which can carry metadata etc.

You have to do this using a macro since sci.core/copy-ns is also a macro.

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

or if not a quoted symbol, maybe a namespace:

(into {}
      (map (fn [ns-sym] [ns-sym (sci.core/copy-ns (find-ns ns-sym) (sci.core/create-ns ns-sym))]))
      '[nextjournal.clerk.parser nextjournal.clerk.render])

@borkdude
Copy link
Collaborator

@zampino The errors probably have to do with non-top-level require and refer. Perhaps it works if you execute the require and usage of that require in two separate functions, but ultimately this is what eval-cljs-str was intended for.

@zampino
Copy link
Collaborator Author

zampino commented Dec 20, 2022

non-top-level require

I see. But also using requires in a separate render-fns doesn't survive a page reload:

CleanShot 2022-12-20 at 08 49 08@2x

@zampino
Copy link
Collaborator Author

zampino commented Dec 20, 2022

this is what eval-cljs-str was intended for.

yeah, that works

CleanShot 2022-12-20 at 08 56 24@2x

@mk mk marked this pull request as ready for review December 22, 2022 09:30
@mk mk merged commit 16a5c55 into main Dec 22, 2022
@mk mk deleted the sci-env-pass branch December 22, 2022 09:30
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants