Add sayid, a debugger, to the clojure language

"Sayid (siy EED) is a tool for debugging and profiling clojure code."
(https://bpiel.github.io/sayid/) it allows viewing the results of each line of
code in a clojure function, without editing the code at all.

This commit evilifies the plugin and adds its commands to the "debug" submenu
of the main clojure mode menu.
This commit is contained in:
Daniel Manila 2017-01-18 17:27:08 +06:00 committed by Eivind Fonn
parent 113794f4e8
commit cfe0295875
2 changed files with 171 additions and 33 deletions

View File

@ -3,33 +3,37 @@
[[file:img/clojure.png]] [[file:img/cider.png]]
* Table of Contents :TOC_4_gh:noexport:
- [[#description][Description]]
- [[#features][Features]]
- [[#install][Install]]
- [[#layer][Layer]]
- [[#pretty-symbols][Pretty Symbols]]
- [[#cider-and-clj-refactor][CIDER and clj-refactor]]
- [[#quick-start-with-boot][Quick Start with boot]]
- [[#quick-start-with-lein][Quick Start with lein]]
- [[#more-details][More details]]
- [[#key-bindings][Key Bindings]]
- [[#working-with-clojure-files-barfage-slurpage--more][Working with clojure files (barfage, slurpage & more)]]
- [[#leader][Leader]]
- [[#documentation][Documentation]]
- [[#evaluation][Evaluation]]
- [[#goto][Goto]]
- [[#repl][REPL]]
- [[#tests][Tests]]
- [[#toggles][Toggles]]
- [[#debugging][Debugging]]
- [[#refactoring][Refactoring]]
- [[#reformatting][Reformatting]]
- [[#cider-buffers][CIDER Buffers]]
- [[#stacktrace-mode][stacktrace-mode]]
- [[#inspector-mode][inspector-mode]]
- [[#test-report-mode][test-report-mode]]
- [[#development-notes][Development Notes]]
- [[#indentation][Indentation]]
- [[#description][Description]]
- [[#features][Features]]
- [[#install][Install]]
- [[#layer][Layer]]
- [[#pretty-symbols][Pretty Symbols]]
- [[#cider-and-clj-refactor][CIDER and clj-refactor]]
- [[#quick-start-with-boot][Quick Start with boot]]
- [[#quick-start-with-lein][Quick Start with lein]]
- [[#more-details][More details]]
- [[#key-bindings][Key Bindings]]
- [[#working-with-clojure-files-barfage-slurpage--more][Working with clojure files (barfage, slurpage & more)]]
- [[#leader][Leader]]
- [[#documentation][Documentation]]
- [[#evaluation][Evaluation]]
- [[#goto][Goto]]
- [[#repl][REPL]]
- [[#tests][Tests]]
- [[#toggles][Toggles]]
- [[#debugging][Debugging]]
- [[#refactoring][Refactoring]]
- [[#reformatting][Reformatting]]
- [[#cider-buffers][CIDER Buffers]]
- [[#stacktrace-mode][stacktrace-mode]]
- [[#inspector-mode][inspector-mode]]
- [[#test-report-mode][test-report-mode]]
- [[#sayid-buffers][Sayid Buffers]]
- [[#sayid-mode][sayid-mode]]
- [[#sayid-traced-mode][sayid-traced-mode]]
- [[#sayid-pprint][sayid-pprint]]
- [[#development-notes][Development Notes]]
- [[#indentation][Indentation]]
* Description
This layer adds support for [[https://clojure.org/][Clojure]] language using [[https://github.com/clojure-emacs/cider][CIDER]].
@ -39,6 +43,7 @@ This layer adds support for [[https://clojure.org/][Clojure]] language using [[h
- Code formatting via [[https://github.com/clojure-emacs/cider][CIDER]] using [[https://github.com/weavejester/cljfmt][Cljfmt]]
- Refactoring via [[https://github.com/clojure-emacs/clj-refactor.el][clj-refactor]]
- Aligning of code forms via [[https://github.com/clojure-emacs/clojure-mode][clojure-mode]]
- Debugging with [[https://bpiel.github.io/sayid/][sayid]]
* Install
** Layer
@ -199,12 +204,34 @@ As this state works the same for all files, the documentation is in global
*** Debugging
| Key Binding | Description |
|-------------+--------------------------------|
| ~SPC m d b~ | instrument expression at point |
| ~SPC m d e~ | display last stacktrace |
| ~SPC m d r~ | reload namespaces |
| ~SPC m d v~ | inspect expression at point |
| Key Binding | Description |
|---------------+----------------------------------------------------|
| ~SPC m d b~ | instrument expression at point |
| ~SPC m d e~ | display last stacktrace |
| ~SPC m d r~ | reload namepspaces |
| ~SPC m d v~ | inspect expression at point |
| ~SPC m d i~ | inspect expression at point |
| ~SPC m d f~ | query form at point |
| ~SPC m d w~ | open sayid workspace window |
| ~SPC m d E~ | one time display of value at cursor |
| ~SPC m d !~ | reload traces and clear sayid workspace |
| ~SPC m d c~ | clear workspace trace log |
| ~SPC m d x~ | clear workspace traces and log |
| ~SPC m d s~ | show what is currently traced |
| ~SPC m d S~ | show what is currently traced in current namespace |
| ~SPC m d V~ | set the view |
| ~SPC m d h~ | show sayid help (keybindings may not be accurate) |
| ~SPC m d t y~ | recursively trace every namespace in given dir |
| ~SPC m d t p~ | trace namespaces by regex |
| ~SPC m d t b~ | trace current file's namespace |
| ~SPC m d t e~ | enable existing trace on current function |
| ~SPC m d t E~ | enable existing trace on all functions |
| ~SPC m d t d~ | disable existing trace on current function |
| ~SPC m d t D~ | disable existing trace on all functions |
| ~SPC m d t n~ | create inner trace on function |
| ~SPC m d t o~ | create outer trace on function |
| ~SPC m d t r~ | remove trace on function |
| ~SPC m d t K~ | remove all traces |
*** Refactoring
@ -263,6 +290,7 @@ As this state works the same for all files, the documentation is in global
| ~SPC m f l~ | realign current form |
| ~SPC m f b~ or ~SPC m =~ | reformat current buffer |
** CIDER Buffers
In general, ~q~ should always quit the popped up buffer.
@ -312,6 +340,56 @@ In general, ~q~ should always quit the popped up buffer.
| ~t~ | run test |
| ~T~ | run tests |
** Sayid Buffers
*** sayid-mode
| Key Binding | Description |
|--------------------+---------------------------------------------------|
| ~enter~ | pop to function |
| ~d~ | def value to $s/* |
| ~f~ | query for calls to function |
| ~F~ | query to calls to function with modifier |
| ~i~ | show only this instance |
| ~I~ | show only this instance with modifier |
| ~w~ | show full workspace trace |
| ~n~ | jump to next call |
| ~N~ | jump to previous call |
| ~P~ | pretty print value |
| ~C~ | clear workspace trace log |
| ~L~ or ~Backspace~ | previous buffer state |
| ~Shift-Backspace~ | forward buffer state |
| ~e~ | generate instance expression and put in kill ring |
| ~H~ | display help (keybindings may not be accurate) |
| ~C-s v~ | toggle view |
| ~C-s V~ | set view |
*** sayid-traced-mode
| Key Binding | Description |
|-------------+------------------------------------------------|
| ~enter~ | drill into ns at point |
| ~e~ | enable trace |
| ~d~ | disable trace |
| ~E~ | enable all traces |
| ~D~ | disable all traces |
| ~i~ | apply inner trace to function at point |
| ~o~ | apply outer trace to function at point |
| ~r~ | remove trace at point |
| ~backspace~ | go back to trace overview |
| ~h~ | display help (keybindings may not be accurate) |
*** sayid-pprint
| Key Binding | Description |
|-------------+-----------------------------|
| ~enter~ | show path in minibuffer |
| ~i~ | enter child node |
| ~o~ | enter parent node |
| ~n~ | enter next sibling node |
| ~p~ | enter previous sibling node |
* Development Notes
** Indentation
With a [[https://github.com/clojure-emacs/cider/blob/master/doc/indent_spec.md][new]] functionality of Cider to read the custom indentation rules from the

View File

@ -13,6 +13,7 @@
smartparens
subword
org
sayid
))
(defun clojure/init-cider ()
@ -303,3 +304,62 @@
(spacemacs|use-package-add-hook org
:post-config (add-to-list 'org-babel-load-languages '(clojure . t))
(setq org-babel-clojure-backend 'cider)))
(defun clojure/init-sayid ()
(use-package sayid
:defer t
:init
(progn
(setq sayid--key-binding-prefixes
'(("mdt" . "trace")))
(dolist (m '(clojure-mode
clojurec-mode
clojurescript-mode
clojurex-mode
cider-repl-mode
cider-clojure-interaction-mode))
(mapc (lambda (x) (spacemacs/declare-prefix-for-mode
m (car x) (cdr x)))
sayid--key-binding-prefixes)
(spacemacs/set-leader-keys-for-major-mode m
;;These keybindings mostly preserved from the default sayid bindings
"df" 'sayid-query-form-at-point
"dw" 'sayid-get-workspace
"dE" 'sayid-eval-last-sexp ;in default sayid bindings this is lowercase e, but that was already used in clojure mode
"d!" 'sayid-load-enable-clear
"dc" 'sayid-clear-log
"dx" 'sayid-reset-workspace
"ds" 'sayid-show-traced
"dS" 'sayid-show-traced-ns
"dV" 'sayid-set-view
"dh" 'sayid-show-help
"dty" 'sayid-trace-all-ns-in-dir
"dtp" 'sayid-trace-ns-by-pattern
"dtb" 'sayid-trace-ns-in-file
"dte" 'sayid-trace-fn-enable
"dtE" 'sayid-trace-enable-all
"dtd" 'sayid-trace-fn-disable
"dtD" 'sayid-trace-disable-all
"dtn" 'sayid-inner-trace-fn
"dto" 'sayid-outer-trace-fn
"dtr" 'sayid-remove-trace-fn
"dtK" 'sayid-kill-all-traces))
(evilified-state-evilify sayid-mode sayid-mode-map
(kbd "H") 'sayid-buf-show-help
(kbd "n") 'sayid-buffer-nav-to-next
(kbd "N") 'sayid-buffer-nav-to-prev
(kbd "C-s v") 'sayid-toggle-view
(kbd "C-s V") 'sayid-set-view
(kbd "L") 'sayid-buf-back
(kbd "e") 'sayid-gen-instance-expr ;Originally this was bound to 'g', but I feel this is still mnemonic and doesn't overlap with evil
)
(evilified-state-evilify sayid-pprint-mode sayid-pprint-mode-map
(kbd "h") 'sayid-pprint-buf-show-help
(kbd "n") 'sayid-pprint-buf-next
(kbd "N") 'sayid-pprint-buf-prev
(kbd "l") 'sayid-pprint-buf-exit)
(evilified-state-evilify sayid-traced-mode sayid-traced-mode-map
(kbd "l") 'sayid-show-traced
(kbd "h") 'sayid-traced-buf-show-help))))