let switch_buffer v args =
  if Array.length args > 0 then
    let name = args.(1) in
    switch_to_buffer v name
  else
    (* propose list of available buffers *)
    let candidate_buffers = candidate_buffers () in
    let f = function
      "" ->
        (
         match candidate_buffers with
           [] -> ()
         | s :: _ -> switch_to_buffer v s
        )
    | s -> switch_to_buffer v s
    in
    let title =
      Printf.sprintf "Switch to %s"
        (match candidate_buffers with
           [] -> "" | s :: _ -> "["^(Glib.Convert.filename_to_utf8 s)^"]")
    in
    Ed_misc.select_string
      ~history: switch_buffer_history
      v#minibuffer
      ~title
      ~choices: (List.map Glib.Convert.filename_to_utf8 candidate_buffers)
      ""
      f