git.fiddlerwoaroof.com
Browse code

Reformatting code and cleaning up its style

fiddlerwoaroof authored on 18/03/2016 05:38:54
Showing 1 changed files
... ...
@@ -25,47 +25,52 @@
25 25
 
26 26
 (defgeneric print-format-modifiers (command stream)
27 27
   (:method ((command format-string-command) s)
28
-   ; TODO: format here causes inconsistent behavior :p
28
+     ;; TODO: format here causes inconsistent behavior :p
29 29
      (mapl (lambda (x)
30 30
              (princ (car x) s)
31 31
              (when (cdr x) (princ #\, s)))
32 32
            (modifiers command))))
33 33
 
34 34
 (defgeneric print-format-representation (command stream)
35
-  (:method ((commands list) s)
36
-   (dolist (command commands)
37
-     (print-format-representation command s)))
38
-  (:method ((literal character) s)
39
-   (princ literal s))
40
-  (:method ((literal string) s)
41
-   (princ literal s))
42
-
43
-  (:method :around ((command format-string-command) s)
44
-   (princ #\~ s)
45
-   (call-next-method))
46
-  (:method :before ((command format-string-command) s)
47
-   (when (colon-p command)
48
-     (princ #\: s))
49
-   (when (at-p command)
50
-     (princ #\@ s)))
51
-
52
-  (:method :before ((command simple-format-string-command) s)
53
-   (print-format-modifiers command s))
54
-  (:method ((command simple-format-string-command) s)
55
-   (princ (format-char command) s))
56
-
57
-  (:method :before ((command compound-format-string-command) s)
58
-   (print-format-modifiers command s))
59
-  (:method ((command compound-format-string-command) s)
60
-   (princ (start-char command) s)
61
-   (print-format-representation (contents command) s)
62
-   (princ #\~ s)
63
-   (princ (end-char command) s))
64
-
65 35
   (:documentation "Prints the appropriate control sequence to the stream passed in
66 36
                    The :before method will print the Tilde."))
67 37
 
68
-; TODO: should this be a generic function?
38
+(defmethod ((commands list) s)
39
+  (dolist (command commands)
40
+    (print-format-representation command s)))
41
+
42
+(defmethod ((literal character) s)
43
+  (princ literal s))
44
+
45
+(defmethod ((literal string) s)
46
+  (princ literal s))
47
+
48
+(defmethod :around ((command format-string-command) s)
49
+  (princ #\~ s)
50
+  (call-next-method))
51
+
52
+(defmethod :before ((command format-string-command) s)
53
+  (when (colon-p command)
54
+    (princ #\: s))
55
+  (when (at-p command)
56
+    (princ #\@ s)))
57
+
58
+(defmethod :before ((command simple-format-string-command) s)
59
+  (print-format-modifiers command s))
60
+
61
+(defmethod ((command simple-format-string-command) s)
62
+  (princ (format-char command) s))
63
+
64
+(defmethod :before ((command compound-format-string-command) s)
65
+  (print-format-modifiers command s))
66
+
67
+(defmethod ((command compound-format-string-command) s)
68
+  (princ (start-char command) s)
69
+  (print-format-representation (contents command) s)
70
+  (princ #\~ s)
71
+  (princ (end-char command) s))
72
+
73
+;;; TODO: should this be a generic function?
69 74
 (defun convert-modifier (modifier)
70 75
   (flet ((validate-modifier (modifier)
71 76
            (when (member (elt (string modifier) 0) '(#\: #\@ #\,))
... ...
@@ -115,7 +120,7 @@
115 120
       *format-stream*)))
116 121
 
117 122
 (defun %define-format-char (name format-char closing-char &key at-p colon-p)
118
-  ; TODO: implement closing-char when we implement the block constructs.
123
+  ;; TODO: implement closing-char when we implement the block constructs.
119 124
   (declare (ignore closing-char))
120 125
   (setf (gethash (intern (string name) :keyword)
121 126
                  *format-string-registry*)
... ...
@@ -134,19 +139,15 @@
134 139
                                          :at-p ,at-p
135 140
                                          :colon-p ,colon-p)))
136 141
 
137
-; ('compound-format-string-command :start-char #\{ :end-char #\})
138
-
139 142
 (defmacro define-compound-format-chars (&body specs)
140
-  (list*
141
-    'progn
142
-    (loop for spec in specs
143
-        collect `(define-compound-format-char ,@spec))))
143
+  `(progn
144
+     ,@(loop for spec in specs
145
+             collect `(define-compound-format-char ,@spec))))
144 146
 
145 147
 (defmacro define-simple-format-chars (&body specs)
146
-  (list*
147
-    'progn
148
-    (loop for spec in specs
149
-        collect `(define-simple-format-char ,@spec))))
148
+  `(progn
149
+     ,@(loop for spec in specs
150
+             collect `(define-simple-format-char ,@spec))))
150 151
 
151 152
 (defmacro define-format-chars (&body body)
152 153
   `(macrolet ((:simple (name (char) &key at-p colon-p)
... ...
@@ -181,7 +182,7 @@
181 182
 
182 183
 (define-format-chars
183 184
 
184
-  ; Iteration characters.
185
+  ;; Iteration characters.
185 186
   (:compounds
186 187
     (:map (#\{ #\}))
187 188
     (:rest (#\{ #\}) :at-p t)
... ...
@@ -192,7 +193,7 @@
192 193
     (:aprest (#\{ #\}) :at-p t :colon-p t)
193 194
     (:apply-rest (#\{ #\}) :at-p t :colon-p t))
194 195
 
195
-  ; Alignment characters.
196
+  ;; Alignment characters.
196 197
   (:compounds
197 198
     (:spread (#\< #\>))
198 199
 
... ...
@@ -205,7 +206,7 @@
205 206
     (:cjust (#\< #\>) :at-p t :colon-p t)
206 207
     (:center (#\< #\>) :at-p t :colon-p t))
207 208
 
208
-  ; Case printing characters.
209
+  ;; Case printing characters.
209 210
   (:compounds
210 211
     (:lowercase (#\( #\)))
211 212
     (:uppercase (#\( #\)) :at-p t :colon-p t)