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

The Evolution of the Clojure Tooling for Emacs

The Evolution of the Clojure Tooling for Emacs

Slides from my Clojure/conj 2014 talk

Bozhidar Batsov

November 20, 2014
Tweet

More Decks by Bozhidar Batsov

Other Decks in Programming

Transcript

  1. Bug

  2. 2013 Other 24% LightTable 8% CCW 8% fireplace 10% Cursive

    3% CIDER 48% 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 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 • Scratchpad • Minibuffer code evalution
  14. M-.

  15. IDE

  16. • Emacs (ultimate Elisp dev env) • SLIME (and SLY)

    • Geiser • racket-mode • CIDER (obviously)