My meta-discussion topic is about the question that follows:
The listings manual (v1.5b, subsection 4.18) recommends using \lst@definelanguage instead of
\lstdefinelanguage
in a style file:Where should I put my language definition? If you need the language for one particular document, put it into the preamble of that document. Otherwise create the local file lstlang0.sty or add the definition to that file, but use
\lst@definelanguage
instead of\lstdefinelanguage. [...]
However, I can't find a reason for this distinction between\lst@definelanguage
and\lstdefinelanguage
in either the manual or the developer guide. Is the distinction important?You may be wondering why I'm asking this question... Well, I've managed to get everything working in my style file using
\lstdefinelanguage
. That said, I'd like to follow the guidelines laid out in the listings documentation as closely as possible.However, if I simply substitute
\lst@definelanguage
for\lstdefinelanguage
, I run into problems. Here is an MWE:\documentclass{article} \usepackage{filecontents} % --- generate the style file --- \begin{filecontents*}{mystyle.sty} \NeedsTeXFormat{LaTeX2e} \ProvidesPackage{mystyle} \DeclareOption*{\OptionNotUsed} \ProcessOptions\relax \RequirePackage{listings} \def\mylanguage{Mylanguage} \expandafter\expandafter\expandafter\lstdefinelanguage% \expandafter{\mylanguage}{keywords={foo}} \endinput \end{filecontents*} % --- end of style file --- \usepackage{mystyle} \begin{document} \begin{lstlisting}[language=Mylanguage] foo bar baz \end{lstlisting} \end{document}
Everything is hunky-dory with the code above, but if I simply replace
\lstdefinelanguage
by\lst@definelanguage
, the listings packages throws two errors:Couldn't load requested language.
and
language mylanguage undefined.
This seems to contradict the manual's claim that
\lstdefinelanguage
and\lst@definelanguage
have the same syntax; at least, based on my simple test, they don't seem equivalent when in comes to expansion of their first argument.Should I use
\lst@definelanguage
instead of\lstdefinelanguage
and how can I get the former to work in my MWE?
My answer was to change the value to iftrue
in the corresponding line of \lst@definelanguage
in the file lstmisc.sty
of the listings
package, and the document, therefore, would compile accordingly.
The only useful remark that one of the main commentators managed to say in the end, was in the lines of: I use \lstdefinelanguage
because I don't know the internal commands. endquote. This however, left upon me a disconcerting impression that the commentator was just trying the mend this miserable tore up question. What else?
The other remarks were clearly copied verbatim from the listings
manual. That is, the comments about the local file and the use of \lstdefinelanguage
, with the corresponding language files that follow.
Not surprisingly, the OP was desperately willing to accept this answer.
But this is clearly a vague excuse. A vague excuse that the OP was desperately willing to accept, So desperate in fact, that I am sure he regretted posting the question, he regretted further elaboration of its premises, and generally speaking, asking this kind of question to start with. Then my answer came in, which set off the alarms. Then back to the OP who should have done the homework but he didn't. The commentator, on the other hand, should have provided a better opinion, but he failed. And the bottom line is that this question that I loved so much, me, me, not the OP nor the commentator, is now, sadly, nowwhere to be found. Google cache no longer applies, and the realization that the best answer to fix it, was largely ignored and downvoted, is a fact now.
So, back to the question: Should I use \lst@definelanguage instead of \lstdefinelanguage and how can I get the former to work in my MWE?
- No, you can't use
\lst@definelanguage
, because the manual is incorrect, but you can change it to\iftrue
- Yes, you can use
\lst@definelanguage
because the manual is correct, and you can change it to\iftrue
- It's up to you, you can't use
\lst@definelanguage
because the manual is incorrect, but you can change it to\iftrue
- It's not up to you, you can use
\lst@definelanguage
because the manual is correct, but you can change it to\iftrue
- It's not up to you, you can't use
\lst@definelanguage
because the manual is incorrect, but you can change it to\iftrue
.
What are my options? If I only knew how to count. But most important, give me one reason why this question should be deleted.
\lst@definelanguage
to\iftrue
is false in the filelstmisc.sty
of thelistings
package, that is, in the line\lst@UserCommand\lst@definelanguage{\lst@DefLang\iftrue}
with or without other packages involved, so the document or MWE would compile, then, – doed Mar 9 '14 at 21:46)
in line{\lst@ifbreaklines \lst@Def{
)}{\lst@breakProcessOther)}\fi}` of the filelstmisc.sty
in the packagelistings
holds false as well. Therefore, my answers related to the packagelistings
are invalid, and should be removed, erased, deleted, – doed Mar 9 '14 at 21:47listings
is disallowed to start with. How would a convention hold its truth value if its principle is not satisfied. – doed Mar 9 '14 at 21:47