Upgrade to Pro — share decks privately, control downloads, hide ads and more …

CIDER: Rocking with Clojure and Emacs

CIDER: Rocking with Clojure and Emacs

Slide deck from my buildstuff.lt 2015 presentation.

Bozhidar Batsov

November 20, 2015
Tweet

More Decks by Bozhidar Batsov

Other Decks in Programming

Transcript

  1. Bug

  2. Which is your primary Clojure dev environment? (2014) Other 13%

    LightTable 12% CCW 5% fireplace 14% Cursive 14% CIDER 42%
  3. –Nancy Pearcey “Competition is always a good thing. It forces

    us to do our best. A monopoly renders people complacent and satisfied with mediocrity.”
  4. SLIME Features • REPL • Interactive evaluation • Compilation notes

    • Code completion • Definition lookup • Documentation lookup • Apropos
  5. SLIME Features • Debugger • Value inspector • Tracing •

    Find usages • Macroexpansion • Scratchpad • Minibuffer code evaluation
  6. swank-clojure • Requires knowledge of swank (Common Lisp) • Bundles

    a frozen SLIME version • Subpar features (e.g. debugger, inspector, find usages) • Monolithic (no swank plugins)
  7. •Load (compile) a Clojure source file •Evaluate a Clojure form

    •Interrupt evaluation •Read from the standard input
  8. nrepl.el • lacked many SLIME features • relied heavily on

    evaluation of inlined code • made assumptions about the environment • flawed bencode parser
  9. –Phil Karlton “There are only two hard things in Computer

    Science: cache invalidation and naming things.”
  10. (defun nrepl-jump-to-def (var) "Jump to the definition of the VAR

    at point." (let ((form (format "(let [ns-symbol '%s ns-var '%s ns-file (clojure.core/comp :file clojure.core/meta clojure.core/second clojure.core/first clojure.core/ns-publics) resource-str (clojure.core/comp clojure.core/str clojure.java.io/resource ns-file) file-str (clojure.core/comp clojure.core/str clojure.java.io/file ns-file)] (cond ((clojure.core/ns-aliases ns-symbol) ns-var) (let [resolved-ns ((clojure.core/ns-aliases ns-symbol) ns-var)] [(resource-str resolved-ns) (file-str resolved-ns) 1]) (find-ns ns-var) [(resource-str ns-var) (file-str ns-var) 1] (clojure.core/ns-resolve ns-symbol ns-var) ((clojure.core/juxt (clojure.core/comp clojure.core/str clojure.java.io/resource :file) (clojure.core/comp clojure.core/str clojure.java.io/file :file) :line) (clojure.core/meta (clojure.core/ns-resolve ns-symbol ns-var)))))" (nrepl-current-ns) var))) (nrepl-send-string form (nrepl-jump-to-def-handler (current-buffer)) nrepl-buffer-ns (nrepl-current-tooling-session)))) not portable
  11. (defun cider-jump-to-var (&optional var line) "Jump to the definition of

    VAR, optionally at a specific LINE. When called interactively, this operates on point, or falls back to a prompt." (interactive) (cider-ensure-op-supported "info") (cider-read-symbol-name "Symbol: " (lambda (var) (-if-let (info (cider-var-info var)) (cider--jump-to-loc-from-info info) (message "Symbol %s not resolved" var))))) portable
  12. CIDER Features • Interactive evaluation • Compilation notes • Code

    completion • Definition lookup • Documentation lookup • Apropos
  13. CIDER Features • Value inspector • Command selector • Tracing

    • Macroexpansion • Debugger • Scratchpad • Minibuffer code evalution
  14. CIDER Features • Javadoc support • Jump to Java definition

    • Jump to resource • Sanity-preserving stacktraces • clojure.test integration • namespace browser
  15. CIDER Features • classpath browser • grimoire integration • dynamic

    indentation • dynamic font-locking • nREPL session manager • Smart namespace reloading • ClojureScript support
  16. • Find usages • Built-in refactoring tooling • Better ClojureScript

    support • Support for the new Clojure socket REPL • A proper manual CIDER 1.0