Add log, begin-record, end-record, binary, unbinary, color modes, cursor modes,  Also further docstring updates.

--- src/processing/core.clj
+++ src/processing/core.clj
@@ -10,7 +10,7 @@
 ;; remove this notice, or any other, from this software.

 (ns processing.core
-  (:import (processing.core PApplet PImage PGraphics PFont))
+  (:import (processing.core PApplet PImage PGraphics PFont PConstants))
   (:load "constants"))

 ;; used by functions in this lib. Use binding to set it
@@ -19,8 +19,8 @@
 (def ^{:dynamic true} *state*)

 (defn state
-  "Retrieve canvas-specific state by key. Must initially call set-state! to
-  store state.
+  "Retrieve canvas-specific state by key. Must initially call
+  set-state! to store state.

   (set-state! :foo 1)
   (state :foo) ;=> 1 "
@@ -34,8 +34,8 @@
     (get state key)))

 (defn set-state!
-  "Set canvas-specific state. May only be called once (ideally in the setup fn).
-  Subsequent calls have no effect.
+  "Set canvas-specific state. May only be called once (ideally in the
+  setup fn).  Subsequent calls have no effect.

   Example:
   (set-state! :foo 1 :bar (atom true) :baz (/ (width) 2))"
@@ -45,73 +45,73 @@
       (reset! *state* state-map))))

 (defn abs-int
-  "Calculates the absolute value (magnitude) of a number. The absolute value of
-  a number is always positive. Takes and returns an int."
+  "Calculates the absolute value (magnitude) of a number. The absolute
+  value of a number is always positive. Takes and returns an int."
   [n]
   (PApplet/abs (int n)))

 (defn abs-float
-  "Calculates the absolute value (magnitude) of a number. The absolute value of
-  a number is always positive. Takes and returns a float."
+  "Calculates the absolute value (magnitude) of a number. The absolute
+  value of a number is always positive. Takes and returns a float."
   [n]
   (PApplet/abs (float n)))

-(def abs abs-float)
+(def ^{:arglists (:arglists (meta #'abs-float))
+       :doc (:doc (meta #'abs-float))}
+  abs abs-float)

 (defn acos
-  "The inverse of cos, returns the arc cosine of a value. This function expects
-  the values in the range of -1 to 1 and values are returned in the range 0 to
-  Math/PI (3.1415927)."
+  "The inverse of cos, returns the arc cosine of a value. This
+  function expects the values in the range of -1 to 1 and values are
+  returned in the range 0 to Math/PI (3.1415927)."
   [n]
   (PApplet/acos n))
-
-;; $$addListeners

 (defn alpha
   "Extracts the alpha value from a color."
   [color] (.alpha *applet* (int color)))

 (defn ambient
-  "Sets the ambient reflectance for shapes drawn to the screen. This is combined
-  with the ambient light component of environment. The color components set
-  through the parameters define the reflectance. For example in the default
-  color mode, setting x=255, y=126, z=0, would cause all the red light to
-  reflect and half of the green light to reflect. Used in combination with
-  emissive, specular, and shininess in setting the material properties of
-  shapes."
+  "Sets the ambient reflectance for shapes drawn to the screen. This
+  is combined with the ambient light component of environment. The
+  color components set through the parameters define the
+  reflectance. For example in the default color mode, setting x=255,
+  y=126, z=0, would cause all the red light to reflect and half of the
+  green light to reflect. Used in combination with emissive, specular,
+  and shininess in setting the material properties of shapes."
   ([gray] (.ambient *applet* (float gray)))
   ([x y z] (.ambient *applet* (float x) (float y) (float z))))

 (defn ambient-int
-  "Sets the ambient reflectance for shapes drawn to the screen. This is combined
-  with the ambient light component of environment. The rgb color components set
-  define the reflectance. Used in combination with emissive, specular, and
-  shininess in setting the material properties of shapes."
+  "Sets the ambient reflectance for shapes drawn to the screen. This
+  is combined with the ambient light component of environment. The rgb
+  color components set define the reflectance. Used in combination
+  with emissive, specular, and shininess in setting the material
+  properties of shapes."
   [rgb]
   (.ambient
    *applet* (int rgb)))

 (defn ambient-light
   "Adds an ambient light. Ambient light doesn't come from a specific direction,
-   the rays have light have bounced around so much that objects are evenly lit
-   from all sides. Ambient lights are almost always used in combination with
-   other types of lights. Lights need to be included in the draw to remain
-   persistent in a looping program. Placing them in the setup of a looping
-   program will cause them to only have an effect the first time through the
-   loop. The effect of the parameters is determined by the current color mode."
+   the rays have light have bounced around so much that objects are
+   evenly lit from all sides. Ambient lights are almost always used in
+   combination with other types of lights. Lights need to be included
+   in the draw to remain persistent in a looping program. Placing them
+   in the setup of a looping program will cause them to only have an
+   effect the first time through the loop. The effect of the
+   parameters is determined by the current color mode."
   ([red green blue]
      (.ambientLight *applet* (float red) (float green) (float blue)))
   ([red green blue x y z]
      (.ambientLight *applet* (float red) (float green) (float blue)
                     (float x) (float y) (float z))))

-;; $$append
-
 (defn apply-matrix
   "Multiplies the current matrix by the one specified through the
-  parameters. This is very slow because it will try to calculate the inverse of
-  the transform, so avoid it whenever possible. The equivalent function in
-  OpenGL is glMultMatrix()."
+  parameters. This is very slow because it will try to calculate the
+  inverse of the transform, so avoid it whenever possible. The
+  equivalent function in OpenGL is glMultMatrix()."
   ([n00 n01 n02 n10 n11 n12]
      (.applyMatrix *applet* (float n00) (float n01) (float n02)
                    (float n10) (float n11) (float n12)))
@@ -125,59 +125,64 @@
                    (float n30) (float n31) (float n32) (float 33))))

 (defn arc
-  "Draws an arc in the display window. Arcs are drawn along the outer edge of an
-  ellipse defined by the x, y, width and height parameters. The origin or the
-  arc's ellipse may be changed with the ellipseMode() function. The start and
-  stop parameters specify the angles at which to draw the arc."
+  "Draws an arc in the display window. Arcs are drawn along the outer
+  edge of an ellipse defined by the x, y, width and height
+  parameters. The origin or the arc's ellipse may be changed with the
+  ellipseMode() function. The start and stop parameters specify the
+  angles at which to draw the arc."
   [x y width height start stop]
   (.arc *applet* (float x)(float y) (float width) (float height)
         (float start) (float stop)))

-;; $$arraycopy
-
 (defn asin
-  "The inverse of sin, returns the arc sine of a value. This function expects
-  the values in the range of -1 to 1 and values are returned in the range -PI/2
-  to PI/2."
+  "The inverse of sin, returns the arc sine of a value. This function
+  expects the values in the range of -1 to 1 and values are returned
+  in the range -PI/2 to PI/2."
   [n]
   (PApplet/asin (float n)))

 (defn atan
-  "The inverse of tan, returns the arc tangent of a value. This function expects
-  the values in the range of -Infinity to Infinity (exclusive) and values are
-  returned in the range -PI/2 to PI/2 ."
+  "The inverse of tan, returns the arc tangent of a value. This
+  function expects the values in the range of -Infinity to
+  Infinity (exclusive) and values are returned in the range -PI/2 to
+  PI/2 ."
   [n]
   (PApplet/atan (float n)))

 (defn atan2
-  "Calculates the angle (in radians) from a specified point to the coordinate
-  origin as measured from the positive x-axis. Values are returned as a float in
-  the range from PI to -PI. The atan2 function is most often used for
-  orienting geometry to the position of the cursor. Note: The y-coordinate of
-  the point is the first parameter and the x-coordinate is the second due the
-  the structure of calculating the tangent."
+  "Calculates the angle (in radians) from a specified point to the
+  coordinate origin as measured from the positive x-axis. Values are
+  returned as a float in the range from PI to -PI. The atan2 function
+  is most often used for orienting geometry to the position of the
+  cursor. Note: The y-coordinate of the point is the first parameter
+  and the x-coordinate is the second due the the structure of
+  calculating the tangent."
   [y x]
   (PApplet/atan2 (float y) (float x)))

 (defn background-float
-  "Sets the color used for the background of the Processing window. The default
-  background is light gray. In the draw function, the background color is used
-  to clear the display window at the beginning of each frame.
-
-  It is not possible to use transparency (alpha) in background colors with the
-  main drawing surface, however they will work properly with create-graphics."
+  "Sets the color used for the background of the Processing
+  window. The default background is light gray. In the draw function,
+  the background color is used to clear the display window at the
+  beginning of each frame.
+
+  It is not possible to use transparency (alpha) in background colors
+  with the main drawing surface, however they will work properly with
+  create-graphics."
   ([gray] (.background *applet* (float gray)))
   ([gray alpha] (.background *applet* (float gray) (float alpha)))
   ([r g b] (.background *applet* (float r) (float g) (float b)))
   ([r g b a] (.background *applet* (float r) (float g) (float b) (float a))))

 (defn background-int
-  "Sets the color used for the background of the Processing window. The default
-  background is light gray. In the draw function, the background color is used
-  to clear the display window at the beginning of each frame.
-
-  It is not possible to use transparency (alpha) in background colors with the
-  main drawing surface, however they will work properly with create-graphics."
+  "Sets the color used for the background of the Processing
+  window. The default background is light gray. In the draw function,
+  the background color is used to clear the display window at the
+  beginning of each frame.
+
+  It is not possible to use transparency (alpha) in background colors
+  with the main drawing surface, however they will work properly with
+  create-graphics."
   ([rgb] (.background *applet* (int rgb)))
   ([rgb alpha] (.background *applet* (int rgb) (float alpha))))

@@ -185,37 +190,77 @@
        :doc (:doc (meta #'background-float))}
   background background-float)

-
 (defn background-image
-  "Specify an image to be used as the background for a sketch. Its width and
-  height must be the same size as the sketch window. Images used as background
-  will ignore the current tint setting."
+  "Specify an image to be used as the background for a sketch. Its
+  width and height must be the same size as the sketch window. Images
+  used as background will ignore the current tint setting."
   [^PImage img]
   (.background *applet* img))

 (defn begin-camera
-  "Sets the matrix mode to the camera matrix so calls such as translate, rotate,
-  apply-matrix and reset-matrix affect the camera. begin-camera should always be
-  used with a following end-camera and pairs of begin-camera and end-camera
-  cannot be nested.
+  "Sets the matrix mode to the camera matrix so calls such as
+  translate, rotate, apply-matrix and reset-matrix affect the
+  camera. begin-camera should always be used with a following
+  end-camera and pairs of begin-camera and end-camera cannot be
+  nested.

   For most situations the camera function will be sufficient."
   []
   (.beginCamera *applet*))

+(defn end-camera
+  "Unsets the matrix mode from the camera matrix. See begin-camera."
+  []
+  (.endCamera *applet*))
+
 (defn begin-raw
-  "Enables the creation of vectors from 3D data. Requires corresponding end-raw
-  command. These commands will grab the shape data just before it is rendered to
-  the screen. At this stage, your entire scene is nothing but a long list of
-  individual lines and triangles. This means that a shape created with sphere
-  method will be made up of hundreds of triangles, rather than a single
-  object. Or that a multi-segment line shape (such as a curve) will be rendered
+  "Enables the creation of vectors from 3D data. Requires
+  corresponding end-raw command. These commands will grab the shape
+  data just before it is rendered to the screen. At this stage, your
+  entire scene is nothing but a long list of individual lines and
+  triangles. This means that a shape created with sphere method will
+  be made up of hundreds of triangles, rather than a single object. Or
+  that a multi-segment line shape (such as a curve) will be rendered
   as individual segments."
   ([^PGraphics raw-gfx] (.beginRaw *applet* raw-gfx))
   ([^String renderer ^String filename]
      (.beginRaw *applet* renderer filename)))

-;; $$beginRecord
+(def ^{:private true}
+  render-modes {:p2d P2D
+                :p3d P3D
+                :java2d JAVA2D
+                :opengl OPENGL
+                :pdf PDF
+                :dxf DXF})
+
+(defn- resolve-render-mode
+  [mode]
+  (if (keyword? mode)
+    (get render-modes mode)
+    mode))
+
+(defn begin-record
+  "Opens a new file and all subsequent drawing functions are echoed to
+  this file as well as the display window. The begin-record fn
+  requires two parameters, the first is the renderer and the second is
+  the file name. This function is always used with end-record to stop
+  the recording process and close the file.
+
+  Note that begin-record will only pick up any settings that happen
+  after it has been called. For instance, if you call text-font
+  before begin-record, then that font will not be set for the file
+  that you're recording to."
+  [renderer filename]
+  (let [renderer (resolve-render-mode renderer)]
+    (println "renderer: " renderer)
+    (.beginRecord *applet* (str renderer) (str filename))))
+
+(defn end-record
+  "Stops the recording process started by begin-record and closes the
+  file."
+  []
+  (.endRecord *applet*))

 (def ^{:private true}
      shapes-map {:points POINTS
@@ -233,34 +278,37 @@
     mode))

 (defn begin-shape
-  "Enables the creation of complex forms. begin-shape begins recording vertices
-  for a shape and end-shape stops recording. Use the mode keyword to specify
-  which shape create from the provided vertices. With no mode specified, the
-  shape can be any irregular polygon.
-
-  The available mode keywords are :points, :lines, :triangles, :triangle-fan,
-                                  :triangle-strip, :quads, :quad-strip.
-
-
-  After calling the begin-shape function, a series of vertex commands must
-  follow. To stop drawing the shape, call end-shape. The vertex function with
-  two parameters specifies a position in 2D and the vertex function with three
-  parameters specifies a position in 3D. Each shape will be outlined with the
-  current stroke color and filled with the fill color.
-
-  Transformations such as translate, rotate, and scale do not work within
-  begin-shape. It is also not possible to use other shapes, such as ellipse
-  or rect within begin-shape."
+  "Enables the creation of complex forms. begin-shape begins recording
+  vertices for a shape and end-shape stops recording. Use the mode
+  keyword to specify which shape create from the provided
+  vertices. With no mode specified, the shape can be any irregular
+  polygon.
+
+  The available mode keywords are :points, :lines, :triangles,
+                                  :triangle-fan, :triangle-strip,
+                                  :quads, :quad-strip.
+
+  After calling the begin-shape function, a series of vertex commands
+  must follow. To stop drawing the shape, call end-shape. The vertex
+  function with two parameters specifies a position in 2D and the
+  vertex function with three parameters specifies a position in
+  3D. Each shape will be outlined with the current stroke color and
+  filled with the fill color.
+
+  Transformations such as translate, rotate, and scale do not work
+  within begin-shape. It is also not possible to use other shapes,
+  such as ellipse or rect within begin-shape."
   ([] (.beginShape *applet*))
   ([mode]
      (let [mode (resolve-shape-mode  mode)]
        (.beginShape *applet* (int mode)))))

 (defn bezier
-  "Draws a Bezier curve on the screen. These curves are defined by a series of
-  anchor and control points. The first two parameters specify the first anchor
-  point and the last two parameters specify the other anchor point. The middle
-  parameters specify the control points which define the shape of the curve."
+  "Draws a Bezier curve on the screen. These curves are defined by a
+  series of anchor and control points. The first two parameters
+  specify the first anchor point and the last two parameters specify
+  the other anchor point. The middle parameters specify the control
+  points which define the shape of the curve."
   ([x1 y1 cx1 cy1 cx2 cy2 x2 y2]
      (.bezier *applet*
               (float x1) (float y1)
@@ -275,17 +323,19 @@
               (float x2) (float y2) (float z2))))

 (defn bezier-detail
-  "Sets the resolution at which Beziers display. The default value is 20. This
-  function is only useful when using the P3D or OPENGL renderer as the
-  default (JAVA2D) renderer does not use this information."
+  "Sets the resolution at which Beziers display. The default value is
+  20. This function is only useful when using the P3D or OPENGL
+  renderer as the default (JAVA2D) renderer does not use this
+  information."
   [detail]
   (.bezierDetail *applet* (int detail)))

 (defn bezier-point
-  "Evaluates the Bezier at point t for points a, b, c, d. The parameter t varies
-  between 0 and 1, a and d are points on the curve, and b and c are the control
-  points. This can be done once with the x coordinates and a second time with
-  the y coordinates to get the location of a bezier curve at t."
+  "Evaluates the Bezier at point t for points a, b, c, d. The
+  parameter t varies between 0 and 1, a and d are points on the curve,
+  and b and c are the control points. This can be done once with the x
+  coordinates and a second time with the y coordinates to get the
+  location of a bezier curve at t."
   [a b c d t]
   (.bezierPoint *applet* (float a) (float b) (float c)
                 (float d) (float t)))
@@ -298,13 +348,14 @@
                   (float d) (float t)))

 (defn bezier-vertex
-  "Specifies vertex coordinates for Bezier curves. Each call to bezier-vertex
-  defines the position of two control points and one anchor point of a Bezier
-  curve, adding a new segment to a line or shape. The first time bezier-vertex
-  is used within a begin-shape call, it must be prefaced with a call to
-  vertex to set the first anchor point. This function must be used between
-  begin-shape and end-shape and only when there is no parameter specified
-  to begin-shape."
+  "Specifies vertex coordinates for Bezier curves. Each call to
+  bezier-vertex defines the position of two control points and one
+  anchor point of a Bezier curve, adding a new segment to a line or
+  shape. The first time bezier-vertex is used within a begin-shape
+  call, it must be prefaced with a call to vertex to set the first
+  anchor point. This function must be used between begin-shape and
+  end-shape and only when there is no parameter specified to
+  begin-shape."
   ([cx1 cy1 cx2 cy2 x y]
      (.bezierVertex *applet*
                     (float cx1) (float cx1)
@@ -316,7 +367,18 @@
                     (float cx2) (float cy2) (float cz2)
                     (float x) (float y) (float z))))

-;; $$binary
+(defn binary
+  "Returns a string representing the binary value of an int, char or
+  byte. When converting an int to a string, it is possible to specify
+  the number of digits used."
+  ([val] (PApplet/binary (if (number? val) (int val) val)))
+  ([val num-digits] (PApplet/binary (int val) (int num-digits))))
+
+(defn unbinary
+  "Unpack a binary string to an integer. See binary for converting
+  integers to strings."
+  [str-val]
+  (PApplet/unbinary (str str-val)))

 (def ^{:private true}
   blend-map {:blend BLEND
@@ -341,29 +403,36 @@
     mode))

 (defn blend
-  "Blends a region of pixels from one image into another (or in itself again)
-  with full alpha channel support.
+  "Blends a region of pixels from one image into another (or in itself
+  again) with full alpha channel support.

   Available blend modes are:

   :blend      - linear interpolation of colours: C = A*factor + B
-  :add        - additive blending with white clip: C = min(A*factor + B, 255)
-  :subtract   - subtractive blending with black clip: C = max(B - A*factor, 0)
-  :darkest    - only the darkest colour succeeds: C = min(A*factor, B)
-  :lightest   - only the lightest colour succeeds: C = max(A*factor, B)
+  :add        - additive blending with white clip:
+                                            C = min(A*factor + B, 255)
+  :subtract   - subtractive blending with black clip:
+                                            C = max(B - A*factor, 0)
+  :darkest    - only the darkest colour succeeds:
+                                            C = min(A*factor, B)
+  :lightest   - only the lightest colour succeeds:
+                                            C = max(A*factor, B)
   :difference - subtract colors from underlying image.
   :exclusion  - similar to :difference, but less extreme.
   :multiply   - Multiply the colors, result will always be darker.
   :screen     - Opposite multiply, uses inverse values of the colors.
-  :overlay    - A mix of :multiply and :screen. Multiplies dark values, and
-                screens light values.
-  :hard-light - :screen when greater than 50% gray, :multiply when lower.
-  :soft-light - Mix of :darkest and :lightest. Works like :overlay, but not as
-                harsh.
-  :dodge      - Lightens light tones and increases contrast, ignores darks.
+  :overlay    - A mix of :multiply and :screen. Multiplies dark values
+                and screens light values.
+  :hard-light - :screen when greater than 50% gray, :multiply when
+                lower.
+  :soft-light - Mix of :darkest and :lightest. Works like :overlay,
+                but not as harsh.
+  :dodge      - Lightens light tones and increases contrast, ignores
+                darks.
                 Called \"Color Dodge\" in Illustrator and Photoshop.
-  :burn       - Darker areas are applied, increasing contrast, ignores lights.
-                Called \"Color Burn\" in Illustrator and Photoshop."
+  :burn       - Darker areas are applied, increasing contrast, ignores
+                lights. Called \"Color Burn\" in Illustrator and
+                Photoshop."
   ([x y width height dx dy dwidth dheight mode]
      (let [mode (resolve-blend-mode mode)]
        (.blend *applet* (int x) (int y) (int width) (int height)
@@ -379,31 +448,39 @@

   Available blend modes are:

+
   :blend      - linear interpolation of colours: C = A*factor + B
-  :add        - additive blending with white clip: C = min(A*factor + B, 255)
-  :subtract   - subtractive blending with black clip: C = max(B - A*factor, 0)
-  :darkest    - only the darkest colour succeeds: C = min(A*factor, B)
-  :lightest   - only the lightest colour succeeds: C = max(A*factor, B)
+  :add        - additive blending with white clip:
+                                            C = min(A*factor + B, 255)
+  :subtract   - subtractive blending with black clip:
+                                            C = max(B - A*factor, 0)
+  :darkest    - only the darkest colour succeeds:
+                                            C = min(A*factor, B)
+  :lightest   - only the lightest colour succeeds:
+                                            C = max(A*factor, B)
   :difference - subtract colors from underlying image.
   :exclusion  - similar to :difference, but less extreme.
   :multiply   - Multiply the colors, result will always be darker.
   :screen     - Opposite multiply, uses inverse values of the colors.
-  :overlay    - A mix of :multiply and :screen. Multiplies dark values, and
-                screens light values.
-  :hard-light - :screen when greater than 50% gray, :multiply when lower.
-  :soft-light - Mix of :darkest and :lightest. Works like :overlay, but not as
-                harsh.
-  :dodge      - Lightens light tones and increases contrast, ignores darks.
+  :overlay    - A mix of :multiply and :screen. Multiplies dark values
+                and screens light values.
+  :hard-light - :screen when greater than 50% gray, :multiply when
+                lower.
+  :soft-light - Mix of :darkest and :lightest. Works like :overlay,
+                but not as harsh.
+  :dodge      - Lightens light tones and increases contrast, ignores
+                darks.
                 Called \"Color Dodge\" in Illustrator and Photoshop.
-  :burn       - Darker areas are applied, increasing contrast, ignores lights.
-                Called \"Color Burn\" in Illustrator and Photoshop."
+  :burn       - Darker areas are applied, increasing contrast, ignores
+                lights. Called \"Color Burn\" in Illustrator and
+                Photoshop."
   [c1 c2 mode]
   (let [mode (resolve-blend-mode mode)]
     (PApplet/blendColor (int c1) (int c2) (int mode))))

 (defn blue
   "Extracts the blue value from a color, scaled to match current color-mode.
-  Returns a float. "
+  Returns a float."
   [color]
   (.blue *applet* (int color)))

@@ -418,12 +495,13 @@
   (.brightness *applet* (int color)))

 (defn camera
-  "Sets the position of the camera through setting the eye position, the center
-  of the scene, and which axis is facing upward. Moving the eye position and
-  the direction it is pointing (the center of the scene) allows the images to be
-  seen from different angles. The version without any parameters sets the camera
-  to the default position, pointing to the center of the display window with the
-  Y axis as up. The default values are:
+  "Sets the position of the camera through setting the eye position,
+  the center of the scene, and which axis is facing upward. Moving the
+  eye position and the direction it is pointing (the center of the
+  scene) allows the images to be seen from different angles. The
+  version without any parameters sets the camera to the default
+  position, pointing to the center of the display window with the Y
+  axis as up. The default values are:

   eyeX:     (/ (width) 2.0)
   eyeY:     (/ (height) 2.0)
@@ -435,58 +513,114 @@
   upY:      1
   upZ:      0

-  Similar imilar to gluLookAt() in OpenGL, but it first clears the current
-  camera settings."
+  Similar imilar to gluLookAt() in OpenGL, but it first clears the
+  current camera settings."
   ([] (.camera *applet*))
   ([eyeX eyeY eyeZ centerX centerY centerZ upX upY upZ]
      (.camera *applet* (float eyeX) (float eyeY) (float eyeZ)
               (float centerX) (float centerY) (float centerZ)
               (float upX) (float upY) (float upZ))))

-(defn can-draw? [] (.canDraw *applet*))
-
 (defn ceil
-  "Calculates the closest int value that is greater than or equal to the value
-  of the parameter. For example, (ceil 9.03) returns the value 10."
+  "Calculates the closest int value that is greater than or equal to
+  the value of the parameter. For example, (ceil 9.03) returns the
+  value 10."
   [n]
   (PApplet/ceil (float n)))

 (defn color-float
+  "Creates an integer representation of a color The parameters are
+  interpreted as RGB or HSB values depending on the current
+  color-mode. The default mode is RGB values from 0 to 255 and
+  therefore, the function call (color 255 204 0) will return a bright
+  yellow. Args are cast to floats.
+
+  r - red or hue value
+  g - green or saturation value
+  b - blue or brightness value
+  a - alpha value"
   ([gray] (.color *applet* (float gray)))
   ([gray alpha] (.color *applet* (float gray) (float alpha)))
   ([r g b] (.color *applet* (float r) (float g) (float b)))
   ([r g b a] (.color *applet* (float r) (float g) (float b) (float a))))

 (defn color-int
+    "Creates an integer representation of a color The parameters are
+  interpreted as RGB or HSB values depending on the current
+  color-mode. The default mode is RGB values from 0 to 255 and
+  therefore, the function call (color 255 204 0) will return a bright
+  yellow. Args are cast to ints.
+
+  r - red or hue value
+  g - green or saturation value
+  b - blue or brightness value
+  a - alpha value"
   ([gray] (.color *applet* (int gray)))
   ([gray alpha] (.color *applet* (int gray) (float alpha)))
   ([r g b] (.color *applet* (int r) (int g) (int b)))
   ([r g b a] (.color *applet* (int r) (int g) (int b) (int a))))

-(def color color-float)
+(def ^{:arglists (:arglists (meta #'color-float))
+       :doc (:doc (meta #'color-float))}
+  color color-float)
+
+(defn ^{:private true}
+  color-modes {:rgb RGB
+               :hsb HSB})
+
+(defn- resolve-color-mode
+  [mode]
+  (if (keyword? mode)
+    (get color-modes mode)
+    mode))

 (defn color-mode
-  ([mode] (.colorMode *applet* (int mode)))
-  ([mode max] (.colorMode *applet* (int mode) (float max)))
+  "Changes the way Processing interprets color data. Available modes
+  are :rgb and :hsb.By default, the parameters for fill, stroke,
+  background, and color are defined by values between 0 and 255 using
+  the :rgb color model. The color-mode fn is used to change the
+  numerical range used for specifying colors and to switch color
+  systems. For example, calling
+  (color-mode :rgb 1.0) will specify that values are specified between
+  0 and 1. The limits for defining colors are altered by setting the
+  parameters range1, range2, range3, and range 4."
+  ([mode]
+     (let [mode (resolve-color-mode mode)]
+       (.colorMode *applet* (int mode))))
+  ([mode max]
+     (let [mode (resolve-color-mode mode)]
+       (.colorMode *applet* (int mode) (float max))))
   ([mode max-x max-y max-z]
-     (.colorMode *applet* (int mode) (float max-x) (float max-y) (float max-z)))
+     (let [mode (resolve-color-mode mode)]
+       (.colorMode *applet* (int mode) (float max-x) (float max-y) (float max-z))))
   ([mode max-x max-y max-z max-a]
-     (.colorMode *applet* (int mode)
-                 (float max-x) (float max-y) (float max-z) (float max-a))))
-
-;; $$concat
+     (let [mode (resolve-color-mode mode)]
+       (.colorMode *applet* (int mode) (float max-x) (float max-y) (float max-z) (float max-a)))))

 (defn constrain-float
+  "Constrains a value to not exceed a maximum and minimum value. All
+  args are cast to floats."
   [amt low high]
   (PApplet/constrain (float amt) (float low) (float high)))

 (defn constrain-int
+  "Constrains a value to not exceed a maximum and minimum value. All
+  args are cast to ints."
   [amt low high]
   (PApplet/constrain (int amt) (int low) (int high)))

-(def constrain constrain-float)
+(def ^{:arglists (:arglists (meta #'constrain-float))
+       :doc (:doc (meta #'constrain-float))}
+  constrain constrain-float)

 (defn copy
+  "Copies a region of pixels from the display window to another area
+  of the display window and copies a region of pixels from an image
+  used as the src-img parameter into the display window. If the source
+  and destination regions aren't the same size, it will automatically
+  resize the source pixels to fit the specified target region. No
+  alpha information is used in the process, however if the source
+  image has an alpha channel set, it will be copied as well. "
   ([[sx1 sy1 sx2 sy2] [dx1 dy1 dx2 dy2]]
      (.copy *applet* (int sx1) (int sy1) (int sx2) (int sy2)
             (int dx1) (int dy1) (int dx2) (int dy2)))
@@ -532,15 +666,52 @@

 (defn create-writer [filename] (.createWriter *applet* filename))

+(def ^{:private true}
+  cursor-modes {:arrow PConstants/ARROW
+                :cross PConstants/CROSS
+                :hand PConstants/HAND
+                :move PConstants/MOVE
+                :text PConstants/TEXT
+                :wait PConstants/WAIT})
+
+(defn- resolve-cursor-mode
+  [mode]
+  (if (keyword? mode)
+    (get cursor-modes mode)
+    mode))
+
 (defn cursor
+  "Sets the cursor to a predefined symbol, an image, or makes it
+  visible if already hidden. If you are trying to set an image as the
+  cursor, it is recommended to make the size 16x16 or 32x32 pixels.
+  The values for parameters x and y must be less than the dimensions
+  of the image.
+
+  Available modes: :arrow, :cross, :hand, :move, :text, :wait
+
+  Setting or hiding the cursor generally does not work with 'Present'
+  mode (when running full-screen).
+
+  See cursor-image for specifying a generic image as the cursor
+  symbol."
   ([] (.cursor *applet*))
-  ([cur-type] (.cursor *applet* (int cur-type))))
+  ([cursor-mode] (.cursor *applet* (int (resolve-cursor-mode cur-type)))))

 (defn cursor-image
+  "Set the cursor to a predefined image. The horizontal and vertical
+  active spots of the cursor may be specified with hx and hy"
   ([^PImage img] (.cursor *applet* img))
   ([^PImage img hx hy] (.cursor *applet* img (int hx) (int hy))))

 (defn curve
+  "Draws a curved line on the screen. The first and second parameters
+  specify the beginning control point and the last two parameters
+  specify the ending control point. The middle parameters specify the
+  start and stop of the curve. Longer curves can be created by putting
+  a series of curve fns together or using curve-vertex. An additional
+  fn called curve-tightness provides control for the visual quality of
+  the curve. The curve fn is an implementation of Catmull-Rom
+  splines."
   ([x1 y1 x2 y2 x3 y3 x4 y4]
      (.curve *applet*
              (float x1) (float y1)
@@ -554,17 +725,39 @@
              (float x3) (float y3) (float z3)
              (float x4) (float y4) (float z4))))

-(defn curve-detail [detail] (.curveDetail *applet* (int detail)))
+(defn curve-detail
+  "Sets the resolution at which curves display. The default value is
+  20. This function is only useful when using the P3D or OPENGL
+  renderer as the default (JAVA2D) renderer does not use this
+  information."
+  [detail]
+  (.curveDetail *applet* (int detail)))

 (defn curve-point
+  "Evalutes the curve at point t for points a, b, c, d. The parameter
+  t varies between 0 and 1, a and d are points on the curve, and b and
+  c are the control points. This can be done once with the x
+  coordinates and a second time with the y coordinates to get the
+  location of a curve at t."
   [a b c d t]
   (.bezierPoint *applet* (float a) (float b) (float c) (float d) (float t)))

 (defn curve-tangent
+  "Calculates the tangent of a point on a curve.
+  See: http://en.wikipedia.org/wiki/Tangent"
   [a b c d t]
   (.curveTangent *applet* (float a) (float b) (float c) (float d) (float t)))

-(defn curve-tightness [ti]
+(defn curve-tightness
+  "Modifies the quality of forms created with curve and
+  curve-vertex. The parameter squishy determines how the curve fits
+  to the vertex points. The value 0.0 is the default value for
+  squishy (this value defines the curves to be Catmull-Rom splines)
+  and the value 1.0 connects all the points with straight
+  lines. Values within the range -5.0 and 5.0 will deform the curves
+  but will leave them recognizable and as values increase in
+  magnitude, they will continue to deform."
+  [ti]
   (.curveTightness *applet* (float ti)))

 (defn curve-vertex
@@ -628,20 +821,16 @@
   (.directionalLight *applet* (float r) (float g) (float b)
                      (float nx) (float ny) (float nz)))

-(defn displayable? [] (.displayable *applet*))
-
 (defn dist
   "Calculates the distance between two points"
   ([x1 y1 x2 y2] (PApplet/dist (float x1) (float y1) (float x2) (float y2)))
   ([x1 y1 z1 x2 y2 z2] (PApplet/dist (float x1) (float y1) (float z1)
                                (float x2) (float y2) (float z2))))

-;; $$draw
-
 (defn ellipse
-  "Draws an ellipse (oval) in the display window. An ellipse with an equal width
-  and height is a circle.  The origin may be changed with the ellipse-mode
-  function"
+  "Draws an ellipse (oval) in the display window. An ellipse with an
+  equal width and height is a circle.  The origin may be changed with
+  the ellipse-mode function"
   [x y width height]
   (.ellipse *applet* (float x) (float y) (float width) (float height)))

@@ -651,7 +840,7 @@
                     :corner CORNER
                     :corners CORNERS})

-(defn- recolve-ellipse-mode
+(defn- resolve-ellipse-mode
   [mode]
   (if (keyword? mode)
     (get ellipse-map mode)
@@ -674,15 +863,30 @@
     (.ellipseMode *applet* (int mode))))

 (defn emissive-float
-  ([gray] (.emissive *applet* (float gray)))
-  ([x y z] (.emissive *applet* (float x) (float y) (float z))))
+  "Sets the emissive color of the material used for drawing shapes
+ drawn to the screen. Used in combination with ambient, specular, and
+ shininess in setting the material properties of shapes. Converts all
+ args to floats"
+  ([float-val] (.emissive *applet* (float float-val)))
+  ([r g b] (.emissive *applet* (float r) (float g) (float b))))

 (defn emissive-int
-  [gray] (.emissive *applet* (int gray)))
-
-(def emissive emissive-float)
-
-(defn end-camera [] (.endCamera *applet*))
+  "Sets the emissive color of the material used for drawing shapes
+  drawn to the screen. Used in combination with ambient, specular, and
+  shininess in setting the material properties of shapes. Converts all
+  args to ints"
+  ([int-val] (.emissive *applet* (int int-val)))
+  ([r g b] (.emissive *applet* (int r) (int g) (int b))))
+
+(defn emissive
+  "Sets the emissive color of the material used for drawing shapes
+   drawn to the screen. Used in combination with ambient, specular,
+   and shininess in setting the material properties of shapes.
+
+  If passed one arg - it is assumed to be an int (i.e. a color),
+   multiple args are converted to floats."
+  ([col-int]) (.emissive *applet* (int col-int))
+  ([r g b] (.emissive *applet* (float r) (float g) (float b))))

 (defn end-raw [] (.endRaw *applet*))

@@ -710,13 +914,14 @@
 (defn exp
   "Returns Euler's number e (2.71828...) raised to the power of the
   value parameter."
-  [val] (PApplet/exp (float val)))
+  [val]
+  (PApplet/exp (float val)))

 ;; $$expand

 (defn fill-float
-  "Sets the color used to fill shapes. For example, (fill 204 102 0), will
-  specify that all subsequent shapes will be filled with orange."
+  "Sets the color used to fill shapes. For example, (fill 204 102 0),
+  will specify that all subsequent shapes will be filled with orange."
   ([gray] (.fill *applet* (float gray)))
   ([gray alpha] (.fill *applet* (float gray) (float alpha)))
   ([x y z] (.fill *applet* (float x) (float y) (float z)))
@@ -791,12 +996,13 @@
   (.frameCount *applet*))

 (defn frame-rate
-  "With no args, returns the current framerate. With one arg specifies a new
-  target framerate (number of frames to be displayed every second). If the
-  processor is not fast enough to maintain the specified rate, it will not be
-  achieved. For example, the function call (frame-rate 30) will attempt to
-  refresh 30 times a second. It is recommended to set the frame rate within
-  setup. The default rate is 60 frames per second."
+  "With no args, returns the current framerate. With one arg specifies
+  a new target framerate (number of frames to be displayed every
+  second). If the processor is not fast enough to maintain the
+  specified rate, it will not be achieved. For example, the function
+  call (frame-rate 30) will attempt to refresh 30 times a second. It
+  is recommended to set the frame rate within setup. The default rate
+  is 60 frames per second."
   ([] (.frameRate *applet*))
   ([new-rate]
      (.frameRate *applet* (float new-rate))))
@@ -817,7 +1023,8 @@
 ;; $$hex

 (defn height
-  "Height of the display window. The value of height is zero until size() is called."
+  "Height of the display window. The value of height is zero until
+  size() is called."
   []
   (.getHeight *applet*))

@@ -859,13 +1066,13 @@
   (.lightSpecular *applet* (float x) (float y) (float z)))

 (defn line
-  "Draws a line (a direct path between two points) to the screen. The version of
-  line with four parameters draws the line in 2D. To color a line, use the
-  stroke function. A line cannot be filled, therefore the fill method will
-  not affect the color of a line. 2D lines are drawn with a width of one pixel
-  by default, but this can be changed with the stroke-weight function. The
-  version with six parameters allows the line to be placed anywhere within XYZ
-  space. "
+  "Draws a line (a direct path between two points) to the screen. The
+  version of line with four parameters draws the line in 2D. To color
+  a line, use the stroke function. A line cannot be filled, therefore
+  the fill method will not affect the color of a line. 2D lines are
+  drawn with a width of one pixel by default, but this can be changed
+  with the stroke-weight function. The version with six parameters
+  allows the line to be placed anywhere within XYZ space. "
   ([p1 p2] (apply line (concat p1 p2)))
   ([x1 y1 x2 y2] (.line *applet* (float x1) (float y1) (float x2) (float y2)))
   ([x1 y1 z1 x2 y2 z2]
@@ -894,7 +1101,11 @@
   [filename]
   (.loadStrings *applet* filename))

-;; $$log
+(defn log
+  "Calculates the natural logarithm (the base-e logarithm) of a
+  number. This function expects the values greater than 0.0."
+  [val]
+  (PApplet/log (float val)))

 (defn start-loop [] (.loop *applet*))

@@ -938,13 +1149,10 @@
   []
   (PApplet/month))

-;; $$mouseClicked
-;; $$mouseDragged
+
 ;; $$mouseEntered
 ;; $$mouseExited
-;; $$mouseMoved
-;; $$mousePressed
-;; $$mouseReleased
+
 ;; $$nf
 ;; $$nfc
 ;; $$nfp
@@ -963,9 +1171,8 @@
 (defn no-cursor [] (.noCursor *applet*))

 (defn no-fill
- "Disables filling geometry. If both no-stroke and no-fill are called, nothing
-  will be drawn to the screen."
- []
+ "Disables filling geometry. If both no-stroke and no-fill are called,
+  nothing will be drawn to the screen."  []
  (.noFill *applet*))

 (defn noise
@@ -1024,8 +1231,8 @@
   [] (.noSmooth *applet*))

 (defn no-stroke
-  "Disables drawing the stroke (outline). If both no-stroke and no-fill are
-  called, nothing will be drawn to the screen."
+  "Disables drawing the stroke (outline). If both no-stroke and
+  no-fill are called, nothing will be drawn to the screen."
   []
   (.noStroke *applet*))

@@ -1094,15 +1301,21 @@
   [num exponent]
   (PApplet/pow (float num) (float exponent)))

-;; $$print
-
-(defn print-camera [] (.printCamera *applet*))
-
-;; $$println
-
-(defn print-matrix [] (.printMatrix *applet*))
-
-(defn print-projection [] (.printProjection *applet*))
+(defn print-camera
+  "Prints the current camera matrix to std out. Useful for debugging."
+  []
+  (.printCamera *applet*))
+
+(defn print-matrix
+  "Prints the current matrix to std out. Useful for debugging."
+  []
+  (.printMatrix *applet*))
+
+(defn print-projection
+  "Prints the current projection matrix to std out. Useful for
+  debugging"
+  []
+  (.printProjection *applet*))

 (defn push-matrix
   "Pushes the current transformation matrix onto the matrix
@@ -1118,10 +1331,10 @@

 (defn quad
   "A quad is a quadrilateral, a four sided polygon. It is similar to a
-  rectangle, but the angles between its edges are not constrained to be ninety
-  degrees. The first pair of parameters (x1,y1) sets the first vertex and the
-  subsequent pairs should proceed clockwise or counter-clockwise around the
-  defined shape."
+  rectangle, but the angles between its edges are not constrained to
+  be ninety degrees. The first pair of parameters (x1,y1) sets the
+  first vertex and the subsequent pairs should proceed clockwise or
+  counter-clockwise around the defined shape."
   [x1 y1 x2 y2 x3 y3 x4 y4]
   (.quad *applet*
          (float x1) (float y1)
@@ -1156,10 +1369,11 @@
 (defn random-seed [w] (.randomSeed *applet* (float w)))

 (defn rect
-  "Draws a rectangle to the screen. A rectangle is a four-sided shape with every
-   angle at ninety degrees. By default, the first two parameters set the
-   location of the upper-left corner, the third sets the width, and the fourth
-   sets the height. These parameters may be changed with rect-mode."
+  "Draws a rectangle to the screen. A rectangle is a four-sided shape
+   with every angle at ninety degrees. By default, the first two
+   parameters set the location of the upper-left corner, the third
+   sets the width, and the fourth sets the height. These parameters
+   may be changed with rect-mode."
   [x y width height]
   (.rect *applet* (float x) (float y) (float width) (float height)))

@@ -1209,8 +1423,8 @@
 (defn rotate-x
   "Rotates a shape around the x-axis the amount specified by the angle
   parameter. Angles should be specified in radians (values from 0 to
-  (* PI 2)) or converted to radians with the radians function. Objects are
-  always rotated around their relative position to the origin and
+  (* PI 2)) or converted to radians with the radians function. Objects
+  are always rotated around their relative position to the origin and
   positive numbers rotate objects in a counterclockwise
   direction. Transformations apply to everything that happens after
   and subsequent calls to the function accumulates the effect. For
@@ -1263,12 +1477,12 @@
 ;; $$saveFile

 (defn save-frame
-  "Saves an image identical to the current display window as a file. May be
-  called multple times - each file saved will have a unique name. Name and image
-  formate may be modified by passing a string parameter of the form
-  \"foo-####.ext\" where foo- can be any arbitrary string, #### will be replaced
-  with the current frame id and .ext is one of .tiff, .targa, .png, .jpeg or
-  .jpg
+  "Saves an image identical to the current display window as a
+  file. May be called multple times - each file saved will have a
+  unique name. Name and image formate may be modified by passing a
+  string parameter of the form \"foo-####.ext\" where foo- can be any
+  arbitrary string, #### will be replaced with the current frame id
+  and .ext is one of .tiff, .targa, .png, .jpeg or .jpg

   Examples:
   (save-frame)
@@ -1345,9 +1559,9 @@
 ;; $$shorten

 (defn sin
-  "Calculates the sine of an angle. This function expects the values of the
-  angle parameter to be provided in radians (values from 0 to 6.28). A float
-  within the range -1 to 1 is returned."
+  "Calculates the sine of an angle. This function expects the values
+  of the angle parameter to be provided in radians (values from 0 to
+  6.28). A float within the range -1 to 1 is returned."
   [angle]
   (PApplet/sin (float angle)))

@@ -1361,8 +1575,9 @@
 ;; $$sketchPath

 (defn smooth
-  "Draws all geometry with smooth (anti-aliased) edges. This will slow down the
-  frame rate of the application, but will enhance the visual refinement.
+  "Draws all geometry with smooth (anti-aliased) edges. This will slow
+  down the frame rate of the application, but will enhance the visual
+  refinement.

   Note that smooth will also improve image quality of resized images."
   []
@@ -1455,9 +1670,9 @@
   stroke stroke-float)

 (defn stroke-cap
-  "Sets the style for rendering line endings. These ends are either squared,
-  extended, or rounded and specified with the corresponding parameters :square,
-  :project, and :round. The default cap is :round. "
+  "Sets the style for rendering line endings. These ends are either
+  squared, extended, or rounded and specified with the corresponding
+  parameters :square, :project, and :round. The default cap is :round."
   [cap-mode]
   (let [cap-mode (resolve-stroke-cap-mode cap-mode)]
     (.strokeCap *applet* (int cap-mode))))
@@ -1465,8 +1680,8 @@
 (defn stroke-join [jn] (.strokeJoin *applet* (int jn)))

 (defn stroke-weight
-  "Sets the width of the stroke used for lines, points, and the border around
-  shapes. All widths are set in units of pixels. "
+  "Sets the width of the stroke used for lines, points, and the border
+  around shapes. All widths are set in units of pixels. "
   [weight]
   (.strokeWeight *applet* (float weight)))

@@ -1552,9 +1767,10 @@
   ([tx ty tz] (.translate *applet* (float tx) (float ty) (float tz))))

 (defn triangle
-  "A triangle is a plane created by connecting three points. The first two
-  arguments specify the first point, the middle two arguments specify the second
-  point, and the last two arguments specify the third point."
+  "A triangle is a plane created by connecting three points. The first
+  two arguments specify the first point, the middle two arguments
+  specify the second point, and the last two arguments specify the
+  third point."
   [x1 y1 x2 y2 x3 y3]
   (.triangle *applet*
              (float x1) (float y1)
@@ -1562,7 +1778,6 @@
              (float x3) (float y3)))

 ;; $$trim
-;; $$unbinary
 ;; $$unhex
 ;; $$unint
 ;; $$unregisterDispose
@@ -1626,7 +1841,8 @@
   (.getWidth *applet*))

 (defmacro with-translation
-  "Berforms body with translation, restores current transformation on exit."
+  "Berforms body with translation, restores current transformation on
+  exit."
   [translation-vector & body]
   `(let [tr# ~translation-vector]
      (push-matrix)


Implement resource-data for ring 1.4.0 when it arrives [IMMUTANT-525]

--- web/src/immutant/web/internal/ring.clj
+++ web/src/immutant/web/internal/ring.clj
@@ -16,7 +16,8 @@
     (:require [potemkin                      :refer [def-map-type]]
               [clojure.java.io               :as io]
               [immutant.web.async            :as async]
-              [immutant.web.internal.headers :as hdr])
+              [immutant.web.internal.headers :as hdr]
+              [immutant.internal.util        :refer [try-resolve]])
     (:import [java.io File InputStream OutputStream]
              [clojure.lang ISeq PersistentHashMap]))

@@ -147,3 +148,21 @@
     (if (async/streaming-body? body)
       (async/open-stream body hmap)
       (write-body body (output-stream response) hmap))))
+
+;; ring 1.3.2 introduced a change that causes wrap-resource to break
+;; in-container because it doesn't know how to handle vfs: urls. ring
+;; 1.4.0 will include a multi-method that allows us to provide the
+;; correct data for vfs: urls, so we provide an implementation here
+;; see IMMUTANT-525 for more details
+(when (try-resolve 'ring.util.response/resource-data)
+  (eval
+    '(defmethod ring.util.response/resource-data :vfs
+       [url]
+       (let [conn (.openConnection url)
+             vfile (.getContent conn)]
+         (when-not (.isDirectory vfile)
+           {:content (.getInputStream conn)
+            :content-length (.getContentLength conn)
+            :last-modified (-> vfile
+                             .getPhysicalFile
+                             ring.util.io/last-modified-date)})))))


use babel.morph/analyze directly rather than re-implementing in babel.italiano.morphology

--- src/babel/italiano/morphology.cljc
+++ src/babel/italiano/morphology.cljc
@@ -14,6 +14,7 @@
             plural-to-singular-noun-masc-1
             plural-to-singular-noun-masc-2)]
    [babel.italiano.morphology.verbs :as verbs]
+   [babel.morphology :as language-independent]
    [babel.stringutils :refer (replace-from-list)]
    [clojure.string :as string]
    [clojure.string :refer (trim)]
@@ -71,7 +72,6 @@
    ["su gli" "sugli"]
    ["su le"  "sulle"]
       ])
-

 ;; TODO: pre-compile these rules rather than building regexp objects at runtime.
 (defn apply-one-rule [string from-to-pair]
@@ -685,36 +685,7 @@

 (defn analyze-regular [surface-form lexicon]
   "do regular (i.e. non-exceptional) morphological analysis to determine lexical information for a conjugated surface-form, using the (defonce replace-patterns) defined above."
-  (mapcat
-   (fn [replace-pattern]
-     (let [ ;; regular expression that matches the surface form
-           from (nth (:p replace-pattern) 0)]
-       (log/debug (str "trying replace-pattern:" replace-pattern " against surface-form: " surface-form))
-       (when (re-matches from surface-form)
-         (log/debug (str "found matching replace-pattern:" replace-pattern " for surface-form: " surface-form))
-         (log/debug (str "using unify-with: " (:u replace-pattern)))
-         (let [;; expression that is used by string/replace along with the first regexp and the surface form,
-               ;; to create the lexical string
-               to (nth (:p replace-pattern) 1)
-               ;; unifies with the lexical entry to create the inflected form.
-               unify-with (if (:u replace-pattern)
-                            (:u replace-pattern)
-                            :top) ;; default unify-with
-               debug (log/debug (str "surface-form: " surface-form "; from: " from "; to:" to))
-               potential-lexical-form
-               (try
-                 (string/replace surface-form from to)
-                 (catch Exception e
-                   (throw (Exception. (str "Can't string/replace on: "
-                                           "surface-form: " surface-form "; from: " from "; to:" to)))))]
-           (filter (fn [result] (not (= :fail result)))
-                   (let [map-fn #?(:clj pmap) #?(:cljs map)]
-                     (map-fn (fn [lexical-entry]
-                               (let [result (unify unify-with lexical-entry)]
-                                 (log/debug (str "unify result:" result))
-                                 result))
-                             (get lexicon potential-lexical-form))))))))
-   replace-patterns))
+  (language-independent/analyze surface-form lexicon replace-patterns))

 (declare analyze-capitalization-variant)


cleanup

cleanup

--- src/babel/italiano/morphology.cljc
+++ src/babel/italiano/morphology.cljc
@@ -108,31 +108,9 @@
 ;; TODO: use replace patterns instead (as with French)
 ;; TODO: split into morphology/verb function, morphology/noun function, etc.
 (defn get-string-1 [word]
-  (if (seq? word)
-    (map (string/join " " #(get-string-1 %))
-         word)
   (let [person (get-in word '(:agr :person))
         number (get-in word '(:agr :number))]
-    (log/trace "get-string-1: input word: " word)
-
-    (log/debug (str "word's a is a string? " (get-in word '(:a)) " => " (string? (get-in word '(:a)))))
-    (log/debug (str "word's b is a map? " (get-in word '(:b)) " => " (map? (get-in word '(:b)))))
-
-    (log/debug (str "word's a italian is a string? " (get-in word '(:a :italiano)) " => " (string? (get-in word '(:a :italiano)))))
-
     (cond
-
-     (= word :top) ".."
-
-     (ref? word)
-     (get-string-1 @word)
-
-     ;; TODO: this is a special case that should be handled below instead
-     ;; of forcing every input to go through this check.
-     (= word {:initial false})
-     ".."
-     (= word {:initial true})
-     ".."

      (and (string? (get-in word '(:a)))
           (string? (get-in word '(:b))))
@@ -149,6 +127,9 @@
      (get-string
       (get-in word '(:a))
       (get-in word '(:b)))
+
+     (= :verb (get-in word [:cat]))
+     (verbs/conjugate word)

      ;; TODO: this rule is pre-empting all of the following rules
      ;; that look in :a and :b. Either remove those following rules
@@ -316,10 +297,6 @@
           (string? (get-in word '(:italiano))))
      (get-in word '(:italiano))

-
-     (= :verb (get-in word [:cat]))
-     (verbs/conjugate word)
-
      (and
       (get-in word '(:a))
       (get-in word '(:b)))
@@ -414,7 +391,7 @@
      ;; in other words, if we've gotten this far, it's a bug.
      :else
      word)
-    )))
+    ))

 ;; TODO: replace 'a' and 'b' with 'left' and 'right': latter easier to talk about
 (defn get-string [a & [ b ]]


Newline at the end of gitignore.

Newline at the end of gitignore.

--- src/leiningen/new.clj
+++ src/leiningen/new.clj
@@ -56,7 +56,8 @@
              test-ns (str prefix ".test.core")
              project-clj (ns->path project-ns)]
          (spit (file project-dir ".gitignore")
-               (join "\n" ["pom.xml" "*jar" "lib" "classes"]))
+               (apply str (interleave ["pom.xml" "*jar" "lib" "classes"]
+                                      (repeat "\n"))))
          (write-implementation project-dir project-clj project-ns)
          (write-test project-dir test-ns project-ns)
          (write-readme project-dir artifact-id)


get all the angles depending on angles?

get all the angles depending on angles?

--- src/clj/ephemeris/core.clj
+++ src/clj/ephemeris/core.clj
@@ -7,7 +7,7 @@
 (def defaults {:utc nil
                :geo {:lat nil :lon nil}
                :bodies []
-               :angles []
+               :angles true
                :houses "O"})

 (defn- geo? [geo]
@@ -69,6 +69,10 @@
                               (int (coerce-houses (:houses want)))
                               cusps
                               ascmc)]
-          (if (houses? (:houses want))
-            {:houses (zipmap (range 1 13) (rest cusps))}
-            {}))))))
+          (merge
+            (if (houses? (:houses want))
+              {:houses (zipmap (range 1 13) (rest cusps))}
+              {})
+            (if (angles? (:angles want))
+              {:angles (subvec (vec ascmc) 0 8)}
+              {})))))))


fix access-helper-hq function

fix access-helper-hq function

--- src/clj/game/core-runs.clj
+++ src/clj/game/core-runs.clj
@@ -202,12 +202,12 @@
    :effect (req (case target
                   "Unrezzed upgrade in HQ"
                   ;; accessing an unrezzed upgrade
-                  (let [unrezzed (filter #(and (= (last (:zone %)) :content) (not (:rezzed %))) cards)]
+                  (let [unrezzed (filter #(and (= (last (:zone %)) :content) (not (:rezzed %))) from-root)]
                     (if (= 1 (count unrezzed))
                       ;; only one unrezzed upgrade; access it and continue
                       (do (system-msg state side (str "accesses " (:title (first unrezzed))))
                           (handle-access state side unrezzed)
-                          (when (or (pos? from-hq) (< 1 (count from-hq)))
+                          (when (or (pos? from-hq) (< 1 (count from-root)))
                             (resolve-ability
                               state side (access-helper-hq from-hq
                                                            (filter #(not= (:cid %) (:cid (first unrezzed))) from-root)
@@ -237,10 +237,10 @@
                                          card nil)))
                   ;; accessing a rezzed upgrade
                   (do (system-msg state side (str "accesses " target))
-                      (handle-access state side [(some #(when (= (:title %) target) %) cards)])
-                      (when (or (pos? from-hq) (< 1 (count from-hq)))
+                      (handle-access state side [(some #(when (= (:title %) target) %) from-root)])
+                      (when (or (pos? from-hq) (< 1 (count from-root)))
                         (resolve-ability state side (access-helper-hq from-hq
-                                                                      (remove-once #(not= (:title %) target) cards)
+                                                                      (remove-once #(not= (:title %) target) from-root)
                                                                       already-accessed) card nil)))))})

 (defmethod choose-access :hq [cards server]


fix cake tasks

fix cake tasks

--- src/clj/protobuf/tasks.clj
+++ src/clj/protobuf/tasks.clj
@@ -1,8 +1,9 @@
 (ns protobuf.tasks
   (:use cake cake.core cake.ant
+        [cake.tasks.compile :only [compile-java]]
         [clojure.java.shell :only [sh]]
         [clojure.java.io :only [reader]]
-        [useful.io :only [extract-resource]])
+        [cake.utils.io :only [extract-resource]])
   (:import [org.apache.tools.ant.taskdefs Chmod Copy Delete ExecTask Get Javac Mkdir Untar]))

 (def version "2.3.0")
@@ -77,9 +78,7 @@
               (catch org.apache.tools.ant.BuildException e
                 (ant Delete {:dir dest})
                 (throw (Exception. (str "error compiling " proto))))))
-       (ant Javac {:srcdir    (path dest)
-                   :destdir   (file "classes")
-                   :classpath (classpath)}))))
+       (compile-java (file dest)))))

 (defn build-protobuf []
   (ant Mkdir {:dir "proto/google/protobuf"})


Support for wildcard characters

Support for wildcard characters

--- src/clj_mrazik/irc_bot.clj
+++ src/clj_mrazik/irc_bot.clj
@@ -1,5 +1,5 @@
 ;
-;  (C) Copyright 2016  Pavel Tisnovsky
+;  (C) Copyright 2017  Pavel Tisnovsky
 ;
 ;  All rights reserved. This program and the accompanying materials
 ;  are made available under the terms of the Eclipse Public License v1.0
@@ -132,6 +132,29 @@
 (defn return-words-from-dictionary
     [input]
     (dictionary/find-word input))
+
+(defn use-wildchards?
+    [input]
+    (or (.startsWith input "*")
+        (.endsWith input "*")))
+
+(defn one-word-like-this?
+    [input]
+    (if (use-wildchards? input)
+        (= (dictionary/words-like-this input) 1)))
+
+(defn more-words-like-this?
+    [input]
+    (if (use-wildchards? input)
+        (> (dictionary/words-like-this input) 1)))
+
+(defn return-word-like-this
+    [input]
+    (dictionary/find-word-like-this input))
+
+(defn return-more-words-like-this
+    [input]
+    (dictionary/find-words-like-this input))

 (defn dictionary-status
     []
@@ -172,7 +195,9 @@
                               (and number-cruncher? (is-two-numbers? input))          (print-gcd input)
                               (and number-cruncher? (is-factorial? input))            (print-factorial input)
                               (and s-expressions?   (is-s-expression? input))         (s-expression input)
-                              (and dictionary?      (is-word-from-dictionary? input)) (return-words-from-dictionary input)
+                              (is-word-from-dictionary? input) (return-words-from-dictionary input)
+                              (one-word-like-this? input)      (return-word-like-this input)
+                              (more-words-like-this? input)    (return-more-words-like-this input)
                               :else (if random-messages? (random-message)
                                                          "Command not understood or term not found")))]
         {:prefix prefix


Created a controller instance bound database

Idea is to use Controller as the closure
for app global db object instead of page or module global

This is perhaps closer to model pattern in Mithril than re-frame

--- src/cljs/repodoc/core.cljs
+++ src/cljs/repodoc/core.cljs
@@ -73,6 +73,18 @@
   [serializer]
   (serialize serializer
              (filter #(get % "mtime") (querydb [:data]))))
+
+(defn initialize-db
+  "Creates closure based database
+  of the map given as data"
+  [data]
+  (def db (atom data))
+  {:update (fn [key val]
+              (println @db db key val)
+              (swap! db #(assoc % key val)))
+   :query (fn [key]
+             (println @db db key)
+             (get @db key))})

 ;; Handlers

@@ -229,8 +241,7 @@

 (def repodoc {:controller ctrl :view viewer})

-(def index {:controller (fn [] {:username "jussiarpalahti"
-                                :repositories []})
+(def index {:controller #(initialize-db {:username "jussiarpalahti" :repositories []})
             :view index_view})

 ;; Routing mode


refactor component-did-mount focus on input

--- src/cljs/todomvc/core.cljs
+++ src/cljs/todomvc/core.cljs
@@ -1,6 +1,6 @@
 (ns todomvc.core
-    (:require [reagent.core :as reagent :refer [atom]]
-              [cljsjs.react :as react]))
+  (:require [reagent.core :as reagent :refer [atom]]
+            [cljsjs.react :as react]))

 ;; -------------------------
 ;; Views
@@ -43,25 +43,26 @@
                 (add-todo! "Create Todo App")
                 (add-todo! "Run 4 miles")))

+(defn focus [component]
+  (.focus (reagent/dom-node component)))
+
 (defn todo-input
   "Input box for todos. Pass in initial title and a callback for on-save."
   [{:keys [text on-save]}]
-  (let [val (atom text)
-        save #(let [v (-> @val str clojure.string/trim)]
-               (if-not (empty? v)
-                 (on-save v)))]
-    (fn []
-      [:input {:type "text"
-               :value @val
-               :on-blur save
-               :on-change #(reset! val (.. % -target -value))
-               :on-key-down #(case (.-which %)
-                               13 (save)
-                               nil)}])))
-
-(def todo-edit
-  "A todo-input with focus when spawned."
-  (with-meta todo-input {:component-did-mount #(.focus (reagent/dom-node %))}))
+  (reagent/create-class {:render
+                         (let [val (atom text)
+                               save #(let [v (-> @val str clojure.string/trim)]
+                                       (if-not (empty? v)
+                                         (on-save v)))]
+                           (fn []
+                             [:input {:type "text"
+                                      :value @val
+                                      :on-blur save
+                                      :on-change #(reset! val (.. % -target -value))
+                                      :on-key-down #(case (.-which %)
+                                                      13 (save)
+                                                      nil)}]))
+                         :component-did-mount focus}))

 (defn todo-entry []
   (let [editing (atom false)]
@@ -72,9 +73,9 @@
         [:input {:type "checkbox"
                  :on-change #(toggle! id)}]
         [:label {:on-double-click #(reset! editing true)} text]
-        [:button {:on-click #(remove-todo! id)} "X"]]
+        [:a {:on-click #(remove-todo! id)} "X"]]
        (when @editing
-         [todo-edit {:text text
+         [todo-input {:text text
                       :on-save #(do (save! id %)
                                     (reset! editing false))}])])))


Move field repair game logic into its own section

General rule is 1 section per game action

--- src/cljs/zetawar/game.cljs
+++ src/cljs/zetawar/game.cljs
@@ -655,50 +655,9 @@
     (throw (unit-ex "Unit is already fully repaired" unit)))
   (checked-next-state db unit :action.type/repair-unit))

-(defn check-can-field-repair [db game unit]
-  (check-unit-current db game unit)
-  (when (:unit/capturing unit)
-    (throw (unit-ex "Unit cannot make repairs while capturing" unit)))
-  (when (empty? (get-in unit [:unit/type :unit-type/can-repair]))
-    (throw (unit-ex "Unit cannot repair other units" unit)))
-  (checked-next-state db unit :action.type/field-repair-unit))
-
-(defn check-can-be-repaired [db game unit]
-  (when (>= (:unit/count unit) (:game/max-count-per-unit game))
-    (throw (unit-ex "Unit is already fully repaired" unit)))
-  unit)
-
-(defn check-compatible-armor-types-for-repair [db game repairer wounded]
-  (let [possible-repair-types (get-in repairer [:unit/type :unit-type/can-repair])
-        goal-repair-type (get-in wounded [:unit/type :unit-type/armor-type])]
-    (when-not (some #{goal-repair-type} possible-repair-types)
-      (throw (unit-ex "Armor types are not compatible" repairer)))
-    repairer))
-
 (defn can-repair? [db game unit]
   (try
     (check-can-repair db game unit)
-    true
-    (catch :default ex
-      false)))
-
-(defn can-field-repair? [db game unit]
-  (try
-    (check-can-field-repair db game unit)
-    true
-    (catch :default ex
-      false)))
-
-(defn can-be-repaired? [db game unit]
-  (try
-    (check-can-be-repaired db game unit)
-    true
-    (catch :default ex
-      false)))
-
-(defn compatible-armor-types-for-repair? [db game repairer wounded]
-  (try
-    (check-compatible-armor-types-for-repair db game repairer wounded)
     true
     (catch :default ex
       false)))
@@ -717,6 +676,56 @@
   ([db game q r]
    (let [unit (checked-unit-at db game q r)]
      (repair-tx db game unit))))
+
+(defn repair! [conn game-id q r]
+  (let [db @conn
+        game (game-by-id db game-id)
+        tx (repair-tx db game q r)]
+    (d/transact! conn tx)))
+
+;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
+;;; Field Repair
+
+(defn check-can-field-repair [db game unit]
+  (check-unit-current db game unit)
+  (when (:unit/capturing unit)
+    (throw (unit-ex "Unit cannot make repairs while capturing" unit)))
+  (when (empty? (get-in unit [:unit/type :unit-type/can-repair]))
+    (throw (unit-ex "Unit cannot repair other units" unit)))
+  (checked-next-state db unit :action.type/field-repair-unit))
+
+(defn can-field-repair? [db game unit]
+  (try
+    (check-can-field-repair db game unit)
+    true
+    (catch :default ex
+      false)))
+
+(defn check-can-be-repaired [db game unit]
+  (when (>= (:unit/count unit) (:game/max-count-per-unit game))
+    (throw (unit-ex "Unit is already fully repaired" unit)))
+  unit)
+
+(defn can-be-repaired? [db game unit]
+  (try
+    (check-can-be-repaired db game unit)
+    true
+    (catch :default ex
+      false)))
+
+(defn check-compatible-armor-types-for-repair [db game repairer wounded]
+  (let [possible-repair-types (get-in repairer [:unit/type :unit-type/can-repair])
+        goal-repair-type (get-in wounded [:unit/type :unit-type/armor-type])]
+    (when-not (some #{goal-repair-type} possible-repair-types)
+      (throw (unit-ex "Armor types are not compatible" repairer)))
+    repairer))
+
+(defn compatible-armor-types-for-repair? [db game repairer wounded]
+  (try
+    (check-compatible-armor-types-for-repair db game repairer wounded)
+    true
+    (catch :default ex
+      false)))

 (defn field-repair-tx
   ([db game repairer wounded]
@@ -735,12 +744,6 @@
    (let [repairer (checked-unit-at db game q1 r1)
          wounded (checked-unit-at db game q2 r2)]
      (field-repair-tx db game repairer wounded))))
-
-(defn repair! [conn game-id q r]
-  (let [db @conn
-        game (game-by-id db game-id)
-        tx (repair-tx db game q r)]
-    (d/transact! conn tx)))

 ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
 ;;; Capture


remove destructure signature so it is not printed in ref file

--- src/cljs_api_gen/parse.clj
+++ src/cljs_api_gen/parse.clj
@@ -526,10 +526,12 @@
                 :else nil)
         match? #(= "destructure" (:name %))
         item (first (filter match? items))]
-    (assoc item
-      :ns *cur-ns*
-      :name "destructure"
-      :type "syntax")))
+
+    (-> item
+        (assoc :ns *cur-ns*
+               :name "destructure"
+               :type "syntax")
+        (dissoc :signature))))

 ;;--------------------------------------------------------------------------------
 ;; Clojure Macros to import or exclude


correct typo in namespace description

correct typo in namespace description

--- src/cljs_api_gen/write.clj
+++ src/cljs_api_gen/write.clj
@@ -31,7 +31,7 @@
    "clojure.browser.dom"          "browser DOM library, wrapping [goog.dom](http://www.closurecheatsheet.com/dom)"
    "clojure.browser.event"        "browser event library, wrapping [goog.events](http://www.closurecheatsheet.com/events)"
    "clojure.browser.net"          "network communication library, wrapping [goog.net](http://www.closurecheatsheet.com/net)"
-   "clojure.browser.repl"         "evalute compiled cljs in a browser. send results back to server"
+   "clojure.browser.repl"         "evaluate compiled cljs in a browser. send results back to server"
    "clojure.core.reducers"        "a library for reduction and parallel folding (parallelism not supported)"
    "clojure.reflect"              "DEPRECATED. Do not use, superceded by REPL enhancements."
    "cljs.nodejs"                  "nodejs support functions"


Update the contact link to point at a wiki page. #9

--- src/clojars/web/common.clj
+++ src/clojars/web/common.clj
@@ -51,7 +51,7 @@
      [:article
       body]]
     [:footer
-     (link-to "mailto:contact@clojars.org" "contact")
+     (link-to "https://github.com/ato/clojars-web/wiki/Contact" "contact")
      (link-to "http://github.com/ato/clojars-web" "code")
      (link-to "http://wiki.github.com/ato/clojars-web" "help")]]))


also scroll on i-did-update

also scroll on i-did-update

--- src/chat/client/views/threads.cljs
+++ src/chat/client/views/threads.cljs
@@ -51,6 +51,9 @@
       om/IWillReceiveProps
       (will-receive-props [_ _]
         (scroll-to-bottom owner thread))
+      om/IDidUpdate
+      (did-update [_ _ _]
+        (scroll-to-bottom owner thread))
       om/IRender
       (render [_]
         (dom/div #js {:className "thread"}


Making it work

Making it work

--- src/clj/algorithms_clj/huffman.clj
+++ src/clj/algorithms_clj/huffman.clj
@@ -7,12 +7,15 @@
 (defn- make-leaf
   "Create a leaf for the huffman code tree"
   [[value freq]]
-  [#{value} freq])
+  [{:values #{value}} freq])

 (defn- make-node
   "Build an intermediary node from two sub-trees"
-  [[vs1 w1] [vs2 w2]]
-  [(merge vs1 vs2) (+ w1 w2)])
+  [[c1 w1 :as lhs]
+   [c2 w2 :as rhs]]
+  [{:values (into (:values c1) (:values c2))
+    :childs [c1 c2]}
+   (+ w1 w2)])

 (defn- merge-lowest
   "Merge the two lowest priority elements"
@@ -26,10 +29,12 @@
   "Build the huffman tree from the priority map"
   [heap]
   (if (< 1 (count heap))
-    (recur (merge-lowest heap)) heap))
+    (recur (merge-lowest heap))
+    (first heap)))

 (defn make-tree
   "Build the huffman tree from a list of (value, frequence) pairs"
   [inputs]
   (let [heap (into (priority-map) (map make-leaf) inputs)]
-    (make-tree-impl heap)))
+    (first (make-tree-impl heap))
+    ))


insert type hints automatically for clojure dsl

--- src/clj/backtype/storm/clojure.clj
+++ src/clj/backtype/storm/clojure.clj
@@ -5,6 +5,26 @@
   (:import [backtype.storm.task OutputCollector IBolt])
   (:import backtype.storm.clojure.ClojureBolt)
   (:require [backtype.storm [thrift :as thrift]]))
+
+(defn hint [sym class-sym]
+  (with-meta sym {:tag class-sym})
+  )
+
+(defmulti hinted-args (fn [m args] m))
+
+(defmethod hinted-args 'prepare [_ [conf context collector]]
+           [(hint conf 'java.util.Map)
+            (hint context 'backtype.storm.task.TopologyContext)
+            (hint collector 'backtype.storm.task.OutputCollector)]
+           )
+
+(defmethod hinted-args 'execute [_ [tuple]]
+           [(hint tuple 'backtype.storm.tuple.Tuple)]
+           )
+
+(defmethod hinted-args 'cleanup [_ []]
+           []
+           )

 (defn direct-stream [fields]
   (StreamInfo. fields true))
@@ -19,7 +39,9 @@

 (defmacro bolt [& body]
   (let [fns (for [[name args & impl] body
-                  :let [args (-> "this"
+                  :let [name (hint name 'void)
+                        args (hinted-args name args)
+                        args (-> "this"
                                  gensym
                                  (cons args)
                                  vec)]]
@@ -37,8 +59,9 @@
                     (cons 'fn impl)
                     (let [[args & impl-body] impl
                           coll-sym (nth args 1)
-                          args (vec (take 1 args))]
-                      `(fn [conf# context# ~coll-sym] (bolt (~'execute ~args ~@impl-body)))))
+                          args (vec (take 1 args))
+                          prepargs (hinted-args 'prepare [(gensym "conf") (gensym "context") coll-sym])]
+                      `(fn ~prepargs (bolt (~'execute ~args ~@impl-body)))))
           definer (if params
                     `(defn ~name [& args#]
                        (clojure-bolt ~output-spec ~worker-name args#))


Use more advanced searching

Use more advanced searching

--- src/clj/herder/solver/schedule.clj
+++ src/clj/herder/solver/schedule.clj
@@ -4,8 +4,9 @@
    [org.optaplanner.core.config.solver SolverConfig]
    [org.optaplanner.core.config.score.director ScoreDirectorFactoryConfig]
    [org.optaplanner.core.config.score.definition ScoreDefinitionType]
-   [org.optaplanner.core.config.constructionheuristic ConstructionHeuristicPhaseConfig]
-   [org.optaplanner.core.config.localsearch LocalSearchPhaseConfig]
+   [org.optaplanner.core.config.constructionheuristic ConstructionHeuristicPhaseConfig ConstructionHeuristicType]
+   [org.optaplanner.core.config.localsearch LocalSearchPhaseConfig LocalSearchType]
+   [org.optaplanner.core.config.localsearch.decider.acceptor AcceptorConfig]
    [org.optaplanner.core.config.solver.termination TerminationConfig]

    [herder.solver.types HerderSolution Event Slot]))
@@ -16,9 +17,19 @@
     (.setScoreDefinitionType ScoreDefinitionType/HARD_SOFT)
     (.setScoreDrlList ["herder/solver/rules.drl"])))

+(defn genConstructionHeuristic []
+  (doto
+   (ConstructionHeuristicPhaseConfig.)
+    (.setConstructionHeuristicType ConstructionHeuristicType/FIRST_FIT_DECREASING)))
+
+(defn genLocalSearch [type]
+  (doto
+   (LocalSearchPhaseConfig.)
+    (.setLocalSearchType type)))
+
 (defn genPhaseSearch []
-  [(ConstructionHeuristicPhaseConfig.)
-   (LocalSearchPhaseConfig.)])
+  [(genConstructionHeuristic)
+   (genLocalSearch LocalSearchType/TABU_SEARCH)])

 (defn genTerminationConfig []
   (doto


search result amount output

search result amount output

--- src/clj/morpheus/traversal/bfs.clj
+++ src/clj/morpheus/traversal/bfs.clj
@@ -129,6 +129,7 @@
                 (recur (inc level)))))))
     (swap! tasks-vertices dissoc task-id)
     (swap! tasks-level dissoc task-id)
+    (println "Parallel BFS completed for" (count vertices-map) "vertices")
     vertices-map))

 (defn path-to [vertex-a vertex-b & params]


CLJS-1006: Implicit dependency of clojure.browser.repl on cljs.repl

--- src/cljs/clojure/browser/repl.cljs
+++ src/cljs/clojure/browser/repl.cljs
@@ -16,7 +16,12 @@
       :author "Bobby Calderwood and Alex Redington"}
   clojure.browser.repl
   (:require [clojure.browser.net   :as net]
-            [clojure.browser.event :as event]))
+            [clojure.browser.event :as event]
+            ;; repl-connection callback will receive goog.require('cljs.repl')
+            ;; and monkey-patched require expects to be able to derive it
+            ;; via goog.basePath, so this namespace should be compiled together
+            ;; with clojure.browser.repl:
+            [cljs.repl]))

 (def xpc-connection (atom nil))


Add preventDefault call to login button back, as it was needed

--- src/cljs/my_money/views/login.cljs
+++ src/cljs/my_money/views/login.cljs
@@ -4,11 +4,16 @@
             [my-money.app.controller.authentication :as ac]
             [reagent.core :as r]))

+
+(defn login! [e! data event-handler]
+  (.preventDefault event-handler)
+  (e! (ac/->Login data)))
+
 (defn- buttons [e! data close-fn]
   [:div
    [button {:type :primary
             :form "login"
-            :on-click  (r/partial e! (ac/->Login @data))}
+            :on-click  (r/partial login! e! @data)}
     "Login"]
  [button {:type :danger
           :on-click close-fn}


refactor board

refactor board

--- src/cljs/tictactoe/view/board.cljs
+++ src/cljs/tictactoe/view/board.cljs
@@ -8,10 +8,12 @@
 (defn render-one-cell
   "Dispatch the rendering of the cell based on the player"
   [type cell-pos options]
-  (case type
-    :cell/empty (cell/render-square cell-pos options)
-    :cell/cross (cell/render-cross cell-pos options)
-    :cell/circle (cell/render-circle cell-pos options)))
+  (let [renderer
+        (case type
+          :cell/empty cell/render-square
+          :cell/cross cell/render-cross
+          :cell/circle cell/render-circle)]
+    (renderer cell-pos options)))

 (defn render-board


Add better docstring for exception monad ns.

--- src/cljx/cats/monad/exception.cljx
+++ src/cljx/cats/monad/exception.cljx
@@ -24,11 +24,35 @@
 ;; THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.

 (ns cats.monad.exception
-  "The Try Monad.
-
-  The Try type represents a computation that may either result in an exception,
-  or return a successfully computed value. It's similar to, but semantically
-  different from the Either type."
+  "The Exception monad.
+
+  Also known as Try monad, popularized by Scala.
+
+  It represents a computation that may either result
+  in an exception or return a successfully computed
+  value. Is very similar to Either monad, but is
+  semantically different.
+
+  It consists in two types: Success and Failure. The
+  Success type is a simple wrapper like Right of Either
+  monad. But the Failure type is slightly different
+  from Left, because it is forced to wrap an instance
+  of Throwable (or Error in cljs).
+
+  The most common use case of this monad is for wrap
+  third party libraries that uses standard Exception
+  based error handling. In normal circumstances you
+  should use Either instead.
+
+  The types defined for Exception monad (Success and
+  Failure) also implementes the clojure IDeref interface
+  which facilitates libraries developing using monadic
+  composition without forcing a user of that library
+  to use or understand monads.
+
+  That is because when you will dereference the
+  failure instance, it will reraise the containing
+  exception."
   #+clj
   (:require [cats.protocols :as proto]
             [cats.core :refer [with-monad]])


Make sure the REPL buttons are always toggled correctly

--- src/clojure/nightcode/builders.clj
+++ src/clojure/nightcode/builders.clj
@@ -38,6 +38,7 @@
         in (utils/get-console-input console)
         out (utils/get-console-output console)
         run-action (fn [e]
+                     (toggle-repl-buttons @utils/ui-root false)
                      (lein/run-project process thread in out path))
         run-repl-action (fn [e]
                           (toggle-repl-buttons @utils/ui-root true)
@@ -49,10 +50,13 @@
                              (.insertCode console (str "(do " code ")")))
                            (s/request-focus! (.getView (.getViewport console))))
         build-action (fn [e]
+                       (toggle-repl-buttons @utils/ui-root false)
                        (lein/build-project process thread in out path))
         test-action (fn [e]
+                      (toggle-repl-buttons @utils/ui-root false)
                       (lein/test-project process thread in out path))
         clean-action (fn [e]
+                       (toggle-repl-buttons @utils/ui-root false)
                        (lein/clean-project process thread in out path))
         stop-action (fn [e]
                       (toggle-repl-buttons @utils/ui-root false)


:zzz:

:zzz:


more silliness

more silliness

--- test/github_contributions/github_test.clj
+++ test/github_contributions/github_test.clj
@@ -16,7 +16,6 @@
    (github/stream-contributions send-event-fn sse-context "defunkt")))

 (deftest stream-contributions-receives-403-from-github
-  []
   (with-redefs [repos/user-repos (constantly fixtures/response-403)
                 github/gh-auth (constantly {})]
     (mocking [send-event-fn]
@@ -25,7 +24,6 @@
                                        "Rate limit has been exceeded for Github's API. Please try again later."))))

 (deftest stream-contributions-receives-404-from-github
-  []
   (with-redefs [repos/user-repos (constantly fixtures/response-404)
                 github/gh-auth (constantly {})]
     (mocking [send-event-fn]
@@ -38,7 +36,6 @@
   "
ajaxorg/ace (fork) 5188 stars	5 commits	1st of 2	Ajax.org Cloud9 Editor
")

 (deftest stream-contributions-receives-200s-from-github
-  []
   (with-redefs [repos/user-repos (constantly fixtures/response-user-repos)
                 repos/specific-repo (constantly fixtures/response-specific-repo)
                 repos/contributors (constantly fixtures/response-contributors)
@@ -64,4 +61,4 @@
        "3" "rd"
        "13" "th"
        "123" "rd"
-       "4" "th"))+       "4" "th"))


Fix exampleArg prop name.

Fix exampleArg prop name.


extend compose parameter for more distant intersections

--- src/duckling/time/pred.clj
+++ src/duckling/time/pred.clj
@@ -31,7 +31,7 @@

 ; Limit the space search beam

-(def safe-max 100)
+(def safe-max 183) ; 366 (days in a leap year) if we take safe-max forward and backward
 (def safe-max-interval 12)

 ;; Debug utlity


make links trackable with distinct class names

--- frontend/components/build_head.cljs
+++ frontend/components/build_head.cljs
@@ -488,7 +488,7 @@
                [:th "Parallelism"]
                [:td
                 (if (has-scope :write-settings data)
-                  [:a {:title (str "This build used " (:parallel build) " containers. Click here to change parallelism for future builds.")
+                  [:a.parallelsim-link-head {:title (str "This build used " (:parallel build) " containers. Click here to change parallelism for future builds.")
                        :href (build-model/path-for-parallelism build)}
                    (str (:parallel build) "x")]
                   [:span (:parallel build) "x"])]


added react keys for dynamic children of seat-cols

--- src-cljs/kmc_booking/components.cljs
+++ src-cljs/kmc_booking/components.cljs
@@ -51,8 +51,17 @@
 				} ""]))

+(rum/defc seat-col < rum/static [col]
+	[:div.col_num
+		[:div {:key col} col]
+		]
+	)
+
+
 (rum/defc seat-cols < rum/static [range]
-	(into [:div] (map #(vector :div.col_num [:div {:key %} %]) range)))
+	(into [:div]
+		(map #(rum/with-props seat-col % :rum/key %)
+			range)))

 (rum/defc seat-row < rum/static [row]


Application route authn & authz rules

Application route authn & authz rules

must be a user to get to /app for now

--- src/kixi/hecuba/routes.clj
+++ src/kixi/hecuba/routes.clj
@@ -8,10 +8,12 @@
    [compojure.route :as route]
    [ring.middleware.session.cookie :refer (cookie-store)]
    [cemerick.friend :as friend]
+   (cemerick.friend [workflows :as workflows]
+                    [credentials :as creds])
    [com.stuartsierra.component :as component]
    [org.httpkit.server :refer (run-server)]
    [kixi.hecuba.web-paths :refer (compojure-route amon-index-route amon-resource-route)]
-   [kixi.hecuba.security :as sec]
+   [kixi.hecuba.security :as security]
    [kixi.hecuba.session :refer (cassandra-store)]

    [kixi.hecuba.api.programmes :as programmes]
@@ -73,23 +75,8 @@
          params
          handler)))

-(defn app-routes [store]
+(defn amon-api-routes [store]
   (routes
-   ;; landing page
-   (GET "/" [] index-page)
-   ;; login/logout
-   (GET (compojure-route :login) [] login-form)
-   (friend/logout (ANY (compojure-route :logout) request (redirect "/")))
-
-   ;; main application
-   (GET (compojure-route :app) [] app-page)
-
-   ;; clojurescript
-   (route/resources "/cljs" {:root "cljs/"})
-
-   ;; js/css/etc
-   (route/resources "/" {:root "site/"})
-
    ;; API
    ;; Programmes
    (index-routes :programmes-index (programmes/index store))
@@ -134,19 +121,51 @@
    (resource-route :entity-device-measurement-readingtype-hourly-rollups [:entity_id :device_id :type] (rollups/hourly_rollups store))

    ;; Daily Measurements
-   (resource-route :entity-device-measurement-readingtype-daily-rollups [:entity_id :device_id :type] (rollups/daily_rollups store))
+   (resource-route :entity-device-measurement-readingtype-daily-rollups [:entity_id :device_id :type] (rollups/daily_rollups store))))

+(defn all-routes [store]
+  (routes
+
+   ;; landing page
+   (GET "/" [] index-page)
+
+   ;; clojurescript
+   (route/resources "/cljs" {:root "cljs/"})
+
+   ;; Log In and Log Out
+   (GET (compojure-route :login) [] login-form)
+   (friend/logout (ANY (compojure-route :logout) request (redirect "/")))
+
+   ;; Main Application
+   (GET (compojure-route :app) []
+        (friend/wrap-authorize
+         app-page
+         #{:kixi.hecuba.security/user}))
+
+   ;; AMON API Routes
+   (amon-api-routes store)
+
+   ;; js/css/etc
+   (route/resources "/" {:root "site/"})
+
    ;; 404 - if nothing else matches, then this is the end, my friend.
    (route/not-found not-found-page)))

 (defrecord Routes [context]
   component/Lifecycle
   (start [this]
-    (let [store  (:store this)
-          app    (-> (app-routes store)
-                     (sec/friend-middleware store)
-                     (handler/site {:session {:store (cassandra-store store)}}))
-          server (run-server app {:port 8010})]
+    (let [store      (:store this)
+          all-routes (handler/site
+                      (friend/authenticate
+                       (all-routes store)
+                       {:credential-fn (partial creds/bcrypt-credential-fn (security/get-user store))
+                        :allow-anon? true
+                        :default-landing-uri "/app"
+                        :workflows
+                        ;; Note that ordering matters here. Basic first.
+                        [(workflows/http-basic :realm "/")
+                         (workflows/interactive-form :login-uri "/login")]}))
+          server     (run-server all-routes {:port 8010})]
       (assoc this ::server server)))
   (stop [this]
     ((::server this))))


[up] Money in fees calc func.

[up] Money in fees calc func.

--- src/ombs/db/admin.clj
+++ src/ombs/db/admin.clj
@@ -22,12 +22,18 @@
   "Alias for rm-fee, to avoid call refute in affirm, or rm-fee in interface."
   (rm-fee fee-id) )

-(defn get-fees []
+(defn get-fees []
   "Return fees, for views"
-  (sql/select fees (sql/fields :id :money :date :parts)
-              (sql/with users  (sql/fields [:name :user]))
-              (sql/with events (sql/fields [:name :event] [:date :edate]))
-              ))
+  (sql/select fees (sql/fields :id :money :date :parts)
+              (sql/with users  (sql/fields [:name :user]))
+              (sql/with events (sql/fields [:name :event] [:date :edate]))))
+
+(defn fees-money [uid eid]
+  "Get sum of fees of some user on some event."
+  (:summ (first (sql/select fees
+              (sql/where {:users_id uid :events_id eid})
+              (sql/fields :summ)
+              (sql/aggregate (sum :money) :summ)))))

 (defn get-role [uid]
   (:role (first (sql/select users (sql/where {:id uid}) (sql/fields :role)))))
@@ -37,10 +43,10 @@
 (defn- write-pay [{eid :events_id uid :users_id parts :parts money :money}]
     (println "write-pay eid:" eid " uid:" uid " parts:" parts " money:" money)
     (when (isvalid/ids? eid uid)
-      (when (> parts 0)
-        (do
+      (when (> parts 0)
+        (do
           (println " Pay partial event")
-          (shrink-goods eid parts)
+          (shrink-goods eid parts)
           (dbpay/credit-payment eid uid money)))
       (dbpay/debit-payment eid uid money)
       (if (can-finish? eid)


fix recursive calls for eval & eval-str

fix recursive calls for eval & eval-str

--- src/main/cljs/cljs/js.cljs
+++ src/main/cljs/cljs/js.cljs
@@ -259,7 +259,8 @@
              (cb (.toString sb)))))))))

 (defn compile
-  ([env source cb] (compile env source cb))
+  ([env source cb]
+   (compile env source nil cb))
   ([env source opts cb]
     (compile*
       {:*compiler*     env
@@ -294,7 +295,8 @@
              (cb (*eval-fn* (.toString cb))))))))))

 (defn eval-str
-  ([env source cb] (eval-str env source cb))
+  ([env source cb]
+   (eval-str env source nil cb))
   ([env source opts cb]
    (eval-str*
      {:*compiler*     env


old analyze-deps logic not needed, user responsible via *load-fn*, typo, name -> dep

--- src/main/cljs/cljs/js.cljs
+++ src/main/cljs/cljs/js.cljs
@@ -143,18 +143,16 @@
            (-> (:*cljs-dep-set* bound-vars) meta :dep-path)))
        (if (seq deps)
          (let [dep (first deps)]
-           (when-not (or (not-empty (get-in compiler [::namespaces dep :defs]))
-                         (contains? (:js-dependency-index compiler) (name dep)))
-             (*load-fn* (ns->relpath name)
-               (fn [source]
-                 (if-not (nil? source)
-                   (analyze* bound-vars source opts
-                     (fn []
-                       (analyze-deps bound-vars ana-env lib (next deps) opts cb)))
-                   (throw
-                     (ana/error ana-env
-                       (ana/error-message :undeclared-ns
-                         {:ns-sym dep :js-provide (name dep)}))))))))
+           (*load-fn* (ns->relpath dep)
+             (fn [source]
+               (if-not (nil? source)
+                 (analyze* bound-vars source opts
+                   (fn []
+                     (analyze-deps bound-vars ana-env lib (next deps) opts cb)))
+                 (throw
+                   (ana/error ana-env
+                     (ana/error-message :undeclared-ns
+                       {:ns-sym dep :js-provide (name dep)})))))))
          (cb))))))

 (defn load-macros [bound-vars k macros reload reloads opts cb]


Fix bug: when looking up a non-existant child we should be returning an empty TwigSnapshot instead of a delayed nil.

--- src/twigs/snapshot.cljc
+++ src/twigs/snapshot.cljc
@@ -45,8 +45,9 @@
               snaps))))

   ILookup
-  #?(:cljs (-lookup [this k] (-lookup this k (delay nil)))
-     :clj (valAt [this k] (.valAt this k (delay nil))))
+  (#?(:cljs -lookup :clj valAt) [this k]
+    (#?(:cljs -lookup :clj .valAt) this k
+      (TwigSnapshot. (.child ss (name k)) (delay nil))))
   (#?(:cljs -lookup :clj valAt) [_ k nf]
     (if (.hasChild ss (name k))
       (let [css (.child ss (name k))]


Refactor auth.clj

Refactor auth.clj

--- src/clj/rumahsewa141/routes/auth.clj
+++ src/clj/rumahsewa141/routes/auth.clj
@@ -9,39 +9,40 @@
             [bouncer.validators :as v]
             [rumahsewa141.db.core :as db]))

-(defn login-page [{identity :identity}]
+(defn show-login-page [{identity :identity}]
   (if (nil? identity)
     (layout/render "login.html")
     (redirect "/member")))

-(defn lookup-user [username password]
+(defn- lookup-user [username password]
   (if-let [user (db/get-user {:username username})]
     (if (hashers/check password (get user :password))
       (dissoc user :password))))

-(defn do-login! [{{:keys [username password session] :as params} :params}]
-  (if (b/valid? params
-                {:username v/required
-                 :password v/required})
+(defn- valid-login? [params]
+  (b/valid? params
+            {:username v/required
+             :password v/required}))

-    ;; If parameters are valid, lookup for the user in database,
+(defn- get-login-error [params]
+  (str (first (b/validate params
+                          {:username v/required
+                           :password v/required}))))
+
+(defn log-user-in [{{:keys [username password session] :as params} :params}]
+  (if (valid-login? params)
     (if-let [{admin :admin :as user} (lookup-user username password)]
       (-> (redirect (if (true? admin) "/admin" "/member"))
           (assoc :session (assoc session :identity user)))
-      (layout/render "error_message.html"
-                     {:title "Failed login"
-                      :description "Wrong username or password."}))
+      (layout/render "error_message.html" {:title "Failed login"
+                                           :description "Wrong username or password."}))
+    (layout/render "error_message.html" {:description (get-login-error params)})))

-    ;; else, display errors.
-    (str (first (b/validate params
-                            {:username v/required
-                             :password v/required})))))
-
-(defn do-logout! [{session :session}]
+(defn log-user-out [{session :session}]
   (-> (redirect "/")
       (assoc :session (dissoc session :identity))))

 (defroutes auth-routes
-  (GET "/login" req (login-page req))
-  (POST "/login" req (do-login! req))
-  (POST "/logout" req (do-logout! req)))
+  (GET "/login" req (show-login-page req))
+  (POST "/login" req (log-user-in req))
+  (POST "/logout" req (log-user-out req)))


Use underscore for unused symbol

Use underscore for unused symbol

--- src/play_clj/core.clj
+++ src/play_clj/core.clj
@@ -34,10 +34,10 @@
     :as options}]
   (let [screen (atom {})
         entities (atom '())
-        watcher (add-watch entities
-                           :changed
-                           (fn [_ _ _ new-entities]
-                             (refresh-renderer! @screen new-entities)))
+        _ (add-watch entities
+                     :changed
+                     (fn [_ _ _ new-entities]
+                       (refresh-renderer! @screen new-entities)))
         execute-fn! (fn [func & {:keys [] :as options}]
                       (when func
                         (let [old-entities @entities]


Simplify history handling

Simplify history handling

--- demo/sitetools/core.cljs
+++ demo/sitetools/core.cljs
@@ -61,11 +61,11 @@
                   (assoc state :page-name x))
     :goto-page (do
                  (assert (string? x))
-                 (if history
-                   (do (.setToken history x)
-                       (r/next-tick #(set! js/document.body.scrollTop 0))
-                       state)
-                   (recur state [:set-page x])))))
+                 (when-some [h history]
+                   (.setToken h x)
+                   (r/next-tick #(set! js/document.body.scrollTop 0))
+                   state)
+                 (recur state [:set-page x]))))

 (defn dispatch [event]
   ;; (dbg event)
@@ -98,10 +98,13 @@
                                            (re-pattern (str page "$")) "")
                                           (string/replace #"/*$" ""))))
                     (History.)))
-        (evt/listen hevt/NAVIGATE #(dispatch [:set-page (.-token %)]))
+        (evt/listen hevt/NAVIGATE #(when (.-isNavigation %)
+                                    (dispatch [:set-page (.-token %)])))
         (.setEnabled true))
-      (when (and page (not html5) (-> history .getToken empty?))
-        (.setToken history page)))))
+      (let [p (if (and page (not html5) (-> history .getToken empty?))
+                page
+                (.getToken history))]
+        (dispatch [:set-page p])))))

 (defn to-relative [f]
   (string/replace f #"^/" ""))


more TODO

more TODO

--- test/com/billpiel/sayid/core_test.clj
+++ test/com/billpiel/sayid/core_test.clj
@@ -948,6 +948,8 @@
 - FIX adding only deep-trace throws execption on execution -- happened in scheduler
 ~ test profiling w/ deep trace
 ~ profile simulated tracer fn
+- FIX return values of `false` aren't displayed
+- FIX deep-traced fn returning fn blows up
 - profiling interface in core
 - rec-save-as should accept keyword or string
 - never return ws or recs from core fns


Removes unused :ref

Removes unused :ref

--- src/wordsmith/core.cljs
+++ src/wordsmith/core.cljs
@@ -161,8 +161,7 @@
                            :onChange #(handle-input % input)
                            :value input})
         (dom/div
-          #js {:ref "output-area"
-               :id "output-area"
+          #js {:id "output-area"
                :dangerouslySetInnerHTML #js {:__html (marked input)}})))))

 ;; State transformations