# File lib/rbreadline.rb, line 5882
  def _rl_copy_to_kill_ring(text, append)
    # First, find the slot to work with.
    if (!@_rl_last_command_was_kill)
      # Get a new slot.
      if @rl_kill_ring.nil?
        # If we don't have any defined, then make one.
        @rl_kill_ring_length = 1
        @rl_kill_ring = Array.new(@rl_kill_ring_length+1)
        @rl_kill_ring[slot = 0] = nil
      else
        # We have to add a new slot on the end, unless we have
        #   exceeded the max limit for remembering kills.
        slot = @rl_kill_ring_length
        if (slot == @rl_max_kills)
          @rl_kill_ring[0,slot] = @rl_kill_ring[1,slot]
        else
          slot = @rl_kill_ring_length += 1
        end
        @rl_kill_ring[slot-=1] = nil
      end
    else
      slot = @rl_kill_ring_length - 1
    end

    # If the last command was a kill, prepend or append.
    if (@_rl_last_command_was_kill && @rl_editing_mode != @vi_mode)
      old = @rl_kill_ring[slot]

      if (append)
        new = old + text
      else
        new = text + old
      end
      old = nil
      text = nil
      @rl_kill_ring[slot] = new
    else
      @rl_kill_ring[slot] = text
    end

    @rl_kill_index = slot
    0
  end