        (zero? (mod (% :frame-index) (-> % :channel :skip-frames inc))))
     events))
 
-(defn process-new-position [events]
+(defn process-new-position
+  "Attach a [:new-position true] entry to events where appropriate."
+  [events]
   (for [[e1 e2] (pairs-back events)]
     (assoc e2 :new-position
       (different e1 e2 [:position-index]))))
 
-(defn process-use-autofocus [events use-autofocus autofocus-skip]
+(defn process-use-autofocus
+  "Modify events sequence so that event maps will include an [:autofocus true]
+   entry when appropriate."
+  [events use-autofocus autofocus-skip]
   (for [[e1 e2] (pairs-back events)]
     (assoc e2 :autofocus
       (and use-autofocus

        events))
    events))

(defn different [e1 e2 selectors]
  (not= (get-in e1 selectors)
        (get-in e2 selectors)))

(defn manage-shutter [events keep-shutter-open-channels keep-shutter-open-slices]
  (for [[e1 e2] (pairs events)]
    (let [diff #(different e1 e2 %)]
      (assoc e1 :close-shutter

  :time-first :keep-shutter-open-slices :keep-shuftter-open-channels
  :use-autofocus :autofocus-skip :relative-slices :exposure :interval-ms :custom-intervals-ms)

(defn pairs
  "Generates a lazy list of pairs in sequence, ending with the last
   value paired with nil."
  [x]
  (partition 2 1 (lazy-cat x (list nil))))

(defn pairs-back
  "Generates a lazy list of pairs in sequence, beginning the (nil first-val)."
  [x]
  (partition 2 1 (lazy-cat (list nil) x)))

(defn if-assoc
  "Associate k,v in a map if pred is true, otherwise
   return the map unchanged."
  [pred m k v]
  (if pred (assoc m k v) m))

(defn make-property-sequences
  "Make a sequence of properties."
  [channel-properties]
  (let [ks (apply sorted-set
                  (apply concat (map keys channel-properties)))]
    (into (sorted-map)
      (for [[d p] ks]
        [[d p] (map #(get % [d p]) channel-properties)]))))

(defn channels-sequenceable
  "Checks if a give property sequence can actually be triggered,
   (and if a set of channels all have the same exposure setting)."
  [property-sequences channels]
  (and
    (not (some false?
           (for [[[d p] s] property-sequences]
