[Geany] infile filetype
enrico.troeger at xxxxx
Sat Apr 3 15:35:17 UTC 2010
On Sat, 3 Apr 2010 12:39:41 +1100, Lex wrote:
>On 3 April 2010 02:14, Christian Holland <mail at cholland.de> wrote:
>> I search about a possibility to set the filetype in the file itself.
>> E.g. a file is identified as shell script cause
>> first line starts with '#!/bin/bash',
>> but inside perl is called with -x.
>> So the file should be formatted as perl script automatically at
>> startup. I know, I can set the filetype within the menus,
>> but I have to do this everytime the is loaded.
>> With vim it is possible to do this automatically when the file is
>> loaded with a line '# vim: set filetype=perl:'.
>> For the encoding type, geany recognized a line with
>> '# coding: ISO-8859-15' .
>> I searched and tried with '# geany_filetype: perl' and
>> '# filetype: perl', but the auto filetype is shell-script at startup.
>> So, is there a possibility to set the filetype in the file itself ?
>> Regards Chris.
>Geany detects filetype by:
>1. if the file starts with #! and one of the recognised command names
>(sh, bash, perl, python etc.) then use that filetype
>2. if the file starts with <! DOCTYPE html or <html uses html unless
>the file extension is one of the perl, php or python extensions when
>it uses that instead
>3. if the file starts <?xml then xml or <?php then php
>4. if none of the above then a recognised extension sets the filetype
>There has been discussion about recognising Emacs and/or vim filetype
>marks but shtdi and no one has needed it that bad to be motivated, but
>In your case there are two filetypes so it would depend on the order
>the tests were done which it would use, I guess if Emacs or vim mark
>is present then that overrides the others even though the bash mark
>would precede the emacs/vim mark.
There was a similar bug report before, IIRC a user had a shell script
which itself executed some TCL/Tk. IMHO such things, also the example
above, are shell scripts and so Geany's auto-detection is correct.
I never understood why one would write a shell script which only
executes code of another language.
But still, if it would be really that necessary, maybe we could
implement something like a geany_filetypes modeline.
Get my GPG key from http://www.uvena.de/pub.key
-------------- next part --------------
A non-text attachment was scrubbed...
Name: not available
Size: 198 bytes
Desc: not available
More information about the Users