modeline: choose a parser by emacs mode specification at the first line

If a parser for a given file cannot be determined by file extension,
a editor mode line can be used as a good hint for the choice.

emacs detects following two formats at the first line of a file as a
mode specification:

     -*- MODE -*-[1]

     -*- mode: MODE; ... -*-[2]

[1] https://www.gnu.org/software/emacs/manual/html_node/emacs/Choosing-Modes.html#Choosing-Modes
[2] https://www.gnu.org/software/emacs/manual/html_node/emacs/Specifying-File-Variables.html
This patch makes ctags determines a parser by this mode specification.

TODO: getPatternLanguage is not considered yet.

Signed-off-by: Masatake YAMATO <yamato@redhat.com>
modeline: a test case for choosing a parser from "-*- mode: MODE; ... -*-" editor mode line

Signed-off-by: Masatake YAMATO <yamato@redhat.com>
modeline: a test case for choosing a parser from "-*- MODE -*-" editor mode line

Signed-off-by: Masatake YAMATO <yamato@redhat.com>
modeline: choose a parser by emacs mode specification at the end of file

emacs detects following format at the end of file as a mode specification[1]:

     Local Variables:
     mode: MODE
     ...
     End:

This patch makes ctags determines a parser by this mode specification.

[1] https://www.gnu.org/software/emacs/manual/html_node/emacs/Specifying-File-Variables.html

Signed-off-by: Masatake YAMATO <yamato@redhat.com>
modeline: a test case for choosing a parser from "Local Variables:" editor mode line

Signed-off-by: Masatake YAMATO <yamato@redhat.com>
modeline: use shbang line to choose a parser even if the file is not executable

Signed-off-by: Masatake YAMATO <yamato@redhat.com>
modeline: check emacs modeline appeared on the second line

Generally -*- MODE -*- style emacs modeline must be appeared on
the first line of the file. However, if the first line is #! shbang,
the modeline can be appeared on the second line. This patch handles
this case.

Signed-off-by: Masatake YAMATO <yamato@redhat.com>
modeline: a test case for choosing a parser from the seconde line after #!

Signed-off-by: Masatake YAMATO <yamato@redhat.com>
modeline: choose a parser by vim modeline specification

vim detects following format at the end of file as a mode specification[1][2]:

     /* vim: set filetype=FILETYPE */

This patch makes ctags determines a parser by this mode specification.

[1] http://vimdoc.sourceforge.net/htmldoc/options.html#modeline
[2] http://vimdoc.sourceforge.net/htmldoc/filetype.html#filetype

Signed-off-by: Masatake YAMATO <yamato@redhat.com>
modeline: add unit test cases for vim modeline detection

Signed-off-by: Masatake YAMATO <yamato@redhat.com>
modeline: make shbang and modeline take precedence of extension when choosing a parser

Choosing parser by file extension can conflict.  For example ".m" is
used by ObjectiveC and Matlab.  shbang and modline is more specific
hint for choosing a parser than file extension.

TODO: Documents must be updated.

Signed-off-by: Masatake YAMATO <yamato@redhat.com>
Merge pull request #41 from masatake/modeline

use modeline as a hint for choosing a parser