+###*
+ * Main list-edit module.
+ *
+ * @module ListEdit
+###
+
 {CompositeDisposable, Range, TextBuffer} = require 'atom'
 _ = require 'underscore-plus'
 TextManipulation = require './text-manipulation'

    , eltRanges: eltRanges
    }

  getListEditMeta: (clip) ->
    clip.metadata if clip?.metadata?.id == 'list-edit-clip-meta'

  ignoreScopes: ['string', 'comment']

  # Return all ranges that have a scope from ignoreScopes. Connecting ranges are merged.
  scanIgnoreRanges: (editor, textBuffer, bufferText) ->
    grammar = editor.getGrammar()
    ignoredScopeIds = []
    for scope, scopeId of grammar.registry.idsByScope # TODO: is this how we should access the GrammarRegistry?

          # Can also use => in the definition of the callbacks that require @, but this is safer
          (callback.bind this) editor, textBuffer, bufferText, selectionIxRange, elementList, listSelection

  ###*
   * Clipboard metadata for list-edit operations. Contains the specifics for the source list of a copy or cut operation.
   *
   * @global
   * @typedef {Object} ListEditMeta
   * @property {string}     id                - Is always 'list-edit-clip-meta'.
   * @property {string}     openBracket       - String of length 1.
   * @property {string}     initialWhitespace - Whitespace following the opening bracket.
   * @property {string}     finalWhitespace   - Whitespace preceding the closing bracket.
   * @property {string}     separator         - String of length 1.
   * @property {number[][]} eltRanges         - Character index in clipboard string (not buffer) for actual list elements (without leading/trailing whitespace).
  ###

  ###*
   * Create clipboard metadata object.
   *
   * @param  {ElementList} elementList Source element list for the clip.
   * @param  {number} selStart    Buffer-text index of start of selection.
   * @param  {number} selEnd      Buffer-text index of end of selection.
   * @return {ListEditMeta}
  ###
  mkListEditMeta: (elementList, selStart, selEnd) ->
    { startIx: listStartIx, endIx: listEndIx
    , openBracket: openBracket, separator: separator
