# File lib/rbreadline.rb, line 8222
  def _rl_nsearch_dosearch(cxt)
    @rl_mark = cxt.save_mark

    # If rl_point == 0, we want to re-use the previous search string and
    #   start from the saved history position.  If there's no previous search
    #   string, punt.
    if (@rl_point == 0)
      if @noninc_search_string.nil?
        rl_ding()
        rl_restore_prompt()
        rl_unsetstate(RL_STATE_NSEARCH)
        return -1
      end
    else
      # We want to start the search from the current history position.
      @noninc_history_pos = cxt.save_line
      @noninc_search_string = @rl_line_buffer.dup

      # If we don't want the subsequent undo list generated by the search
      #matching a history line to include the contents of the search string,
      #we need to clear rl_line_buffer here.  For now, we just clear the
      #undo list generated by reading the search string.  (If the search
      #fails, the old undo list will be restored by rl_maybe_unsave_line.)
      rl_free_undo_list()
    end

    rl_restore_prompt()
    noninc_dosearch(@noninc_search_string, cxt.direction)
  end