Skip to content
This repository
Browse code

fix indentation and comments

  • Loading branch information...
commit 84ef585cd5ff4f7a2395d945237655236aa0cf52 1 parent bc78662
Dmitri Naumov authored June 21, 2011

Showing 1 changed file with 46 additions and 55 deletions. Show diff stats Hide diff stats

  1. 101  midje-mode.el
101  midje-mode.el
... ...
@@ -1,21 +1,12 @@
1 1
 ;;; midje-mode.el --- Minor mode for Midje tests
2 2
 ;;
3 3
 ;; This is a minor mode designed to be used with clojure-mode.el and slime.el
4  
-
5  
-;; What's in my .emacs file:
6  
-;; (eval-after-load 'clojure-mode
7  
-;;   '(define-clojure-indent
8  
-;;      (fact 'defun)
9  
-;;      (facts 'defun)
10  
-;;      (against-background 'defun)
11  
-;;      (provided 0)))
12  
-
13  
-;; (require 'clojure-mode)
14  
-;; (add-to-list 'auto-mode-alist '("\\.clj$" . clojure-mode))
  4
+;;
  5
+;; Usage:
15 6
 ;; (require 'midje-mode)
16  
-;; (add-hook 'clojure-mode-hook 'midje-mode)
17 7
 ;; (require 'clojure-jump-to-file)
18 8
 
  9
+;;; Code:
19 10
 
20 11
 (require 'clojure-mode)
21 12
 (require 'slime)
@@ -53,31 +44,31 @@
53 44
     (modify-syntax-entry ?? "w" midje-syntax-table)
54 45
     (modify-syntax-entry ?! "w" midje-syntax-table))
55 46
 
56  
-  (save-excursion 
  47
+  (save-excursion
57 48
     (with-syntax-table midje-syntax-table
58 49
       (let ((beg (if (midje-at-start-of-identifier?)
59  
-		     (point)
60  
-		   (progn (backward-word) (point)))))
61  
-	(forward-word)
62  
-	(buffer-substring-no-properties beg (point))))))
  50
+                     (point)
  51
+                   (progn (backward-word) (point)))))
  52
+        (forward-word)
  53
+        (buffer-substring-no-properties beg (point))))))
63 54
 
64 55
 (defun midje-to-unfinished ()
65 56
   (goto-char (point-min))
66 57
   (search-forward "(unfinished"))
67 58
 
68  
-(defun midje-within-unfinished? () 
  59
+(defun midje-within-unfinished? ()
69 60
   (let ((target (point))
70  
-	 unfinished-beg
71  
-	 unfinished-end)
  61
+        unfinished-beg
  62
+        unfinished-end)
72 63
     (save-excursion
73 64
       (save-restriction
74  
-	(midje-to-unfinished)
75  
-	(beginning-of-defun)
76  
-	(setq unfinished-beg (point))
77  
-	(end-of-defun)
78  
-	(setq unfinished-end (point))
79  
-	(and (>= target unfinished-beg)
80  
-	     (<= target unfinished-end))))))
  65
+        (midje-to-unfinished)
  66
+        (beginning-of-defun)
  67
+        (setq unfinished-beg (point))
  68
+        (end-of-defun)
  69
+        (setq unfinished-end (point))
  70
+        (and (>= target unfinished-beg)
  71
+             (<= target unfinished-end))))))
81 72
 
82 73
 (defun midje-tidy-unfinished ()
83 74
   (midje-to-unfinished) (let ((fill-prefix "")) (fill-paragraph nil))
@@ -100,11 +91,11 @@
100 91
     (save-restriction
101 92
       (widen)
102 93
       (let ((identifier (midje-identifier)))
103  
-	(with-syntax-table midje-syntax-table
104  
-	  (unless (midje-at-start-of-identifier?) (backward-word))
105  
-	  (kill-word nil)
106  
-	  (midje-tidy-unfinished)
107  
-	  identifier)))))
  94
+        (with-syntax-table midje-syntax-table
  95
+          (unless (midje-at-start-of-identifier?) (backward-word))
  96
+          (kill-word nil)
  97
+          (midje-tidy-unfinished)
  98
+          identifier)))))
108 99
 
109 100
 (defun midje-add-defn-after-unfinished (identifier)
110 101
   (widen)
@@ -123,33 +114,33 @@
123 114
 (defun midje-provide-result-info (result)
124 115
   (destructuring-bind (output value) result
125 116
     (if (string= output "")
126  
-	(midje-display-reward)
  117
+        (midje-display-reward)
127 118
       (midje-insert-failure-message output))))
128 119
 
129 120
 (defun midje-insert-failure-message (str &optional justify)
130 121
   (let ((start-point (point))
131  
-	(end-point (progn (insert str) (point))))
  122
+        (end-point (progn (insert str) (point))))
132 123
     (midje-add-midje-comments start-point end-point)
133 124
     (goto-char start-point)
134  
-    (unless (string= ";" (char-to-string (char-after))) 
  125
+    (unless (string= ";" (char-to-string (char-after)))
135 126
       (delete-char 1))))
136 127
 
137 128
 (defun midje-display-reward ()
138 129
   (save-excursion
139 130
     (save-restriction
140 131
       (let ((start (point)))
141  
-	(insert (midje-random-praise))
142  
-	(narrow-to-region start (point))
143  
-	(goto-char (point-min))
144  
-	(fill-paragraph nil)
145  
-	(midje-add-midje-comments (point-min) (point-max))))))
  132
+        (insert (midje-random-praise))
  133
+        (narrow-to-region start (point))
  134
+        (goto-char (point-min))
  135
+        (fill-paragraph nil)
  136
+        (midje-add-midje-comments (point-min) (point-max))))))
146 137
 
147 138
 (defun midje-add-midje-comments (start-point end-point)
148 139
   (let ((comment-start midje-comments)
149  
-	(comment-empty-lines t))
  140
+        (comment-empty-lines t))
150 141
     (comment-region start-point end-point)))
151 142
 
152  
-(defun midje-on-fact? () 
  143
+(defun midje-on-fact? ()
153 144
   (save-excursion
154 145
     (save-restriction
155 146
       (narrow-to-defun)
@@ -181,8 +172,8 @@ all such comments."
181 172
     (goto-char (point-min))
182 173
     (let ((kill-whole-line t))
183 174
       (while (search-forward midje-comments nil t)
184  
-	(beginning-of-line)
185  
-	(kill-line)))))
  175
+        (beginning-of-line)
  176
+        (kill-line)))))
186 177
 
187 178
 (defun midje-check-fact-near-point ()
188 179
   "Used when `point' is on or just after a Midje fact.
@@ -191,8 +182,8 @@ Check that fact and also save it for use of
191 182
   (interactive)
192 183
   (midje-clear-comments)
193 184
   (let ((string (save-excursion
194  
-		 (mark-defun)
195  
-		 (buffer-substring-no-properties (mark) (point)))))
  185
+                  (mark-defun)
  186
+                  (buffer-substring-no-properties (mark) (point)))))
196 187
     (setq last-checked-midje-fact string)
197 188
     (slime-eval-async `(swank:eval-and-grab-output ,string)
198 189
       'midje-insert-above-fact)))
@@ -206,15 +197,15 @@ the last fact checked (by `midje-check-fact-near-point')."
206 197
   (midje-clear-comments)
207 198
   (setq midje-running-fact t)
208 199
   (slime-compile-defun)
209  
-  ; Callback is slime-compilation-finished, then midje-after-compilation-check-fact
210  
-)
  200
+                                        ; Callback is slime-compilation-finished, then midje-after-compilation-check-fact
  201
+  )
211 202
 
212 203
 ;; This is a HACK. I want to add midje-after-compilation-check-fact to
213  
-;; the slime-compilation-finished-hook, but I can't seem to override the 
214  
-;; :options declaration in the original slime.el defcustom. 
  204
+;; the slime-compilation-finished-hook, but I can't seem to override the
  205
+;; :options declaration in the original slime.el defcustom.
215 206
 (unless (fboundp 'original-slime-compilation-finished)
216 207
   (setf (symbol-function 'original-slime-compilation-finished)
217  
-	(symbol-function 'slime-compilation-finished)))
  208
+        (symbol-function 'slime-compilation-finished)))
218 209
 
219 210
 (defun slime-compilation-finished (result)
220 211
   (original-slime-compilation-finished result)
@@ -224,7 +215,7 @@ the last fact checked (by `midje-check-fact-near-point')."
224 215
 (defun midje-after-compilation-check-fact ()
225 216
   (if midje-running-fact
226 217
       (slime-eval-async `(swank:eval-and-grab-output ,last-checked-midje-fact)
227  
-	'midje-insert-below-code-under-test))
  218
+        'midje-insert-below-code-under-test))
228 219
   (setq midje-running-fact nil))
229 220
 
230 221
 (defun midje-check-fact ()
@@ -233,7 +224,7 @@ the last fact checked (by `midje-check-fact-near-point')."
233 224
 nearby Clojure form and recheck the last fact checked
234 225
 (with `midje-recheck-last-fact-checked')."
235 226
   (interactive)
236  
-  (if (midje-on-fact?) 
  227
+  (if (midje-on-fact?)
237 228
       (midje-check-fact-near-point)
238 229
     (midje-recheck-last-fact-checked)))
239 230
 
@@ -253,7 +244,7 @@ nearby Clojure form and recheck the last fact checked
253 244
 
254 245
 (defun midje-unfinished ()
255 246
   (interactive)
256  
-  (if (midje-within-unfinished?) 
  247
+  (if (midje-within-unfinished?)
257 248
       (midje-add-defn-after-unfinished (midje-remove-identifier-from-unfinished-list))
258 249
     (midje-add-identifier-to-unfinished-list (midje-identifier))))
259 250
 
@@ -279,7 +270,7 @@ nearby Clojure form and recheck the last fact checked
279 270
 
280 271
 ;;;###autoload
281 272
 (define-minor-mode midje-mode
282  
-"A minor mode for running Midje tests when in `slime-mode'.
  273
+  "A minor mode for running Midje tests when in `slime-mode'.
283 274
 
284 275
 \\{midje-mode-map}"
285 276
   nil " Midje" midje-mode-map

0 notes on commit 84ef585

Please sign in to comment.
Something went wrong with that request. Please try again.