Learn how easy it is to sync an existing GitHub or Google Code repo to a SourceForge project! See Demo

Close

#107 file types

open
nobody
None
5
2011-12-18
2011-12-18
No

This patch adds the ability to specify file types in ftyperc. It allows us to remove a ton of redundant code. To demonstrate, the entries for Python go from

Python
*
+#!\+\[ ]\+\[a-z/]\+\[ ]python\>
-autoindent
-syntax python
-highlighter_context
-smarthome
-smartbacks
-purify
-single_quoted
-pound_comment

*.py
-autoindent
-syntax python
-highlighter_context
-smarthome
-smartbacks
-purify
-single_quoted
-pound_comment

to

Python
[python]
* #!\+\[ ]\+\[a-z/]\+\[ ]python\>
*.py
-autoindent
-syntax python
-highlighter_context
-smarthome
-smartbacks
-purify
-single_quoted
-pound_comment

You specify a file type in square brackets, followed by the name regexes and optional contents regexes, followed by the options for that file type. All of the options get applied to all of the regexes.

If you have specified a file type, then the contents regexes are separated from their corresponding file name regexes by whitespace instead of having them on the next line with a '+'. It was confusing having them on the next line now that the regexes are all on consecutive lines. If you have not specified a file type, then whitespace after a name regex starts a comment, and contents regexes need to be on a following line after a '+', just like before, in order to be backwards compatible.

The way this works is that there is still one option set per name regex, and an additional field called ftype. When an ftype has been specified, we apply any options to all previous option sets that have the same ftype. Another, perhaps better, way to do things would be to have one option set for each ftype, but then we would need a linked list for the name and contents regexes. What do you think?

By the way, I added a few patterns, removed one (that I requested but now think was a mistake), and removed -wordwrap from [asm]. Was there a reason to turn on word-wrap for assembly files? Since they can have line comments, wrapping seems like a bad idea to me, and has annoyed me several times in the past. But if you think it should be there, then just add it back in, since I can always override ftyperc with my own.

This patch is on top of patch 3459260.

Discussion

  •  
    Attachments