   :group 'jail-windows)
 (defcustom jail-windows-default-layout nil
   "Default layout to activate when none has been selected and jail-windows-mode
-activates for the first time on a frame"
+activates for the first time on a frame."
+  :group 'jail-windows)
+(defcustom jail-windows-new-window-buffer "*scratch*"
+  "Default buffer to display when activating a layout with more windows than
+were previously shown."
+  :type 'string
   :group 'jail-windows)
 (defcustom jail-windows-repeat-minimum-horz 45
-  ""
+  "TODO"
   :type 'integer
   :group 'jail-windows)
-(defconst jail-windows--real-repeat-minimum-horz 1
-  "")
 (defcustom jail-windows-repeat-minimum-vert 3
-  ""
+  "TODO"
   :type 'integer
   :group 'jail-windows)
+(defcustom jail-windows-choose-window-actions
+  '(jail-windows--single-window-action
+    jail-windows--existing-window-action
+    jail-windows--same-window-action
+    jail-windows--just-pick-one-action)
+  "List of functions to select a window to display a buffer.
+
+Functions should use a signature of (fn FRAME WINDOW-GROUP AVAILABLE-WINDOWS
+BUFFER ALIST); where the arguments are:
+
+ `FRAME' -- the frame from which the AVAILABLE-WINDOWS have been chosen,
+ `WINDOW-GROUP' -- the layout group which matched for the BUFFER,
+ `AVAILABLE-WINDOWS' -- a list of windows preselected by jail-windows-mode,
+ `BUFFER' -- the buffer that will be displayed, and
+ `ALIST' -- as described by `display-buffer'.
+
+Each function should return either a window or nil. Note that a returned window
+needn't be one from AVAILABLE-WINDOWS.
+
+These functions should only perform the selection of a window and should not
+perform the actual buffer-switching behavior."
+  :type '(repeat function)
+  :group 'jail-windows)
+(defcustom jail-windows-debug-messages '(on-off)
+  "TODO"
+  :type '(set (const :tag "on-off TODO" on-off)
+              (const :tag "layout TODO" layout)
+              (const :tag "selection TODO" selection)
+              (const :tag "selection verbose TODO" selection-verbose))
+  :group 'jail-windows)
+
+;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
+;;; Non-customizable variables
+;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
+
+(defconst jail-windows--real-repeat-minimum-horz 1
+  "TODO")
 (defconst jail-windows--real-repeat-minimum-vert 1
-  "")
+  "TODO")
 
 ;; Hooks
 (defvar jail-windows-mode-hook '()

      (setq ret (funcall buffer-matches-p buffer)))
    ret))

(defun jail-windows--find-window-for-buffer (frame buffer alist
                                                   &optional skip-windows)
  "[Internal]"
  (unless frame
    (setq frame (selected-frame)))
  (let ((available-windows (-difference (window-list frame 'nominibuf)
                                        skip-windows))
        (matched-group))
    ;; For each group defined in the jail-windows' window-options
    (--each-while (jail-windows--get-option frame 'groups)
        ;; Stop iterating when a group has matched
        (not matched-group)
      ;; Pull the group definition and the window list from the group list
      (let ((group-defs (car it))
            (window-list (cdr it))
            (-compare-fn #'jail-windows--group-buffer-compare-fn))
        ;; Check if this group has live windows and matches against the buffer
        (if (and window-list
                 (-contains? group-defs buffer))
            ;; When it does match, only use windows from this group
            (progn
              (setq matched-group t)
              (let ((-compare-fn nil))
                (setq available-windows
                      (-intersection available-windows window-list))))
          ;; When it doesn't, remove this group's windows from the list
          (let ((-compare-fn nil))
            (setq available-windows
                  (-difference available-windows window-list))))))

    ;; Pick among the remaining windows
    (when available-windows
      (let ((selected-window))
        ;; TODO(rgrimm): Look for an active one
        (setq selected-window (car available-windows))

        ;; Return the selected window
        selected-window))))

(defun jail-windows--display-buffer-override (buffer alist)
  "[Internal] Take over window placement... ALIST is ignored"
  (let ((selected-window (jail-windows--find-window-for-buffer (selected-frame)
                                                               buffer
                                                               alist)))

                      "^\\*Locate\\*$"
                      "^\\*magit-\\(diff\\|commit\\)"
                      "^\\*Man "
                      "^\\*Occur\\*$"
                      "^\\*Pp Eval Output\\*$"
                      "^\\*\\(Wo\\)?Man"
                      "^COMMIT_EDITMSG$")
