Permalink
Browse files

Added wrangling examples.

  • Loading branch information...
1 parent 7254b0b commit 2a9c34141379a4aff05eb68ad5078cab41823551 @technomancy committed Jul 2, 2009
Showing with 33 additions and 16 deletions.
  1. +27 −10 outline.markdown
  2. +6 −6 rooms.clj
View
@@ -101,24 +101,38 @@ fix things. You can also prefix backspace with C-u to force it.
## 4. Wrangling (depth-changing)
- TODO: example
+ open rooms.clj
+ point at right before mire.rooms
+ M-(
+ Mark "declare rooms"
+ Press (
You can wrap the next expression in parens with M-(. If you want to
wrap multiple expressions, simply mark them and then hit (.
- TODO: example
+ Back to mire.rooms
+ M-s
If you're inside a list and want to merge it with its parent, use M-s
to splice.
- TODO: example
+ Back to "declare rooms"; point in rooms
+ C-S-]
+ C-S-0
Of course we can't neglect to mention the imaginatively named "barf"
-and "slurp" commands.
+and "slurp" commands. If you're inside a list, you can "barf" the last
+expression out of the list. The reverse operation "slurps" the next
+element outside into the list. Yum!
- TODO: finish
+ C-S-[
+ C-S-9
- TODO: example
+Barfing and slurping have forward and backward variations.
+
+ Point to front of rooms
+ M-S-s
+ M-S-j
This is pretty straightforward; just use M-S-s and M-S-j to split and
join lists.
@@ -128,10 +142,12 @@ join lists.
[TODO: example]
While paredit-mode was designed to work with Lisp languages, it can be
-used in others as well. In Ruby it works pretty well, although it does
-not consider do/end to be matching elements, and it only matches
-double-quotes. For Javascript and other languages based on cc-mode,
-there are a few hiccups, but it can be made to work.
+used in others as well. It works with most modes based on cc-mode
+(including espresso-mode for Javascript), but there are problems with
+js2-mode. It also works in ruby-mode. The list modification commands
+don't expect list elements to need commas between them, so this causes
+some problems. Other than that, the functionality it provides is quite
+helpful.
## 6. Installation and Enabling
@@ -148,6 +164,7 @@ hooks for that:
(add-hook 'scheme-mode-hook 'enable-paredit-mode)
(add-hook 'clojure-mode-hook 'enable-paredit-mode)
(add-hook 'ruby-mode-hook 'esk-paredit-nonlisp)
+ (add-hook 'espresso-mode-hook 'esk-paredit-nonlisp)
Add a hook for each mode for which you want paredit activated, and
you're good to go.
View
@@ -3,7 +3,12 @@
(ns mire.rooms)
-(declare rooms)
+declare rooms load-room
+
+(defn load-rooms [dir]
+ "Given a dir, return a map with an entry corresponding to each file
+in it. Files should be maps containing room data."
+ (reduce load-room {} (.listFiles (java.io.File. dir))))
(defn load-room [rooms file]
(let [room (read-string (slurp (.getAbsolutePath file)))]
@@ -15,11 +20,6 @@
:items (ref (or (:items room) #{}))
:inhabitants (ref #{})}})))
-(defn load-rooms [dir]
- "Given a dir, return a map with an entry corresponding to each file
-in it. Files should be maps containing room data."
- (reduce load-room {} (.listFiles (java.io.File. dir))))
-
(defn set-rooms
"Set mire.rooms/rooms to a map of rooms corresponding to each file
in dir. This function should be used only once at mire startup, so

0 comments on commit 2a9c341

Please sign in to comment.