   # Convert Atom snippet into Sublime Text completion
   atomToSubl: ->
     editor = @workspace.getActiveTextEditor()
-    if typeof editor is "undefined"
+    unless editor?
       @atom.beep()
       return
     text = editor.getText()


    for k,v of obj.completions
      unless typeof v.trigger is 'undefined'
        completions[v.trigger] = { prefix: v.trigger, body: v.contents }

    atom = { }


    # Convert to CSON
    @makeCoffee(editor, input)

  appendTabStop: (input) ->
    unless input.match(/\$\d+$/g) is null
      # nothing to do here
      return input

    re  = /\${?(\d+)/g;
    tabStops = [];

    while (m = re.exec(input)) != null
      tabStops.push m[1]

    # no tab-stops
    unless tabStops.length
      return "#{input}$1"
    
    tabStops = tabStops.sort()
    highest = parseInt(tabStops[tabStops.length - 1]) + 1

    return "#{input}$#{highest}"

  trimTabStop: (input) ->

    if input.match(/\$\d+$/g) is null
      # nothing to do here
      return input

    return input.replace(/\$\d+$/g, "")

  makeCoffee: (editor, input) ->
    output = CSON.createCSONString(input)
