-
Notifications
You must be signed in to change notification settings - Fork 2
Expand file tree
/
Copy pathemacs-tweaks.html
More file actions
122 lines (110 loc) · 5.55 KB
/
emacs-tweaks.html
File metadata and controls
122 lines (110 loc) · 5.55 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
<!doctype html>
<html>
<head>
<meta charset="utf-8">
<meta http-equiv="X-UA-Compatible" content="chrome=1">
<title>Expectations by jaycfields</title>
<link rel="stylesheet" href="stylesheets/styles.css">
<link rel="stylesheet" href="stylesheets/pygment_trac.css">
<script src="javascripts/scale.fix.js"></script>
<meta name="viewport" content="width=device-width, initial-scale=1, user-scalable=no">
<!--[if lt IE 9]>
<script src="//html5shiv.googlecode.com/svn/trunk/html5.js"></script>
<![endif]-->
</head>
<body>
<div class="wrapper">
<header>
<h1 class="header">Expectations</h1>
<p class="header">a minimalist's unit testing framework</p>
<ul>
<li><a class="buttons" href="index.html">Home</a></li>
<li><a class="buttons" href="installing.html">Installing</a></li>
<li><a class="buttons" href="introduction.html">Introduction</a></li>
<li><a class="buttons" href="advanced.html">Advanced</a></li>
<li><a class="buttons" href="collections.html">Collections</a></li>
<li><a class="buttons" href="templating.html">Expect More</a></li>
<li><a class="buttons" href="odds-ends.html">Odds & Ends</a></li>
<li><a class="buttons" href="in-context.html">Around Each</a></li>
<li><a class="buttons" href="before-run-hook.html">Around Suite</a></li>
<li><a class="buttons" href="state-warnings.html">State Warnings</a></li>
<li><a class="buttons" href="redef-state.html">Redef State</a></li>
<li><a class="buttons" href="interactions.html">Side Effects</a></li>
<li><a class="buttons" href="freeze-time.html">Freeze Time</a></li>
<li><a class="buttons" href="env-tweaks.html">ENV Tweaks</a></li>
<li><a class="buttons" href="emacs-tweaks.html">emacs Tweaks</a></li>
<li><a class="buttons" href="clojure-test.html">clojure.test</a></li>
<li><a class="buttons github" href="https://github.com/clojure-expectations/expectations">View On GitHub</a></li>
</ul>
<p class="header">This project is maintained by <a class="header name" href="https://github.com/seancorfield">seancorfield</a> and <a class="header name" href="https://github.com/jaycfields">jaycfields</a></p>
</header>
<section>
<h1>
<a name="expectations" class="anchor" href="#expectations"><span class="octicon octicon-link"></span></a>expectations</h1>
<blockquote>
<p>adding signal, removing noise</p>
</blockquote>
<h2> <a name="indent" class="anchor" href="#indent"><span class="octicon octicon-link"></span></a>Indention</h2>
By default expectations fns and macros will indent like any other custom fns or macros. This works fine; however,
I've added the following emacs lisp to my setup, and I definitely prefer this setup to the standard setup. The Indention
level is based on the settings for clojure.core functions, but you're free to tweak things in whatever way you'd like.
<pre>
(define-clojure-indent
(expect 'defun)
(given 'defun)
(context 1)
(freeze-time 1)
(redef-state 1)
(from-each 1))
</pre>
<h2> <a name="greeks" class="anchor" href="#greeks"><span class="octicon octicon-link"></span></a>Font Lock</h2>
Syntax is very important to expectations; however, there are only so many short function names that you can
responsibly use as part of a framework. However, I do like to shorten things when possible; therefore, I define
the following font locks in my emacs setup. (note, not every function/marco I font lock is defined in expectations)
<pre>
(dolist (x '((true т)
(false ғ)
(nil Ø)
(with-redefs я)
(interaction ι)
(a-fn1 α)
(a-fn2 β)
(a-fn3 γ)
(no-op ε)))
(eval-after-load 'clojure-mode
'(font-lock-add-keywords
'clojure-mode `((,(concat "[\[({[:space:]]"
"\\(" (symbol-name (first x)) "\\)"
"[\])}[:space:]]")
(0 (progn (compose-region (match-beginning 1)
(match-end 1) ,(symbol-name (second x)))
nil))))))
(eval-after-load 'clojure-mode
'(font-lock-add-keywords
'clojure-mode `((,(concat "^"
"\\(" (symbol-name (first x)) "\\)"
"[\])}[:space:]]")
(0 (progn (compose-region (match-beginning 1)
(match-end 1) ,(symbol-name (second x)))
nil))))))
(eval-after-load 'clojure-mode
'(font-lock-add-keywords
'clojure-mode `((,(concat "[\[({[:space:]]"
"\\(" (symbol-name (first x)) "\\)"
"$")
(0 (progn (compose-region (match-beginning 1)
(match-end 1) ,(symbol-name (second x)))
nil)))))))
</pre>
The image below shows the before and after buffers. The top buffer is the buffer with the font locks applied.
<div class="separator" style="clear: both;">
<a href="images/fontlock.png"><img border="0" width="600" src="images/fontlock.png"/></a>
</div>
</section>
<footer>
<p><small>Hosted on <a href="https://pages.github.com">GitHub Pages</a> using the Dinky theme</small></p>
</footer>
</div>
<!--[if !IE]><script>fixScale(document);</script><![endif]-->
</body>
</html>