Skip to content
This repository

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
Browse code

Added wrangling examples.

  • Loading branch information...
commit 2a9c34141379a4aff05eb68ad5078cab41823551 1 parent 7254b0b
Phil Hagelberg authored July 02, 2009
37  outline.markdown
Source Rendered
@@ -101,24 +101,38 @@ fix things. You can also prefix backspace with C-u to force it.
101 101
 
102 102
 ## 4. Wrangling (depth-changing)
103 103
 
104  
-    TODO: example
  104
+    open rooms.clj
  105
+    point at right before mire.rooms
  106
+    M-(
  107
+    Mark "declare rooms"
  108
+    Press (
105 109
 
106 110
 You can wrap the next expression in parens with M-(. If you want to
107 111
 wrap multiple expressions, simply mark them and then hit (.
108 112
 
109  
-    TODO: example
  113
+    Back to mire.rooms
  114
+    M-s
110 115
 
111 116
 If you're inside a list and want to merge it with its parent, use M-s
112 117
 to splice.
113 118
 
114  
-    TODO: example
  119
+    Back to "declare rooms"; point in rooms
  120
+    C-S-]
  121
+    C-S-0
115 122
 
116 123
 Of course we can't neglect to mention the imaginatively named "barf"
117  
-and "slurp" commands.
  124
+and "slurp" commands. If you're inside a list, you can "barf" the last
  125
+expression out of the list. The reverse operation "slurps" the next
  126
+element outside into the list. Yum!
118 127
 
119  
-    TODO: finish
  128
+    C-S-[
  129
+    C-S-9
120 130
 
121  
-    TODO: example
  131
+Barfing and slurping have forward and backward variations.
  132
+
  133
+    Point to front of rooms
  134
+    M-S-s
  135
+    M-S-j
122 136
 
123 137
 This is pretty straightforward; just use M-S-s and M-S-j to split and
124 138
 join lists.
@@ -128,10 +142,12 @@ join lists.
128 142
     [TODO: example]
129 143
 
130 144
 While paredit-mode was designed to work with Lisp languages, it can be
131  
-used in others as well. In Ruby it works pretty well, although it does
132  
-not consider do/end to be matching elements, and it only matches
133  
-double-quotes. For Javascript and other languages based on cc-mode,
134  
-there are a few hiccups, but it can be made to work.
  145
+used in others as well. It works with most modes based on cc-mode
  146
+(including espresso-mode for Javascript), but there are problems with
  147
+js2-mode. It also works in ruby-mode. The list modification commands
  148
+don't expect list elements to need commas between them, so this causes
  149
+some problems. Other than that, the functionality it provides is quite
  150
+helpful.
135 151
 
136 152
 ## 6. Installation and Enabling
137 153
 
@@ -148,6 +164,7 @@ hooks for that:
148 164
     (add-hook 'scheme-mode-hook     'enable-paredit-mode)
149 165
     (add-hook 'clojure-mode-hook    'enable-paredit-mode)
150 166
     (add-hook 'ruby-mode-hook       'esk-paredit-nonlisp)
  167
+    (add-hook 'espresso-mode-hook   'esk-paredit-nonlisp)
151 168
 
152 169
 Add a hook for each mode for which you want paredit activated, and
153 170
 you're good to go.
12  rooms.clj
@@ -3,7 +3,12 @@
3 3
 
4 4
 (ns mire.rooms)
5 5
 
6  
-(declare rooms)
  6
+declare rooms load-room
  7
+
  8
+(defn load-rooms [dir]
  9
+  "Given a dir, return a map with an entry corresponding to each file
  10
+in it. Files should be maps containing room data."
  11
+  (reduce load-room {} (.listFiles (java.io.File. dir))))
7 12
 
8 13
 (defn load-room [rooms file]
9 14
   (let [room (read-string (slurp (.getAbsolutePath file)))]
@@ -15,11 +20,6 @@
15 20
             :items (ref (or (:items room) #{}))
16 21
             :inhabitants (ref #{})}})))
17 22
 
18  
-(defn load-rooms [dir]
19  
-  "Given a dir, return a map with an entry corresponding to each file
20  
-in it. Files should be maps containing room data."
21  
-  (reduce load-room {} (.listFiles (java.io.File. dir))))
22  
-
23 23
 (defn set-rooms
24 24
   "Set mire.rooms/rooms to a map of rooms corresponding to each file
25 25
   in dir. This function should be used only once at mire startup, so

0 notes on commit 2a9c341

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