You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
The reason will be displayed to describe this comment to others. Learn more.
Hi,
since 0.8.5 I have the problem that atom-latex sets the scope to "text.tex.latex.beamer" even in non-beamer LaTeX documents. I had to add the beamer-scope to the spell-checker and "LaTeX-Tree" does no longer work. Small things, nevertheless, I ask myself if this can be related to this change?
The reason will be displayed to describe this comment to others. Learn more.
@Tobii42 I noticed this as well - the default grammar is now set to text.tex.latex.beamer for any .tex document. @mcocdawc what was the reason this was added here?
The reason will be displayed to describe this comment to others. Learn more.
Before going into the code:
My assumption for this change was that regular Tex as well as beamer Tex documents have .tex as file ending. And looking into the code of latex beamer.cson and latex.cson I thought this was the assumption of the original author.
Based on the two REGEXes
# Matches beamer documents
firstLineMatch: "^\\\\documentclass(\\[.*\\])?\\{beamer\\}"
# Matches every documentclass statement, except for beamer ones
firstLineMatch: "^\\\\documentclass(?!.*\\{beamer\\})"
TEX documents are then filtered to be either regular or beamer tex files.
Without
fileTypes: [
"tex"
]
The test for detecting beamer documents is never performed. So I added it in the PR.
Now the problem is, that usually one has comments in front of the documentclass, e.g. %!TEX TS-program = pdflatex. So both REGEXes don't match and it has to fallback to the default (which apparently now is beamer.)
Tests to confirm this:
The grammar detection works, if there are no comments before \documentclass.
If you do touch test.tex && atom test.tex the empty file has text.tex.latex.beamer grammar.
IMHO the underlying problem is, that firstLineMatch is called on the first line and not on the first uncommented line. On the other hand regular tex files appear much more frequent than beamer tex files,
so it might make sense to change the default. Of course this will surprise users as well, because a beamer document with comments in front will have regular latex instead of beamer grammar.
If you can confirm the finding it might make sense to create an issue regarding firstLineMatch on the atom dev page.
The reason will be displayed to describe this comment to others. Learn more.
Your right, I guess it loads the latex beamer grammar before latex and hence the default is now LaTeX Beamer for a .tex that doesn't have a proper firstLineMatch.
I must admit, I am not to well versed with this, but it looks like we can get firstLineMatch to match multiple lines - the underlying function from the grammar-registry is grammarMatchesPrefix
Another option is to load up the base latex grammar, and use an injector for the Beamer class?
788796b
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Hi,
since 0.8.5 I have the problem that atom-latex sets the scope to "text.tex.latex.beamer" even in non-beamer LaTeX documents. I had to add the beamer-scope to the spell-checker and "LaTeX-Tree" does no longer work. Small things, nevertheless, I ask myself if this can be related to this change?
Greetings and thanks for your work!
788796b
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@Tobii42 I noticed this as well - the default grammar is now set to
text.tex.latex.beamer
for any.tex
document.@mcocdawc what was the reason this was added here?
788796b
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Before going into the code:
My assumption for this change was that regular Tex as well as beamer Tex documents have
.tex
as file ending. And looking into the code oflatex beamer.cson
andlatex.cson
I thought this was the assumption of the original author.Based on the two REGEXes
TEX documents are then filtered to be either regular or beamer tex files.
Without
The test for detecting beamer documents is never performed. So I added it in the PR.
Now the problem is, that usually one has comments in front of the documentclass, e.g.
%!TEX TS-program = pdflatex
. So both REGEXes don't match and it has to fallback to the default (which apparently now is beamer.)Tests to confirm this:
\documentclass
.touch test.tex && atom test.tex
the empty file hastext.tex.latex.beamer
grammar.IMHO the underlying problem is, that firstLineMatch is called on the first line and not on the first uncommented line. On the other hand regular tex files appear much more frequent than beamer tex files,
so it might make sense to change the default. Of course this will surprise users as well, because a beamer document with comments in front will have regular latex instead of beamer grammar.
If you can confirm the finding it might make sense to create an issue regarding
firstLineMatch
on the atom dev page.BTW: Thank you for taking over the work. ;-)
788796b
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Your right, I guess it loads the
latex beamer
grammar beforelatex
and hence the default is nowLaTeX Beamer
for a.tex
that doesn't have a properfirstLineMatch
.I must admit, I am not to well versed with this, but it looks like we can get
firstLineMatch
to match multiple lines - the underlying function from thegrammar-registry
isgrammarMatchesPrefix
Another option is to load up the base latex grammar, and use an injector for the Beamer class?
788796b
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I could read the REGEX and
firstLineMatch
was self-explaining, but I neither know Javascript nor Coffescript, so I cannot help here.