# File lib/rbreadline.rb, line 6138
  def _rl_find_completion_word()
    _end = @rl_point
    found_quote = 0
    delimiter = 0.chr
    quote_char = 0.chr

    brkchars = nil
    if @rl_completion_word_break_hook
      brkchars = send(@rl_completion_word_break_hook)
    end
    if brkchars.nil?
      brkchars = @rl_completer_word_break_characters
    end
    if (@rl_completer_quote_characters)
      # We have a list of characters which can be used in pairs to
      # quote substrings for the completer.  Try to find the start
      # of an unclosed quoted substring.
      # FOUND_QUOTE is set so we know what kind of quotes we found.
      scan = 0
      pass_next = false
      while scan < _end
        if !@rl_byte_oriented
          scan = _rl_find_next_mbchar(@rl_line_buffer, scan, 1, MB_FIND_ANY)
        else
          scan += 1
        end

        if (pass_next)
          pass_next = false
          next
        end

        # Shell-like semantics for single quotes -- don't allow backslash
        #   to quote anything in single quotes, especially not the closing
        #   quote.  If you don't like this, take out the check on the value
        #   of quote_char.
        if (quote_char != "'" && @rl_line_buffer[scan,1] == "\\")
          pass_next = true
          found_quote |= RL_QF_BACKSLASH
          next
        end

        if (quote_char != 0.chr)
          # Ignore everything until the matching close quote char.
          if (@rl_line_buffer[scan,1] == quote_char)
            # Found matching close.  Abandon this substring.
            quote_char = 0.chr
            @rl_point = _end
          end

        elsif (@rl_completer_quote_characters.include?(@rl_line_buffer[scan,1]))

          # Found start of a quoted substring.
          quote_char = @rl_line_buffer[scan,1]
          @rl_point = scan + 1
          # Shell-like quoting conventions.
          if (quote_char == "'")
            found_quote |= RL_QF_SINGLE_QUOTE
          elsif (quote_char == '"')
            found_quote |= RL_QF_DOUBLE_QUOTE
          else
            found_quote |= RL_QF_OTHER_QUOTE
          end
        end
      end
    end

    if (@rl_point == _end && quote_char == 0.chr)

      # We didn't find an unclosed quoted substring upon which to do
      #   completion, so use the word break characters to find the
      #   substring on which to complete.


      while (@rl_point =  !@rl_byte_oriented ?
             _rl_find_prev_mbchar(@rl_line_buffer, @rl_point, MB_FIND_ANY):(@rl_point-1))>0

        scan = @rl_line_buffer[@rl_point,1]
        if !brkchars.include?(scan)
          next
        end
        # Call the application-specific function to tell us whether
        #   this word break character is quoted and should be skipped.
        if (@rl_char_is_quoted_p && found_quote!=0 &&
            send(@rl_char_is_quoted_p,@rl_line_buffer, @rl_point))
          next
        end

        # Convoluted code, but it avoids an n^2 algorithm with calls
        #   to char_is_quoted.
        break
      end
    end

    # If we are at an unquoted word break, then advance past it.
    scan = @rl_line_buffer[@rl_point,1]

    # If there is an application-specific function to say whether or not
    #   a character is quoted and we found a quote character, let that
    #   function decide whether or not a character is a word break, even
    #   if it is found in rl_completer_word_break_characters.  Don't bother
    #   if we're at the end of the line, though.
    if (scan != 0.chr)
      if (@rl_char_is_quoted_p)
        isbrk = (found_quote == 0 ||
                 !send(@rl_char_is_quoted_p,@rl_line_buffer, @rl_point)) &&
                 brkchars.include?(scan)
      else
        isbrk = brkchars.include?(scan)
      end

      if (isbrk)
        # If the character that caused the word break was a quoting
        #   character, then remember it as the delimiter.
        if (@rl_basic_quote_characters &&
            @rl_basic_quote_characters.include?(scan) &&
            (_end - @rl_point) > 1)
          delimiter = scan
        end

        # If the character isn't needed to determine something special
        #   about what kind of completion to perform, then advance past it.
        if (@rl_special_prefixes.nil? || !@rl_special_prefixes.include?(scan) )
          @rl_point+=1
        end
      end
    end

    return [quote_char,found_quote!=0,delimiter]
  end