 
     # the grammar is not white listed (and there are things whitelisted)
     autofoldGrammars = atom.config.get('fold-functions.autofoldGrammars')
-    if autofoldGrammars.length > 0 and grammar.name not in autofoldGrammars
+    if autofoldGrammars and autofoldGrammars.length > 0 and grammar.name not in autofoldGrammars
       @debugMessage('fold functions: autofold grammar not whitelisted', grammar.name)
       return false
 
     # the grammar is not in the ignore grammar list
     autofoldIgnoreGrammars = atom.config.get('fold-functions.autofoldIgnoreGrammars')
-    if autofoldIgnoreGrammars.length > 0 and grammar.name in autofoldIgnoreGrammars
+    if autofoldIgnoreGrammars and autofoldIgnoreGrammars.length > 0 and grammar.name in autofoldIgnoreGrammars
       @debugMessage('fold functions: autofold ignored grammar', grammar.name)
       return false
 
     # check if the file is too short to run
-    if shortfileCutoff = atom.config.get('fold-functions.shortfileCutoff')
+    if shortfileCutoff = atom.config.get('fold-functions.shortfileCutoff', 42)
       # make sure the file is longer than the cutoff before folding
-      if shortfileCutoff > 0 and editor.getLineCount() >= shortfileCutoff
+      if (shortfileCutoff > 0 and editor.getLineCount() >= shortfileCutoff)
+        @debugMessage('fold functions: autofold turned on')
         autofold = true
+    # if shortfileCutoff = 0/false/-1 then we should still turn on autofolding
+    else
+      @debugMessage('fold functions: autofold turned on')
+      autofold = true
 
     # figure out if we should skip autofolding because we are not on the first
     # line of the file.

    lines = foldableLines = fold = unfold = toggle = 0
    bufferHasFoldableLines = false
    for row in [0..editor.getLastBufferRow()]
      foldable = editor.isFoldableAtBufferRow(row)
      isFolded = editor.isFoldedAtBufferRow(row)
      isCommented = editor.isBufferRowCommented(row)

      bufferHasFoldableLines = true if foldable


      editor = atom.workspace.getActiveTextEditor()

    if not editor
      @debugMessage('fold functions: no editor, skipping')
      return false

    @debugMessage('fold functions: action=', action)
    @indentLevel = @indentLevel || null
