let paste (v: sourceview) args =
  let text =
    let len = Array.length args in
    if len > 0 then
      Some args.(0)
    else
      let selection = GMain.selection#text in
      (*
         prerr_endline (Printf.sprintf "Selection=%s"
         (match selection with None -> "<None>" | Some s -> s));
      *)

      match selection with
        None -> GMain.clipboard#text
      | x -> x
  in
  (*
     prerr_endline (Printf.sprintf "Text=%s"
     (match text with None -> "<None>" | Some s -> s));
  *)

  match text with
    None -> ()
  | Some text ->
      pastable_history#add (Ed_misc.to_utf8 text);
      v#file#buffer#insert text;
      v#update_my_location