GithubHelp home page GithubHelp logo

ob-clojure-literate-extras's Introduction

These few lines of Elisp simplify the testing of Clojure and ClojureScript libraries with Org Babel (ob-clojure.el).

Just load ob-clojure-literate-extras.el file with load-file and you will be able to run code blocks like these:

(require '[clojure.core.memoize :as m])

(def id (m/ttl
	 #(do (Thread/sleep 1000) (identity %))
	 :ttl/threshold 3000))

(defmacro time-ms [expr]
  `(let [start# (. System (nanoTime))]
     ~expr
     (/ (double (- (. System (nanoTime)) start#) ) (. Math (pow 10 6))))
  )

(time-ms (id 1))
(time-ms (id 1))

(Thread/sleep 3000)

(time-ms (id 1))
(ns example.core
  (:require-macros [cljs.core.async.macros :refer [go]])
  (:require [cljs-http.client :as http]
     [cljs.core.async :refer [<!]]))

(def result (atom {}))
(go (let [response (<! (http/get "https://api.github.com/users"
                                 {:with-credentials? false
                                  :query-params {"since" 135}}))]
      (swap! result #(conj %
                           [:status (:status response)]
                           [:login (map :login (:body response))]))))


@result

ob-clojure-literate-extras's People

Contributors

ag91 avatar

Stargazers

Burin avatar

Watchers

 avatar  avatar

ob-clojure-literate-extras's Issues

Error after loading and try to eval clojure code

From the readme, I try following the steps and kept getting the following error:

apply: Wrong number of arguments: (lambda (expanded params) "Evaluate EXPANDED code block with PARAMS using cider." (condition-case nil (require 'cider) (user-error "cider not available")) (let ((connection (cider-current-connection (cdr (assq :target params)))) (result-params (cdr (assq :result-params params))) result0) (if connection nil (let ((my/cider-extra-deps (alist-get :deps params))) (sesman-start-session 'CIDER))) (if (not connection) (setq result0 "Please reevaluate when nREPL is connected") (let ((temp-buffer (generate-new-buffer " *temp*" t))) (save-current-buffer (set-buffer temp-buffer) (unwind-protect (progn (insert expanded) (goto-char (point-min)) (while (not (looking-at "\\s-*\\'")) (let* (... ... ...) (sit-for 0.1) (let ... ...)))) (and (buffer-name temp-buffer) (kill-buffer temp-buffer))))) (ob-clojure-string-or-list (reverse (delete "" (mapcar #'(lambda (r) (replace-regexp-in-string "nil" "" ...)) result0))))))), 3

I am using Emacs 28.2 with Doom emacs.
Any idea that I may have missed?

Before these changes, I was able to evaluate the Clojure code with the following code block:

#+begin_src clojure
(+ 1 2)
#+end_src

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.