clojure

Running Clojure and other Lisp at the same time on Emacs

风格不统一 提交于 2019-12-18 13:30:49
问题 I use Aquamacs, and Aquamacs is pre-equipped with SLIME. (setq inferior-lisp-program "/usr/local/bin/sbcl") #####!!! (add-to-list 'load-path "/Library/Application Support/Aquamacs Emacs/SLIME/contrib") (add-to-list 'load-path "/Library/Application Support/Aquamacs Emacs/SLIME") (require 'slime) (slime-setup) As is asked in somewhere, I try to use Clojure by adding this code. (add-to-list 'load-path "~/clojure/clojure-mode") (setq inferior-lisp-program "/Users/smcho/bin/clj") ################

How can you dump contents of Clojure REPL to a file?

六眼飞鱼酱① 提交于 2019-12-18 13:16:31
问题 So I have been working on a Clojure tutorial and it's pretty fun so far. Unfortunately, every time I close my REPL out, I lose all of the defn and def that I created in the previous session. So, to save time in the future, is it possible to have the Clojure REPL save everything I've typed to a file so I can dig out what I need for future uses? 回答1: I think most people work by using their IDE to send fragments of code to the REPL, rather than doing a lot of direct hacking in the REPL. This way

Mac OSX, Emacs 24.2 and nrepl.el not working

南笙酒味 提交于 2019-12-18 13:13:25
问题 I'm using nrepl.el, Emacs 24.2. My S.O version is OS X Lion 10.7.5. Running the command [M-x] nrepl after start a REPL session through lein (:~ $ lein repl) i am able to connect to it but if i try to use [M-x] nrepl-jack-in i get the message bellow: error in process sentinel: Could not start nREPL server: /bin/bash: lein: command not found I installed leiningen using the instructions in the main site and reinstalled it using homebrew with the command brew install leiningen --devel but both

Why Does Clojure Use the Context Classloader by Default?

时光总嘲笑我的痴心妄想 提交于 2019-12-18 12:53:03
问题 Why is use-context-classloader set to true by default? Why doesn't Clojure use the current class loader? 回答1: you can override its behavior by setting clojure.lang.Compiler.LOADER to the class loader ie. final ClassLoader ccl= ClojurePlugin.class.getClassLoader(); clojure.lang.Var.pushThreadBindings(clojure.lang.RT.map( clojure.lang.Compiler.LOADER, ccl) ); try { ... clojure.lang.RT.loadResourceScript( cljFile ); ... }finally{ clojure.lang.RT.popThreadBindings(); } where ClojurePlugin is your

Clojure REPL readline like support

放肆的年华 提交于 2019-12-18 12:47:19
问题 Several REPLs (like ruby's irb ) have some very useful features, such as using the arrow keys to "rewind" and "forward" the command history; but when I try to do the same with Clojure, it only prints garbage (I suspect it prints the keycode). How can I get this feature in the Clojure REPL? 回答1: You need to use JLine or rlwrap . Refer to http://en.wikibooks.org/wiki/Clojure_Programming/Getting_Started#Enhancing_the_Environment for assistance 回答2: Download jline from here and copy the jar to

How to install Clojure on Ubuntu 10.04 from Github repo with no clojure.jar

半腔热情 提交于 2019-12-18 12:37:30
问题 I've been trying to install Clojure on my computer to learn and use. I'm running Ubuntu 10.04, and have installed the latest Sun Java SDK and environment from Synaptic. Searching with Google, I found multiple guides that give pretty clear guides on how to go about installing all the dependencies and useful tools and builders like ant, maven, leiningen, and emacs with SLIME. Some of the guides are a bit dated, especially considering how fast Clojure development moves, so I searched for the

In Lisp (Clojure, Emacs Lisp), what is the difference between list and quote?

烈酒焚心 提交于 2019-12-18 12:07:32
问题 From reading introductory material on Lisp, I now consider the following to be identical: (list 1 2 3) '(1 2 3) However, judging from problems I face when using the quoted form in both Clojure and Emacs Lisp, they are not the same. Can you tell me what the difference is? 回答1: The primary difference is that quote prevents evaluation of the elements, whereas list does not: user=> '(1 2 (+ 1 2)) (1 2 (+ 1 2)) user=> (list 1 2 (+ 1 2)) (1 2 3) For this reason (among others), it is idiomatic

Using a javax.servlet.Filter with Compojure

假如想象 提交于 2019-12-18 11:59:25
问题 I'm trying to build a simple web site using Clojure / Compojure and want to feed apply a servlet filter to the request / response (i.e. a standard javax.servlet.Filter instance). e.g. if the current source code is: (defroutes my-app (GET "/*" (html [:h1 "Hello Foo!!"])) ) I would like to add a filter like this: (defroutes my-app (GET "/*" (FILTER my-filter-name (html [:h1 "Hello Foo!!"]))) ) Where my-filter-name is some arbitrary instance of javax.servlet.Filter. Any idea how to do this

clojure.java.jdbc/query large resultset lazily

巧了我就是萌 提交于 2019-12-18 11:56:03
问题 I'm trying to read millions of rows from a database and write to a text file. This is a continuation of my question database dump to text file with side effects My problem now seems to be that the logging doesn't happen until the program completes. Another indicator that i'm not processing lazily is that the text file isn't written at all until the program finishes. Based on an IRC tip it seems my issue is likely having to do with :result-set-fn and defaulting to doall in the clojure.java

How to get runtime access to version number of a running Clojure application?

走远了吗. 提交于 2019-12-18 11:48:01
问题 I have a web service written in Clojure which is continuously delivered. To allow our automated deployment tools to know which version of the codebase has been deployed, the web service should provide a way to query which version it is. The version is declared as part of the project setup in the Leiningen build tool, like this: (defproject my-web-service "1.2-SNAPSHOT" ; ... rest of project.clj ) The codebase is packaged as a JAR file. We developers do not want to increment the version number