Hey folks,
I just hacked together a quick language grammar for LaTeX log files to better see where things are odd ;)
Dan
PS: I am not really sure if the naming below makes sense from the naming convention's viewpoint, but it does the job of generating markup.
{ scopeName = 'source.log.error.latex'; fileTypes = ( 'log' ); foldingStartMarker = '/**|(\s*$'; foldingStopMarker = '**/|^\s*)'; patterns = ( { name = 'invalid.deprecated'; match = '.*Warning:'; }, { name = 'invalid.illegal'; match = '.*Error'; }, { name = 'entity.name.function'; match = '.*.sty'; }, { name = 'entity.name.class'; match = '.*.cls'; }, { name = 'entity.name.tag.configuration'; match = '.*.cfg'; }, { name = 'entity.name.tag.definition'; match = '.*.def'; }, { name = 'comment.documentation'; match = '.*Info.*'; }, { name = 'meta.log.latex.fixme'; match = '.*FiXme:'; }, { name = 'meta.log.latex.hyphenation'; begin = '(Overfull|Underfull)'; end = '([]\n)'; captures = { 1 = { name = 'keyword.control.hyphenation.latex'; }; }; patterns = ( { name = 'variable.parameter.hyphenation.latex2'; match = '[0-9]+--[0-9]+'; } ); }, { name = 'meta.log.latex.filename'; begin = '(<)'; end = '(>)'; captures = { 1 = { name = 'string'; }; 2 = { name = 'storage'; }; 3 = { name = 'string'; }; }; patterns = ( { name = 'support.function.with-arg.latex'; match = '(.*/.*.pdf)'; captures = { 1 = { name = 'entity.name'; };}; } ); }, ); }
{ scopeName = 'source.log.error.latex'; fileTypes = ( 'log' );
Don't know anything about latex, but using the .log filetype is going to be a bit greedy if this is included in the default latex bundle. Should probably just not include one and let latex users select it manually.
On Apr 10, 2006, at 6:32 AM, Michael Sheets wrote:
{ scopeName = 'source.log.error.latex'; fileTypes = ( 'log' );
Don't know anything about latex, but using the .log filetype is going to be a bit greedy if this is included in the default latex bundle. Should probably just not include one and let latex users select it manually.
Automatic detection of file types seems to be a weak point in the TextMate bundle system. The problem, of course, is that some file extensions (e.g., .log, .xml) are overloaded. They could be any one of a number of different file types, as Michael pointed out above. (I mentioned a similar problem with XML files a couple weeks ago.)
I realize there's a firstLineMatch field that solves this problem in situations where a file type must have a "signature" on its first line, but a lot of files types don't have this. Perhaps an additional (but optional) field is necessary: lineMatch, for example. Like firstLineMatch, this would be a regular expression, but instead of matching only the first line, it would match any line in the file. TextMate could run this regular expression through a file when it's loaded, and if it gets a match, it would know the true language of the file and could automatically set the file type.
Although there might still be collisions (and maybe performance issues when loading large files), it seems to me that this would go a long way toward solving the problem mentioned above.
Trevor
I realize there's a firstLineMatch field that solves this problem in situations where a file type must have a "signature" on its first line, but a lot of files types don't have this. Perhaps an additional (but optional) field is necessary: lineMatch, for example. Like firstLineMatch, this would be a regular expression, but instead of matching only the first line, it would match any line in the file. TextMate could run this regular expression through a file when it's loaded, and if it gets a match, it would know the true language of the file and could automatically set the file type.
Scanning the entire file (then scanning it again when you choose a syntax) is probably a bit too taxing, especially for large files. It has been mentioned before to expand it to scan the first few lines however, though I don't know what allan's plans are for it.
On Apr 10, 2006, at 7:35 PM, Michael Sheets wrote:
Scanning the entire file (then scanning it again when you choose a syntax) is probably a bit too taxing, especially for large files.
That's true; perhaps it would only scan the first 500 or 1000 lines or something. Also, note that it wouldn't have to scan all the files that are opened, only those whose extension happens to match a language type with a lineMatch field in it.
Trevor
Trevor Harmon wrote:
I realize there's a firstLineMatch field that solves this problem in situations where a file type must have a "signature" on its first line, but a lot of files types don't have this.
The LaTeX log files have a signature on the first line, and I adjusted the log syntax to use this. It's not necessary to have that signature there, but LaTeX just puts it there.
I agree that it would be nice to expand it to the first few lines. But I think that with the first line match, extension match and personal sticky preference, TextMate already covers more than 95% of users needs.
Jeroen.
On 10/4/2006, at 21:06, Trevor Harmon wrote:
[ regexp search to sniff file types ] Although there might still be collisions (and maybe performance issues when loading large files), it seems to me that this would go a long way toward solving the problem mentioned above.
There will certainly be performance problems -- and I am not sure it will solve more than the current system.
I added the two cases I am aware of to a wiki page [1] where people are encouraged to add the actual problems they face with the current system.
I certainly haven’t crossed the “improve file type sniffing” from my to-do, it’s just that I do not see the current system as weak. It’s just not perfect. But to make it perfect, I think it is unavoidable to introduce some sort of logic into the system.
Hi,
Great, thanks! I've added it to the bundle repository.
I made two small modifications: I removed the log extension binding. And I've added a match for "filename:line-number:error" messages.
Jeroen.