     ) or beautifiers[0]
     return beautifier
 
+  getExtension : (filePath) ->
+    if filePath
+      return path.extname(filePath).substr(1)
+
+  getLanguages : (grammar, filePath) ->
+    # Get language
+    fileExtension = @getExtension(filePath) 
+
+    if fileExtension
+      languages = @languages.getLanguages({grammar, extension: fileExtension})
+    else
+      languages = @languages.getLanguages({grammar})
+
+    logger.verbose(languages, grammar, fileExtension)
+
+    return languages
+
   getLanguage : (grammar, filePath) ->
-    # Get language
-    fileExtension = path.extname(filePath)
-    # Remove prefix "." (period) in fileExtension
-    fileExtension = fileExtension.substr(1)
-    languages = @languages.getLanguages({grammar, extension: fileExtension})
-    logger.verbose(languages, grammar, fileExtension)
+    languages = @getLanguages(grammar, filePath)
+
     # Check if unsupported language
-    if languages.length < 1
-      return null
-    else
-      # TODO: select appropriate language
+    if languages.length > 0
       language = languages[0]
+
+    return language
 
   getOptionsForLanguage : (allOptions, language) ->
     # Options for Language

        logger.info('beautify', text, allOptions, grammar, filePath, onSave)
        logger.verbose(allOptions)

        # Get language
        fileExtension = path.extname(filePath)
        # Remove prefix "." (period) in fileExtension
        fileExtension = fileExtension.substr(1)
        languages = @languages.getLanguages({grammar, extension: fileExtension})
        logger.verbose(languages, grammar, fileExtension)

        # Check if unsupported language
        if languages.length < 1
          unsupportedGrammar = true

          logger.verbose('Unsupported language')

          if atom.config.get("atom-beautify.general.muteUnsupportedLanguageErrors")
            return resolve( null )
          else
            fileExtension = @getExtension(filePath)
            repoBugsUrl = pkg.bugs.url
            title = "Atom Beautify could not find a supported beautifier for this file"
            detail = """
