-
Notifications
You must be signed in to change notification settings - Fork 53
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
new TeX mode (again) #625
new TeX mode (again) #625
Conversation
Thanks for your work. |
Applying the file obtained by appending .patch to this PR
on top of the 0.60.8 tarball, besides the manual
1 out of 1 hunk FAILED -- saving rejects to file manual/aspell.1.rej
1 out of 5 hunks FAILED -- saving rejects to file manual/aspell.texi.rej
I get this failure:
3 out of 6 hunks FAILED -- saving rejects to file modules/filter/tex.cpp.rej
|
@dkwo: That's strange. I've downloaded the patch and the 0.60.8 tar ball. Then
gives (among other things)
|
My bad, sorry about that. I downloaded the patch again, and now it applies cleanly, if I remove the manuals part. |
To ignore
into your |
Thank you. |
I've been using this for almost a year, can confirm it works well. |
@@ -63,6 +63,7 @@ namespace { | |||
|
|||
PosibErr<bool> ContextFilter::setup(Config * config){ | |||
name_ = "context-filter"; | |||
order_num_ = 0.15; |
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.
Changing the order number is likely to break something. If it needs to be changed than it should be an option to the context filer, something like "order-num <float>" where float is a number between 0 and 1.
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.
At present, order_num
is not defined at all for the context filter. What does that mean? Is the filter applied first, last or somewhere else? (If I knew the answer 12 years ago when I wrote this patch, I've forgotten it in the meantime.)
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.
It defaults to 0.50:
aspell/common/indiv_filter.hpp
Line 92 in 875068a
IndividualFilter() : name_(0), order_num_(0.50) {} |
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.
@kevina I understand your concern that this may break something. For the new TeX mode, however, it is important that the context filter comes first. So it would have to be added as an option. Unfortunately, my familiarity with the aspell code is (and never was) sufficient to add such an option. Would you be willing to help out?
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.
Yes. It shouldn't be too hard to modify the context filter to add the option.
@dkwo @matthias314 my main concern with this is causing a regression. I would be more willing to accept this if it has some test cases. There is now a primitive framework for this is the tests/ directory (see the filter-test target in the Makefile). Ideally I would like to first accept a pull request with some tests for the existing TeX filter to make sure this new filter doesn't break anything. |
@matthias314, I am leaning towards accepting this once the above issues are resolved. |
To be clear by above issues I mean the two comments in the code review, tests would be nice, but not really required. |
I'm very sorry for my belated reply. Regarding a potential regression: That's a valid point. I've been using the new TeX mode for many years now, but only on a very limited variety of LaTeX documents. By the same token, I think that if I got around to add test documents, then they would only cover a tiny fraction of the kinds of documents other users have. Would be a possible alternative to add the new TeX mode besides the existing one so that users could fall back to the old version in case the new one causes problems? |
I thought about that, but rejected the idea as being too complicated, but that was many years ago. I'll have another look sometime soonish. Hopefully by the end of the weekend. |
Closing in favor of #644 |
This patch (hopefully) improves Aspell's TeX mode. It is practically identical to the one posted to the Aspell mailing list in 2011.
New features implemented by this patch
Aspell skips over math content inside
$...$
,$$..$$
,\(...\)
,\[...\]
and common LaTeX and AMS-LaTeX environments likeequation
andgather
. Additional environments to be skipped over can be defined via the newtex-ignore-env
list. Otherwise math formulas trigger a huge number of false alarms.Forced spell-checking of macro arguments while skipping over arguments or environments. This is achieved with the new
T
option toadd-tex-command
. Remarks added in 2022 about theT
option:T
was supposed to mean "toggle". MaybeF
for "force" would be a better choice.P
option? Asked differently: What LaTeX macros are there usingP
where we don’t want the corresponding argument to be spell checked in math mode? Such a macro should also have arguments without spell checking because otherwise there is no need to define it in Aspell. I can only think of\textcolor{color}{text}
fromcolor.sty
(wheretext
can also be in math mode!).Discretionary hyphens and italic corrections are ignored. For example,
hy\-phen
andshelf\/ful
are recognized as single words.Spell-checking can be manually switched on and off by putting the text
aspell:on
andaspell:off
into the file. This allows to skip over macro definitions and other parts of text that confuse Aspell.See the Info file for more details.
Comments about the changes
./modules/filter/context.cpp
It seems that the order of the context filter was undefined. Whether one wants to have this filter before or after other filters depends on the application in mind. I need it before the tex filter so that one can place the
aspell:off
andaspell:on
flags inside TeX comments../modules/filter/tex.cpp
The new code for the tex filter.
./modules/filter/tex-filter.info
The new default settings for the filter variables.
tex-ignore-env
is new. Most changes totex-command
are related to the newT
option. The newbegin
line is used internally. The rest are additions and corrections to existing definitions../modules/filter/modes/tex.amf
Note that we enable the context filter by default.
./manual/aspell.1
./manual/aspell.texi
Updated documentation.