[Geany] infile filetype

classic Classic list List threaded Threaded
3 messages Options
Reply | Threaded
Open this post in threaded view
|  
Report Content as Inappropriate

[Geany] infile filetype

Christian Holland
Hello,
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 mailing list
[hidden email]
http://lists.uvena.de/cgi-bin/mailman/listinfo/geany
Reply | Threaded
Open this post in threaded view
|  
Report Content as Inappropriate

Re: [Geany] infile filetype

Lex Trotman


On 3 April 2010 02:14, Christian Holland <[hidden email]> wrote:
Hello,
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.


Hi 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 else none

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 patches welcome.

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.

Cheers
Lex


_______________________________________________
Geany mailing list
[hidden email]
http://lists.uvena.de/cgi-bin/mailman/listinfo/geany



_______________________________________________
Geany mailing list
[hidden email]
http://lists.uvena.de/cgi-bin/mailman/listinfo/geany
Reply | Threaded
Open this post in threaded view
|  
Report Content as Inappropriate

Re: [Geany] infile filetype

Enrico Tröger
On Sat, 3 Apr 2010 12:39:41 +1100, Lex wrote:

>On 3 April 2010 02:14, Christian Holland <[hidden email]> wrote:
>
>>  Hello,
>> 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.
>>
>>
>Hi 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
>else none
>
>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
>patches welcome.
>
>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.


Regards,
Enrico

--
Get my GPG key from http://www.uvena.de/pub.key

_______________________________________________
Geany mailing list
[hidden email]
http://lists.uvena.de/cgi-bin/mailman/listinfo/geany

attachment0 (205 bytes) Download Attachment
Loading...