-
Notifications
You must be signed in to change notification settings - Fork 179
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
Format expandable errors like other errors #931
Comments
my latest last night attempt at ascii art:
we could use that for all error if date = 10/31 :-) More seriously I think the suggested approach is fine and we should make it simple as outlined there. Using a non-printing active char to avoid the |
On 5/18/21 12:36 PM, Frank Mittelbach wrote:
my latest last night attempt at ascii art:
|<argument> \ O> arrg \| mypkg: Some long explanation about 'arg1' |
we could use that for all error if date = 10/31 :-)
Or National Hummingbird Day (in the US), which is the first Saturday in
September. This requires us to have resolved issue #547 (Date and time tools).
https://www.checkiday.com/7e10a9aff26fe865aa2f21c165504cd9/national-hummingbird-day
--------------------------------------------------------------------------------
More seriously I think the suggested approach is fine and we should make it
simple as outlined there.
Using a non-printing active char to avoid the |\| is just asking for trouble
(and the |<argument> \| isn't that bad). But I would drop the ! at the start of
the line --- other LaTeX ...Error: messages don't have that either, so why make
it look half like a Tex half like a LaTeX error?
Ok, I hadn't re-checked what other LaTeX errors do.
Bruno
|
nice one ...we can see about that when #547 is resolved then :-)
I forgot you do not get LaTeX errors with your documents :-) --- it is really just the |
I'm having problems: things like I'm worried that this character translation may be subtly different in different engines. What to do? |
Isn't that because we have explicitly turned those off in the test suite to see the chars as
so I think we can assume this works in real life |
It doesn't work in TeX Lives XeLaTeX. |
it does with the option |
My problem is not with |
certainly something we could try. As I said there is an option call "8bit" if you use that then the |
Using a real unicode char doesn't work because it just displays in my terminal as a square with hex digits inside it. This is in fact already present in the TeX engine (TeXlive's version): when showing the context of an error message, the
I think that this comes from the code around
|
ok so that is the behavior in Knuth's TeX and XeTeX but not in pdftex or luatex. So by disabling new_line_char the print_char routine is displaying So what now, ask for xetex to sync with pdftex and luatex in this regard? Tell users to use -8bit if they don't like the error displays? |
I'm not adding to this commit a couple of LuaTeX-specific l3kernel tests, because they are due to line length and I plan to shorten a few of the error messages to avoid that in more cases.
I've pushed a branch
In contrast the non-expandable errors are formatted as follows (not sure why we have
This works in all engines, without any funny characters, but the error is shifted right by a lot. We could ask on the TeXlive list (and MikTeX) whether they are open to making |
Maybe a solution for XeTeX, could be done along those lines
Maybe U+0370 is a slot taken by now (in my Unicode book it is one of the first unused ones) but then one could select some other unused unicode point. |
Is using |
I asked that too and @blefloch showed me how to ensure that: |
I have read this with interest but as the total length of the error context does not seem extendible, I am not sure using Mentioning in passing that as alternative to
(where |
On 5/19/21 6:49 PM, Skillmon wrote:
Is using |\or| instead of an undefined control sequence a good idea? Do we have
control that an expandable error message is never thrown inside of an |\ifcase|
construct?
That's the purpose of doing \iftrue\expandafter\fi\or, namely TeX is inside an
\iftrue construction (at the deepest level) when expanding \or.
|
nice idea too. I rather like the sound of the low-level error ... so one could have
Maybe better than A variation using the module or package name as @jfbu did, e.g.
Dunno, it is really pity to be so constraint by the number of available characters. |
Meanwhile I realized that the superior aspect of @blefloch If you say, e.g., `\def\a1{...}', then you must always
put `1' after `\a', since control sequence names are
made up of letters only. The macro here has not been
followed by the required stuff, so I'm ignoring it.
This is comparable to current situation with an undefined control sequence, and more verbose than the |
Frank suggested a XeTeX solution making the newlinechar some high unused codepoint and making @jfbu is right about why I preferred
I see the following options.
EDIT: changed the example message and formatting here. |
There is one char we could use perhaps ,which is Having said that, my preference goes for option 2, I think. It gives in my opinion the nicest output without much fuss and it is losing only 2 chars or so over the other solutions (except for 5., but I don't like it so much because that really makes things look totally different). |
@FrankMittelbach You're right about I've changed the formatting of option 5 in my previous message to make it look closer to normal messages. What do you think now? |
@FrankMittelbach Don't look only at the (emailed) unedited version of comments. Of course we cannot have so many !s in the expandable messages only. |
@jfbu you make a good point and I overlooked your |
@FrankMittelbach I looked at old respectable package hyperref.sty and I find this \immediate\write\@auxout{%
\string\providecommand\string\HyperFirstAtBeginDocument{%
\string\AtBeginDocument}^^J%
\string\HyperFirstAtBeginDocument{%
\string\ifx\string\hyper@anchor\string\@undefined^^J%
\string\global\string\let\string\oldcontentsline\string\contentsline^^J%
\string\gdef\string\contentsline%
\string#1\string#2\string#3\string#4{%
\string\oldcontentsline%
{\string#1}{\string#2}{\string#3}}^^J%
\string\global\string\let\string\oldnewlabel\string\newlabel^^J%
\string\gdef\string\newlabel\string#1\string#2{%
\string\newlabelxx{\string#1}\string#2}^^J%
\string\gdef\string\newlabelxx%
\string#1\string#2\string#3\string#4\string#5\string#6{%
\string\oldnewlabel{\string#1}{{\string#2}{\string#3}}}^^J%
\string\AtEndDocument{%
\string\ifx\string\hyper@anchor\string\@undefined^^J%
\string\let\string\contentsline\string\oldcontentsline^^J%
\string\let\string\newlabel\string\oldnewlabel^^J%
\string\fi%
}^^J%
\string\fi%
}^^J%
\string\global\string\let\string\hyper@last\relax^^J%
\string\gdef\string\HyperFirstAtBeginDocument\string#1{\string#1}%
}% A more modern package might not have had the patience of all those EDIT: sorry the |
For the exclamation mark: ok, I will have to add it, and a space, so we lose two characters, but I think it's more important to have exactly the right formatting. Frank, have you managed to make your On making Maybe the two important questions are:
|
I have found the following "real-life" example
This will contain
(running with But if I uncomment the
showing something happened. I grepped for
In the case of catchfilebetweentags, it sets the
so the file end of lines converted to active |
I have found an alternative methods which allows to display
\documentclass{article}
\begin{document}
\long\def\use#1{#1}
\def\boom#1\boom{}
\def\expandableerrormessage#1{%
\expandafter\Clean\boom^^J#1^^J^^J\par
}%
% edited: removed \long, which was left-over from prior trials
\def\Clean#1\par{#1}
\def\userather#1#2#3{#1}
\def\divide#1#2{#1/\ifnum #2=0
\expandableerrormessage{%
LaTeX3 error: \divide^^Jused with 0 as 2nd argument.^^JI will use 17299.%
}%
\use{17299}\else #2\fi}%
\message{This is the result: \the\numexpr \divide{1000000000}{0}\relax}
\end{document}
The same with
There may be a problem if one wants \par token to appear in the message, but the idea can perhaps be refined. V2: \documentclass{article}
\begin{document}
\long\def\use#1{#1}
\expandafter\def
\csname/^^J%
expansion completed, due to an exception (see the above^^J%
explanation about the specifics). If in interactive^^J%
mode, simply hit RET and LaTeX3 will try to recover.^^J%
Hopefully, the above short explanation\endcsname
#1\boom{}
\def\expandableerrormessage#1{%
\def\expandableerrormessage##1##2{%
\expandafter\expandafter\expandafter
\Clean
\expandafter
#1\ErrorStart{##1}##2^^J^^J\par
}}\expandafter\expandableerrormessage
\csname/^^J%
expansion completed, due to an exception (see the above^^J%
explanation about the specifics). If in interactive^^J%
mode, simply hit RET and LaTeX3 will try to recover.^^J%
Hopefully, the above short explanation\endcsname
\def\Clean#1\par{#1}
\def\ErrorStart#1{! #1 error:^^J}%
\def\userather#1#2#3{#1}
\def\divide#1#2{#1/\ifnum #2=0
\expandableerrormessage
{l3foo}%
{\divide used with 0 as 2nd argument. I will use 17299.}%
\use{17299}\else #2\fi}%
\message{This is the result: \the\numexpr \divide{1000000000}{0}\relax}
\end{document}
Unfortunately with the Starting the error with
|
@jfbu's V2 proposal is really great, so I'll implement that in a few days (I need my full focus not to mess up all of the test file updates). The only drawback is that we have to fill in the dots in one of the sentences (depending on whether we use
|
before you do that @blefloch, can we first check how well that works with editors that evaluate error messages? I also think @jbu's idea is a neat, but my fear is that scanning editors will pick on the wrong part and never present the right information and if that's the case, then it may not be so good. Sorry for the late reply but it got my first shot today and not feeling so well (which is perhaps a good sign as people claim) |
The |
@FrankMittelbach Yes, reaction to jab is good! Can you send some jabs here for us? :-) -- There are almost none available here, not even for big money! |
Re @blefloch 's ... (fill in the dots) question. Several types of possibility:
Or maybe we can magic them away? |
I think something like in @jfbu's code is quite a good idea. Some general help text explaining that this is an expandable error that has limitations by nature. And that the user is expected to just hit
|
somewhat imitating Skillmon's formulation I have the following local version for geeks:
Regarding the actual error I am keeping it on one line
because Emacs/AucTeX then displays in its error buffer
and its "ERROR" line seems to have to be that: one line only (the next one ends up below I don't have to maintain style guidelines in my case. |
Compiling the attached TeX file gives 9 errors, corresponding to different ways of producing an error stating
The first three are non-expandable versions (LaTeX2e, LaTeX3 with no help text, LaTeX3 with help text). The next three are recognized in my emacs/auctex tests as some other error (Extra \or, Undefined control sequence, some issue with picture commands). The last three look good for me, with emacs/auctex recognizing the well-known "missing \item" error and telling me about lists. Could some of compile the attached TeX file in your editor of choice and let me know which of the errors look good (including help text etc)? In emacs, 1-3 are nice, 4-6 are pretty bad, 7-9 are ok.
test-expandable-errors.tex.txt |
I use emacs/auctex as well so can only confirm your findings with it. Here is error overview provided by auctex:
(is there some reason for the two spaces between LaTeX and Error in cases 2 and 3 which use the current non-expandable LaTeX3 I tested also with an old TeXShop (2017 or so): it opens up a window during compilation with console output where one can interact as if on command line, plus a button to jump back to source where error is located. So in this interface the "perhaps a missing \item" does not trigger some information about lists being displayed as error help, one only gets the raw extra help from entering In definition of In final version, will inserting tokens via |
In every expandable error solution VIM-LaTeX (aka latex-suite) will not show the The quickfix-window contents (the lines not started with
|
@jfbu I don't know how useful |
@Skillmon agreed. Only mentioning this because current code allows it and even went to some lengths using safe delimiter to implement it. This being said TeXShop strangely reminds the user of the |
In retrospect I agree supporting @jfbu The double space in Here are some more tests. I'll get back with some more later.
|
I use
I hope this is somewhat useful --- I was getting pinged on chat but I have no time now to look at it more in depth --- just loaded the file and tried compiling. |
@blefloch in case you have a new free cycle to do a little TeX work at some point, could you perhaps implement a new expandable error message that fits into the 2e world? The decision in the team meeting was to use |
Instead of
we should have (using
\cs_neq_eq:cN { ~ ^^I } \or:
or similar)following the formatting of normal errors. In LuaTeX we could then simply use Lua code to raise the error expandably (there should be some code for that in
l3trial/l3kernel-extras/
).The text was updated successfully, but these errors were encountered: