#121 SciTe Mime Magic

Completed
closed
SciTE (234)
2
2011-11-02
2004-02-15
No

SciTe should be able to recognize the most common file
types even if there is no or wrong file extension. For
instance, files starting with "<!DOCTYPE"
oder "<html>" should be recognized as HTML, "<?xml "
as XML, "#! ... python" as Python etc. The Apache web
server has such a feature in the mod_mime_magic
module and there is also a Unix command "file" which
does the same.

I have registered SciTE as my source text editor for the
internet explorer (you can do this with Tweak UI),
however since the file is handed over without extension,
SciTe does not recognize that it is HTML. It would be
nice if SciTE would automatically recognize HTML.

Discussion

  • Neil Hodgson

    Neil Hodgson - 2004-02-16
    • priority: 5 --> 2
    • assigned_to: nobody --> nyamatongwe
     
  • Neil Hodgson

    Neil Hodgson - 2004-02-16

    Logged In: YES
    user_id=12579

    May be useful although there would be the possibility of
    guessing wrong and also a need for a precedence between the
    two methods. I won't be implementing this.

     
  • Nobody/Anonymous

    Logged In: NO

    how about using the "file" program?

     
  • Neil Hodgson

    Neil Hodgson - 2004-07-08

    Logged In: YES
    user_id=12579

    I think running an external program to sniff file types will
    be too slow and 'file' may not always be available.

     
  • Christoph Zwerschke

    Logged In: YES
    user_id=193957

    I agree. There should be no dependency from an external
    program. But maybe one could integrate the core file
    recognition algorithm of the file utility into SciTE? The source
    is freely available:
    http://www.darwinsys.com/freeware/file.html

    However, this would be a big overkill since "file" also handles
    binary file types and compressed files which is of course a lot
    more tricky than handling text files, which is the only case
    we need here. Actually, we need to know only those file
    types which are languages covered by SciTE.

    I think the logical and reasonable approach would be to
    include hints about how the file type can be detected in the
    language specific property files, just as the associated file
    extensions are listed there.

    SciTe could search for these patterns in the first 2 non-empty
    lines of the document, if the document seems to be a text
    document. If it finds the pattern (simple substring or regular
    expression) there, it can safely assume the file is of that type.

    In the global properties file one could add a parameter which
    allows disabling automatic file type detection, or the order of
    priority (default: first by file extension, then by text
    patterns).

     
  • Neil Hodgson

    Neil Hodgson - 2004-07-10

    Logged In: YES
    user_id=12579

    You are right about the actual file code: it is enormous for
    this small feature. If you want to contribute something very
    simple then I will include it if it works well and is
    optional. This is not something I will be able to implement.

     
  • Neil Hodgson

    Neil Hodgson - 2011-11-02

    It may be possible to use command.discover.properties for this.

     
  • Neil Hodgson

    Neil Hodgson - 2011-11-02
    • milestone: --> Completed
    • labels: --> SciTE
    • status: open --> closed
     

Get latest updates about Open Source Projects, Conferences and News.

Sign up for the SourceForge newsletter:





No, thanks