Re: [PATCH] Hyphenation, the latex way
Andre == Andre Poenitz [EMAIL PROTECTED] writes: Andre On Tue, Dec 07, 2004 at 04:32:59PM +, Angus Leeming wrote: Isn't it possible to define \mesg only when \typeout's argument starts Babel: {\def\typeout#1{if #1 starts with Babel then \global\def\mesg{#1}} \the\everyjob} Andre We could simply collect all typeout arguments and cut out the Andre interesting part later Andre \def\mesg{} {\def\typeout#1{\global\edef\mesg{\mesg #1}} Andre \the\everyjob} This is basically what I do. JMarc
Re: [PATCH] Hyphenation, the latex way
Jean-Marc == Jean-Marc Lasgouttes [EMAIL PROTECTED] writes: Angus == Angus Leeming [EMAIL PROTECTED] writes: Angus Isn't it possible to define \mesg only when \typeout's argument Angus starts Babel: Jean-Marc I thought about that (and I do not know how to do it...), Jean-Marc but a better solution has been proposed on fctt: Jean-Marc concatenate all the \typeout messages into the \mesg macro, Jean-Marc and find the languages in there. This gives the following Jean-Marc updated patch, where I have added some comments to explain Jean-Marc the code. I have committed this code, along with a slight change to LaTeXConfig.lyx.in. JMarc
Re: [PATCH] Hyphenation, the latex way
> "Andre" == Andre Poenitz <[EMAIL PROTECTED]> writes: Andre> On Tue, Dec 07, 2004 at 04:32:59PM +, Angus Leeming wrote: >> Isn't it possible to define \mesg only when \typeout's argument >> starts "Babel": >> >> {\def\typeout#1{if #1 starts with "Babel" then >> \global\def\mesg{#1}} \the\everyjob} Andre> We could simply collect all typeout arguments and cut out the Andre> interesting part later Andre> \def\mesg{} {\def\typeout#1{\global\edef\mesg{\mesg #1}} Andre> \the\everyjob} This is basically what I do. JMarc
Re: [PATCH] Hyphenation, the latex way
> "Jean-Marc" == Jean-Marc Lasgouttes <[EMAIL PROTECTED]> writes: > "Angus" == Angus Leeming <[EMAIL PROTECTED]> writes: Angus> Isn't it possible to define \mesg only when \typeout's argument Angus> starts "Babel": Jean-Marc> I thought about that (and I do not know how to do it...), Jean-Marc> but a better solution has been proposed on fctt: Jean-Marc> concatenate all the \typeout messages into the \mesg macro, Jean-Marc> and find the languages in there. This gives the following Jean-Marc> updated patch, where I have added some comments to explain Jean-Marc> the code. I have committed this code, along with a slight change to LaTeXConfig.lyx.in. JMarc
Re: [PATCH] Hyphenation, the latex way
Jean-Marc Lasgouttes wrote: http://www.tug.org/utilities/plain/cseq.html Thanks, JMarc. Bookmarked for future reference. -- Angus
Re: [PATCH] Hyphenation, the latex way
On Tue, Dec 07, 2004 at 04:32:59PM +, Angus Leeming wrote: Isn't it possible to define \mesg only when \typeout's argument starts Babel: {\def\typeout#1{if #1 starts with Babel then \global\def\mesg{#1}} \the\everyjob} We could simply collect all typeout arguments and cut out the interesting part later \def\mesg{} {\def\typeout#1{\global\edef\mesg{\mesg #1}} \the\everyjob} [edef expands the definition's body before doing an ordinary def[ Andre'
Re: [PATCH] Hyphenation, the latex way
Jean-Marc Lasgouttes wrote: > http://www.tug.org/utilities/plain/cseq.html Thanks, JMarc. Bookmarked for future reference. -- Angus
Re: [PATCH] Hyphenation, the latex way
On Tue, Dec 07, 2004 at 04:32:59PM +, Angus Leeming wrote: > Isn't it possible to define \mesg only when \typeout's argument starts > "Babel": > > {\def\typeout#1{if #1 starts with "Babel" then \global\def\mesg{#1}} > \the\everyjob} We could simply collect all typeout arguments and cut out the interesting part later \def\mesg{} {\def\typeout#1{\global\edef\mesg{\mesg #1}} \the\everyjob} [edef expands the definition's body before doing an ordinary def[ Andre'
Re: [PATCH] Hyphenation, the latex way
Angus == Angus Leeming [EMAIL PROTECTED] writes: Angus Jean-Marc Lasgouttes wrote: Isn't it possible to define \mesg Angus only when \typeout's argument starts Babel: I thought about that (and I do not know how to do it...), but a better solution has been proposed on fctt: concatenate all the \typeout messages into the \mesg macro, and find the languages in there. This gives the following updated patch, where I have added some comments to explain the code. Angus This is indeed better. Incidentally, can you recommend a book Angus to explain TeX syntax. It's all rather baffling at the moment. There is no real syntax, unfortunately. For example, xmltex is a set of macros that allows tex to parse XML files (one can also input HTML4 in latex with th proper package). However, you can have an idea of TeX primitives and plain macros here: http://www.tug.org/utilities/plain/cseq.html JMarc
Re: [PATCH] Hyphenation, the latex way
> "Angus" == Angus Leeming <[EMAIL PROTECTED]> writes: Angus> Jean-Marc Lasgouttes wrote: Isn't it possible to define \mesg Angus> only when \typeout's argument starts "Babel": >> I thought about that (and I do not know how to do it...), but a >> better solution has been proposed on fctt: concatenate all the >> \typeout messages into the \mesg macro, and find the languages in >> there. This gives the following updated patch, where I have added >> some comments to explain the code. Angus> This is indeed better. Incidentally, can you recommend a book Angus> to explain TeX syntax. It's all rather baffling at the moment. There is no real syntax, unfortunately. For example, xmltex is a set of macros that allows tex to parse XML files (one can also input HTML4 in latex with th proper package). However, you can have an idea of TeX primitives and plain macros here: http://www.tug.org/utilities/plain/cseq.html JMarc
Re: [PATCH] Hyphenation, the latex way
Angus == Angus Leeming [EMAIL PROTECTED] writes: Angus Isn't it possible to define \mesg only when \typeout's argument Angus starts Babel: I thought about that (and I do not know how to do it...), but a better solution has been proposed on fctt: concatenate all the \typeout messages into the \mesg macro, and find the languages in there. This gives the following updated patch, where I have added some comments to explain the code. JMarc Index: lib/ChangeLog === RCS file: /usr/local/lyx/cvsroot/lyx-devel/lib/ChangeLog,v retrieving revision 1.654 diff -u -p -r1.654 ChangeLog --- lib/ChangeLog 7 Dec 2004 09:38:57 - 1.654 +++ lib/ChangeLog 8 Dec 2004 15:51:58 - @@ -1,6 +1,12 @@ +2004-12-08 Jean-Marc Lasgouttes [EMAIL PROTECTED] + + * configure.m4: remove code from last entry... + + * chkconfig.ltx: ... and replace it with a TeX solution + 2004-12-07 Martin Vermeer [EMAIL PROTECTED] - * configure.m4: add printout of language list for which + * configure.m4: add printout of language list for which hyphenation is enabled 2004-11-19 Jürgen Spitzmüller [EMAIL PROTECTED] Index: lib/chkconfig.ltx === RCS file: /usr/local/lyx/cvsroot/lyx-devel/lib/chkconfig.ltx,v retrieving revision 1.14 diff -u -p -r1.14 chkconfig.ltx --- lib/chkconfig.ltx 14 Sep 2004 10:20:37 - 1.14 +++ lib/chkconfig.ltx 8 Dec 2004 15:51:58 - @@ -152,6 +152,25 @@ \message{^^J\prefix checking for LaTeX version... \fmtversion} \AddVariable{fmtversion}{\fmtversion} +%%% And now, the list of available languages +% The trick is to know that \the\everyjob contains something like +% \typeout{LaTeX2e 2001/06/01} +% \typeout{Babel v3.7h and hyphenation patterns for american, french, german, ngerman, nohyphenation, loaded.} +% All we have to do is to extract the list from there: +% (1) concatenate all the messages that are displayed everytime the +% format is loaded. The is done by redefining locally \typeout to +% append its argument to the macro \mesg. +\def\mesg{} +{\def\typeout#1{\xdef\mesg{\mesg #1}} + \the\everyjob} +% (2) strip the useless parts from \mesg. This uses the fact that TeX +% allows to define macros with parameters delimited by arbitrary text. +\def\strip#1patterns for #2, loaded.#3\endmark{\def\langs{#2}} +\expandafter\strip\mesg\endmark +% (3) handle the result +\message{^^J\prefix checking for available hyphenation patterns... \langs} +\AddVariable{languages}{\langs} + %%% Check for ec fonts. Most of this code has been shamelessely stolen %%% from the file ltxcheck.tex in the LaTeX distribution. In particular, %%% don't ask me how the macro \ecrm works... Index: lib/configure.m4 === RCS file: /usr/local/lyx/cvsroot/lyx-devel/lib/configure.m4,v retrieving revision 1.86 diff -u -p -r1.86 configure.m4 --- lib/configure.m4 7 Dec 2004 09:38:57 - 1.86 +++ lib/configure.m4 8 Dec 2004 15:51:58 - @@ -219,19 +219,6 @@ else LATEX= ac_result=not useable fi -# Grab the list of languages avaliable to LaTeX by parsing the LaTeX log file, chklatex.log. -LANGUAGES=`sed -n '/hyphenation patterns/{ -:loop -/loaded\.$/!{ -$!{ -N -s/\n// -s/^.*for\ // -tloop -} -} -/loaded\.$/p -}' chklatex.log` rm -f chklatex.ltx chklatex.log])dnl dnl # Search LaTeX2e @@ -536,11 +523,6 @@ changequote(,)dnl echo creating doc/LaTeXConfig.lyx echo s/@chk_linuxdoc@/$chk_linuxdoc/g chkconfig.sed echo s/@chk_docbook@/$chk_docbook/g chkconfig.sed -# Add a line to chkconfig.sed so that the placeholder in -# LaTeXConfig.lyx.in will be replaced by the list of available -# languages. -test ${LANGUAGES} != \ -echo s/@chk_languages@/${LANGUAGES}/g chkconfig.sed sed -f chkconfig.sed ${srcdir}/doc/LaTeXConfig.lyx.in doc/LaTeXConfig.lyx echo creating $outfile
Re: [PATCH] Hyphenation, the latex way
Jean-Marc Lasgouttes wrote: Angus Isn't it possible to define \mesg only when \typeout's argument Angus starts Babel: I thought about that (and I do not know how to do it...), but a better solution has been proposed on fctt: concatenate all the \typeout messages into the \mesg macro, and find the languages in there. This gives the following updated patch, where I have added some comments to explain the code. This is indeed better. Incidentally, can you recommend a book to explain TeX syntax. It's all rather baffling at the moment. -- Angus
Re: [PATCH] Hyphenation, the latex way
Angus Leeming [EMAIL PROTECTED] writes: This is indeed better. Incidentally, can you recommend a book to explain TeX syntax. It's all rather baffling at the moment. If you *really* want to know the TeX syntax + semantics + dangerous bends + dirty tricks + funny pictures: The TeX book by Donald Knuth. Just be warned: TeX as a programming language is much worse than X* , especially since there's no separation between syntax and semantics. If you extrapolate from Forth and RTL you get the picture. /Andreas * Fill in name of your least favorite language.
Re: [PATCH] Hyphenation, the latex way
> "Angus" == Angus Leeming <[EMAIL PROTECTED]> writes: Angus> Isn't it possible to define \mesg only when \typeout's argument Angus> starts "Babel": I thought about that (and I do not know how to do it...), but a better solution has been proposed on fctt: concatenate all the \typeout messages into the \mesg macro, and find the languages in there. This gives the following updated patch, where I have added some comments to explain the code. JMarc Index: lib/ChangeLog === RCS file: /usr/local/lyx/cvsroot/lyx-devel/lib/ChangeLog,v retrieving revision 1.654 diff -u -p -r1.654 ChangeLog --- lib/ChangeLog 7 Dec 2004 09:38:57 - 1.654 +++ lib/ChangeLog 8 Dec 2004 15:51:58 - @@ -1,6 +1,12 @@ +2004-12-08 Jean-Marc Lasgouttes <[EMAIL PROTECTED]> + + * configure.m4: remove code from last entry... + + * chkconfig.ltx: ... and replace it with a TeX solution + 2004-12-07 Martin Vermeer <[EMAIL PROTECTED]> - * configure.m4: add printout of language list for which + * configure.m4: add printout of language list for which hyphenation is enabled 2004-11-19 Jürgen Spitzmüller <[EMAIL PROTECTED]> Index: lib/chkconfig.ltx === RCS file: /usr/local/lyx/cvsroot/lyx-devel/lib/chkconfig.ltx,v retrieving revision 1.14 diff -u -p -r1.14 chkconfig.ltx --- lib/chkconfig.ltx 14 Sep 2004 10:20:37 - 1.14 +++ lib/chkconfig.ltx 8 Dec 2004 15:51:58 - @@ -152,6 +152,25 @@ \message{^^J\prefix checking for LaTeX version... \fmtversion} \AddVariable{fmtversion}{\fmtversion} +%%% And now, the list of available languages +% The trick is to know that \the\everyjob contains something like +% \typeout{LaTeX2e <2001/06/01>} +% \typeout{Babel and hyphenation patterns for american, french, german, ngerman, nohyphenation, loaded.} +% All we have to do is to extract the list from there: +% (1) concatenate all the messages that are displayed everytime the +% format is loaded. The is done by redefining locally \typeout to +% append its argument to the macro \mesg. +\def\mesg{} +{\def\typeout#1{\xdef\mesg{\mesg #1}} + \the\everyjob} +% (2) strip the useless parts from \mesg. This uses the fact that TeX +% allows to define macros with parameters delimited by arbitrary text. +\def\strip#1patterns for #2, loaded.#3\endmark{\def\langs{#2}} +\expandafter\strip\mesg\endmark +% (3) handle the result +\message{^^J\prefix checking for available hyphenation patterns... \langs} +\AddVariable{languages}{\langs} + %%% Check for ec fonts. Most of this code has been shamelessely stolen %%% from the file ltxcheck.tex in the LaTeX distribution. In particular, %%% don't ask me how the macro \ecrm works... Index: lib/configure.m4 === RCS file: /usr/local/lyx/cvsroot/lyx-devel/lib/configure.m4,v retrieving revision 1.86 diff -u -p -r1.86 configure.m4 --- lib/configure.m4 7 Dec 2004 09:38:57 - 1.86 +++ lib/configure.m4 8 Dec 2004 15:51:58 - @@ -219,19 +219,6 @@ else LATEX= ac_result="not useable" fi -# Grab the list of languages avaliable to LaTeX by parsing the LaTeX log file, chklatex.log. -LANGUAGES=`sed -n '/hyphenation patterns/{ -:loop -/loaded\.$/!{ -$!{ -N -s/\n// -s/^.*for\ // -tloop -} -} -/loaded\.$/p -}' chklatex.log` rm -f chklatex.ltx chklatex.log])dnl dnl # Search LaTeX2e @@ -536,11 +523,6 @@ changequote(,)dnl echo "creating doc/LaTeXConfig.lyx" echo "s/@chk_linuxdoc@/$chk_linuxdoc/g" >> chkconfig.sed echo "s/@chk_docbook@/$chk_docbook/g" >> chkconfig.sed -# Add a line to chkconfig.sed so that the placeholder in -# LaTeXConfig.lyx.in will be replaced by the list of available -# languages. -test "${LANGUAGES}" != "" && \ -echo "s/@chk_languages@/${LANGUAGES}/g" >> chkconfig.sed sed -f chkconfig.sed "${srcdir}"/doc/LaTeXConfig.lyx.in >doc/LaTeXConfig.lyx echo "creating $outfile"
Re: [PATCH] Hyphenation, the latex way
Jean-Marc Lasgouttes wrote: > Angus> Isn't it possible to define \mesg only when \typeout's argument > Angus> starts "Babel": > > I thought about that (and I do not know how to do it...), but a better > solution has been proposed on fctt: concatenate all the \typeout > messages into the \mesg macro, and find the languages in there. This > gives the following updated patch, where I have added some comments to > explain the code. This is indeed better. Incidentally, can you recommend a book to explain TeX syntax. It's all rather baffling at the moment. -- Angus
Re: [PATCH] Hyphenation, the latex way
Angus Leeming <[EMAIL PROTECTED]> writes: > > This is indeed better. Incidentally, can you recommend a book to explain > TeX syntax. It's all rather baffling at the moment. > If you *really* want to know the TeX syntax + semantics + dangerous bends + dirty tricks + funny pictures: "The TeX book" by Donald Knuth. Just be warned: TeX as a programming language is much worse than X* , especially since there's no separation between syntax and semantics. If you extrapolate from Forth and RTL you get the picture. /Andreas * Fill in name of your least favorite language.
[PATCH] Hyphenation, the latex way
The following patch implements the lookup of languages in chkconfig.ltx. It appears that this information is available in \everyjob, and the superior pattern matching abilities of TeX do the rest ;) Pros: - the code is shorter - it has one less bug, since the sed code gives me american, french, german, ngerman, nohyphenation, loaded. whereas the TeX version yields american, french, german, ngerman, nohyphenation - I understand it :) Cons: - it relies on the fact that the babel message is the last \typeout in \everyjob. I have to check whether this is really true. JMarc Index: ChangeLog === RCS file: /usr/local/lyx/cvsroot/lyx-devel/lib/ChangeLog,v retrieving revision 1.654 diff -u -p -r1.654 ChangeLog --- ChangeLog 7 Dec 2004 09:38:57 - 1.654 +++ ChangeLog 7 Dec 2004 13:52:58 - @@ -1,6 +1,12 @@ +2004-12-07 Jean-Marc Lasgouttes [EMAIL PROTECTED] + + * configure.m4: remove code from last entry... + + * chkconfig.ltx: ... and replace it with a TeX solution + 2004-12-07 Martin Vermeer [EMAIL PROTECTED] - * configure.m4: add printout of language list for which + * configure.m4: add printout of language list for which hyphenation is enabled 2004-11-19 Jürgen Spitzmüller [EMAIL PROTECTED] Index: chkconfig.ltx === RCS file: /usr/local/lyx/cvsroot/lyx-devel/lib/chkconfig.ltx,v retrieving revision 1.14 diff -u -p -r1.14 chkconfig.ltx --- chkconfig.ltx 14 Sep 2004 10:20:37 - 1.14 +++ chkconfig.ltx 7 Dec 2004 13:52:58 - @@ -152,6 +152,17 @@ \message{^^J\prefix checking for LaTeX version... \fmtversion} \AddVariable{fmtversion}{\fmtversion} +%%% And now, the list of available languages +% first get the message that is displayed everytime the format is loaded +{\def\typeout#1{\global\def\mesg{#1}} + \the\everyjob} +% then strip some useless parts +\def\strip#1patterns for #2, loaded.{\def\langs{#2}} +\expandafter\strip\mesg +% handle the result +\message{^^J\prefix checking for available hyphenation patterns... \langs} +\AddVariable{languages}{\langs} + %%% Check for ec fonts. Most of this code has been shamelessely stolen %%% from the file ltxcheck.tex in the LaTeX distribution. In particular, %%% don't ask me how the macro \ecrm works... Index: configure.m4 === RCS file: /usr/local/lyx/cvsroot/lyx-devel/lib/configure.m4,v retrieving revision 1.86 diff -u -p -r1.86 configure.m4 --- configure.m4 7 Dec 2004 09:38:57 - 1.86 +++ configure.m4 7 Dec 2004 13:52:58 - @@ -219,19 +219,6 @@ else LATEX= ac_result=not useable fi -# Grab the list of languages avaliable to LaTeX by parsing the LaTeX log file, chklatex.log. -LANGUAGES=`sed -n '/hyphenation patterns/{ -:loop -/loaded\.$/!{ -$!{ -N -s/\n// -s/^.*for\ // -tloop -} -} -/loaded\.$/p -}' chklatex.log` rm -f chklatex.ltx chklatex.log])dnl dnl # Search LaTeX2e @@ -536,11 +523,6 @@ changequote(,)dnl echo creating doc/LaTeXConfig.lyx echo s/@chk_linuxdoc@/$chk_linuxdoc/g chkconfig.sed echo s/@chk_docbook@/$chk_docbook/g chkconfig.sed -# Add a line to chkconfig.sed so that the placeholder in -# LaTeXConfig.lyx.in will be replaced by the list of available -# languages. -test ${LANGUAGES} != \ -echo s/@chk_languages@/${LANGUAGES}/g chkconfig.sed sed -f chkconfig.sed ${srcdir}/doc/LaTeXConfig.lyx.in doc/LaTeXConfig.lyx echo creating $outfile
Re: [PATCH] Hyphenation, the latex way
Jean-Marc Lasgouttes wrote: The following patch implements the lookup of languages in chkconfig.ltx. It appears that this information is available in \everyjob, and the superior pattern matching abilities of TeX do the rest ;) Pros: - the code is shorter - it has one less bug, since the sed code gives me american, french, german, ngerman, nohyphenation, loaded. whereas the TeX version yields american, french, german, ngerman, nohyphenation - I understand it :) Which is the real plus in its favour, no :) Cons: - it relies on the fact that the babel message is the last \typeout in \everyjob. I have to check whether this is really true. Can you explain it to someone who doesn't read LaTeX (me)? +{\def\typeout#1{\global\def\mesg{#1}} + \the\everyjob} +\def\strip#1patterns for #2, loaded.{\def\langs{#2}} +\expandafter\strip\mesg +\message{^^J\prefix checking for available hyphenation patterns... \langs} +\AddVariable{languages}{\langs} -- Angus
Re: [PATCH] Hyphenation, the latex way
Angus == Angus Leeming [EMAIL PROTECTED] writes: - I understand it :) Angus Which is the real plus in its favour, no :) How did you guess? Cons: - it relies on the fact that the babel message is the last \typeout in \everyjob. I have to check whether this is really true. Angus Can you explain it to someone who doesn't read LaTeX (me)? OK, what you have to know is that \the\everyjob contains something like \typeout{LaTeX2e 2001/06/01} \typeout{Babel v3.7h and hyphenation patterns for american, french, german, ngerman, nohyphenation, loaded.} This is the command which is executed when the format is loaded (displays info on screen). Angus +{\def\typeout#1{\global\def\mesg{#1}} Angus + \the\everyjob} Here, we replace locally \typeout by a macro that defines \mesg as its argument. We use \global\def so that the definition of \mesg survives the {} group. Note that we are only interested by the second typeout (this is the assumption I am the less comfortable with, actually). Angus +\def\strip#1patterns for #2, loaded.{\def\langs{#2}} When you define a macro like \def\foo#1bar#2baz{...} and invoke it like \foo abcbardefbaz, then you get #1=abc and #2=def The net effect of \strip is to extract the list of languages from the babel message. The #1 argument is just ignored. Angus +\expandafter\strip\mesg I want the \strip macro to see the _contents_ of \mesg, so I use \expandafter that first expands \mesg and then invokes \strip as if it was followed by the expansion of \mesg (kind of like what backquoting does in unix shell). Angus +\message{^^J\prefix checking for available hyphenation patterns... \langs} Kind of obvious Angus +\AddVariable{languages}{\langs} This creates the sed pattern. Clear? JMarc
Re: [PATCH] Hyphenation, the latex way
Jean-Marc Lasgouttes wrote: Angus Can you explain it to someone who doesn't read LaTeX (me)? OK, what you have to know is that \the\everyjob contains something like \typeout{LaTeX2e 2001/06/01} \typeout{Babel v3.7h and hyphenation patterns for american, french, german, ngerman, nohyphenation, loaded.} This is the command which is executed when the format is loaded (displays info on screen). Angus +{\def\typeout#1{\global\def\mesg{#1}} Angus + \the\everyjob} Here, we replace locally \typeout by a macro that defines \mesg as its argument. We use \global\def so that the definition of \mesg survives the {} group. Note that we are only interested by the second typeout (this is the assumption I am the less comfortable with, actually). So, {\def\typeout#1#2{\global\def\mesg{#1}}\the\everyjob} would mean you were interested in the third typeout? Angus +\def\strip#1patterns for #2, loaded.{\def\langs{#2}} When you define a macro like \def\foo#1bar#2baz{...} and invoke it like \foo abcbardefbaz, then you get #1=abc and #2=def The net effect of \strip is to extract the list of languages from the babel message. The #1 argument is just ignored. Ok, understood. Angus +\expandafter\strip\mesg I want the \strip macro to see the _contents_ of \mesg, so I use \expandafter that first expands \mesg and then invokes \strip as if it was followed by the expansion of \mesg (kind of like what backquoting does in unix shell). Again, understood. Angus +\message{^^J\prefix checking for available hyphenation patterns... \langs} Kind of obvious Angus +\AddVariable{languages}{\langs} This creates the sed pattern. Clear? I'm reminded of how I used to feel when my father explained my maths homework to me. I sort of see how it works, but if you were to ask me to do it myself, you'd find me creeping back into the room to grab the scrumpled up notes from the waste paper basket... -- Angus
Re: [PATCH] Hyphenation, the latex way
Angus == Angus Leeming [EMAIL PROTECTED] writes: Angus So, {\def\typeout#1#2{\global\def\mesg{#1}}\the\everyjob} would Angus mean you were interested in the third typeout? No, there are two \typeout, each with one argument. \merg is defined twice, and the last definition is the one that remains. Angus I'm reminded of how I used to feel when my father explained my Angus maths homework to me. I sort of see how it works, but if you Angus were to ask me to do it myself, you'd find me creeping back Angus into the room to grab the scrumpled up notes from the waste Angus paper basket... It is like when you try to make me understand sed loops... JMarc
Re: [PATCH] Hyphenation, the latex way
Jean-Marc Lasgouttes wrote: Angus == Angus Leeming [EMAIL PROTECTED] writes: Angus So, {\def\typeout#1#2{\global\def\mesg{#1}}\the\everyjob} would Angus mean you were interested in the third typeout? No, there are two \typeout, each with one argument. \merg is defined twice, and the last definition is the one that remains. Thank you. Now I understand. Angus I'm reminded of how I used to feel when my father explained my Angus maths homework to me. I sort of see how it works, but if you Angus were to ask me to do it myself, you'd find me creeping back Angus into the room to grab the scrumpled up notes from the waste Angus paper basket... It is like when you try to make me understand sed loops... Sure. I'm perfectly aware of that. $ grep -r '\typeout' \usr\share\texmf | grep -v 'Binary file' | \ cut -d':' -f1 | sort -u | wc -l 288 So 288 files in my texmf tree output '\typeout'. What makes you think that only Babel does? -- Angus
Re: [PATCH] Hyphenation, the latex way
Angus == Angus Leeming [EMAIL PROTECTED] writes: Angus $ grep -r '\typeout' \usr\share\texmf | grep -v 'Binary file' | Angus \ cut -d':' -f1 | sort -u | wc -l 288 Angus So 288 files in my texmf tree output '\typeout'. What makes you Angus think that only Babel does? Well, typeout is used all over the place indeed. What is more interesting is \everyjob: fantomas: grep -rl everyjob /usr/local/tetex/share/texmf/tex/|wc -l 41 Inspection of these things show only a few possible problems, that are IMO: /usr/local/tetex/share/texmf/tex/latex/base/latex.ltx /usr/local/tetex/share/texmf/tex/latex/mltex/mlltxchg.def /usr/local/tetex/share/texmf/tex/latex/hyperref/hylatex.ltx /usr/local/tetex/share/texmf/tex/cslatex/cslatex.ini /usr/local/tetex/share/texmf/tex/csplain/skhyphen.tex /usr/local/tetex/share/texmf/tex/csplain/csplain.ini /usr/local/tetex/share/texmf/tex/csplain/cseplain.ini /usr/local/tetex/share/texmf/tex/csplain/czhyphen.tex /usr/local/tetex/share/texmf/tex/fontinst/base/fontinst.ini /usr/local/tetex/share/texmf/tex/enctex/enc-k.tex /usr/local/tetex/share/texmf/tex/enctex/enc-p.tex /usr/local/tetex/share/texmf/tex/enctex/enc-w.tex /usr/local/tetex/share/texmf/tex/generic/xypic/xy.tex /usr/local/tetex/share/texmf/tex/generic/hyphen/czhyph.tex /usr/local/tetex/share/texmf/tex/generic/hyphen/skhyph.tex /usr/local/tetex/share/texmf/tex/generic/hyphen/skhyph2e.tex /usr/local/tetex/share/texmf/tex/platex/config/hyphen.cfg JMarc
Re: [PATCH] Hyphenation, the latex way
Jean-Marc Lasgouttes wrote: Angus $ grep -r '\typeout' \usr\share\texmf | grep -v 'Binary file' | Angus \ cut -d':' -f1 | sort -u | wc -l 288 Angus So 288 files in my texmf tree output '\typeout'. What makes you Angus think that only Babel does? Well, typeout is used all over the place indeed. What is more interesting is \everyjob: fantomas: grep -rl everyjob /usr/local/tetex/share/texmf/tex/|wc -l 41 Inspection of these things show only a few possible problems, that are IMO: In an earlier explanation, you wrote: OK, what you have to know is that \the\everyjob contains something like \typeout{LaTeX2e 2001/06/01} \typeout{Babel v3.7h and hyphenation patterns for american, french, german, ngerman, nohyphenation, loaded.} Isn't it possible to define \mesg only when \typeout's argument starts Babel: {\def\typeout#1{if #1 starts with Babel then \global\def\mesg{#1}} \the\everyjob} ? -- Angus
[PATCH] Hyphenation, the latex way
The following patch implements the lookup of languages in chkconfig.ltx. It appears that this information is available in \everyjob, and the superior pattern matching abilities of TeX do the rest ;) Pros: - the code is shorter - it has one less bug, since the sed code gives me american, french, german, ngerman, nohyphenation, loaded. whereas the TeX version yields american, french, german, ngerman, nohyphenation - I understand it :) Cons: - it relies on the fact that the babel message is the last \typeout in \everyjob. I have to check whether this is really true. JMarc Index: ChangeLog === RCS file: /usr/local/lyx/cvsroot/lyx-devel/lib/ChangeLog,v retrieving revision 1.654 diff -u -p -r1.654 ChangeLog --- ChangeLog 7 Dec 2004 09:38:57 - 1.654 +++ ChangeLog 7 Dec 2004 13:52:58 - @@ -1,6 +1,12 @@ +2004-12-07 Jean-Marc Lasgouttes <[EMAIL PROTECTED]> + + * configure.m4: remove code from last entry... + + * chkconfig.ltx: ... and replace it with a TeX solution + 2004-12-07 Martin Vermeer <[EMAIL PROTECTED]> - * configure.m4: add printout of language list for which + * configure.m4: add printout of language list for which hyphenation is enabled 2004-11-19 Jürgen Spitzmüller <[EMAIL PROTECTED]> Index: chkconfig.ltx === RCS file: /usr/local/lyx/cvsroot/lyx-devel/lib/chkconfig.ltx,v retrieving revision 1.14 diff -u -p -r1.14 chkconfig.ltx --- chkconfig.ltx 14 Sep 2004 10:20:37 - 1.14 +++ chkconfig.ltx 7 Dec 2004 13:52:58 - @@ -152,6 +152,17 @@ \message{^^J\prefix checking for LaTeX version... \fmtversion} \AddVariable{fmtversion}{\fmtversion} +%%% And now, the list of available languages +% first get the message that is displayed everytime the format is loaded +{\def\typeout#1{\global\def\mesg{#1}} + \the\everyjob} +% then strip some useless parts +\def\strip#1patterns for #2, loaded.{\def\langs{#2}} +\expandafter\strip\mesg +% handle the result +\message{^^J\prefix checking for available hyphenation patterns... \langs} +\AddVariable{languages}{\langs} + %%% Check for ec fonts. Most of this code has been shamelessely stolen %%% from the file ltxcheck.tex in the LaTeX distribution. In particular, %%% don't ask me how the macro \ecrm works... Index: configure.m4 === RCS file: /usr/local/lyx/cvsroot/lyx-devel/lib/configure.m4,v retrieving revision 1.86 diff -u -p -r1.86 configure.m4 --- configure.m4 7 Dec 2004 09:38:57 - 1.86 +++ configure.m4 7 Dec 2004 13:52:58 - @@ -219,19 +219,6 @@ else LATEX= ac_result="not useable" fi -# Grab the list of languages avaliable to LaTeX by parsing the LaTeX log file, chklatex.log. -LANGUAGES=`sed -n '/hyphenation patterns/{ -:loop -/loaded\.$/!{ -$!{ -N -s/\n// -s/^.*for\ // -tloop -} -} -/loaded\.$/p -}' chklatex.log` rm -f chklatex.ltx chklatex.log])dnl dnl # Search LaTeX2e @@ -536,11 +523,6 @@ changequote(,)dnl echo "creating doc/LaTeXConfig.lyx" echo "s/@chk_linuxdoc@/$chk_linuxdoc/g" >> chkconfig.sed echo "s/@chk_docbook@/$chk_docbook/g" >> chkconfig.sed -# Add a line to chkconfig.sed so that the placeholder in -# LaTeXConfig.lyx.in will be replaced by the list of available -# languages. -test "${LANGUAGES}" != "" && \ -echo "s/@chk_languages@/${LANGUAGES}/g" >> chkconfig.sed sed -f chkconfig.sed "${srcdir}"/doc/LaTeXConfig.lyx.in >doc/LaTeXConfig.lyx echo "creating $outfile"
Re: [PATCH] Hyphenation, the latex way
Jean-Marc Lasgouttes wrote: > The following patch implements the lookup of languages in > chkconfig.ltx. It appears that this information is available in > \everyjob, and the superior pattern matching abilities of TeX do the > rest ;) > > Pros: > > - the code is shorter > > - it has one less bug, since the sed code gives me > american, french, german, ngerman, nohyphenation, loaded. > whereas the TeX version yields > american, french, german, ngerman, nohyphenation > > - I understand it :) Which is the real plus in its favour, no :) > Cons: > > - it relies on the fact that the babel message is the last \typeout in > \everyjob. I have to check whether this is really true. Can you explain it to someone who doesn't read LaTeX (me)? +{\def\typeout#1{\global\def\mesg{#1}} + \the\everyjob} +\def\strip#1patterns for #2, loaded.{\def\langs{#2}} +\expandafter\strip\mesg +\message{^^J\prefix checking for available hyphenation patterns... \langs} +\AddVariable{languages}{\langs} -- Angus
Re: [PATCH] Hyphenation, the latex way
> "Angus" == Angus Leeming <[EMAIL PROTECTED]> writes: >> - I understand it :) Angus> Which is the real plus in its favour, no :) How did you guess? >> Cons: >> >> - it relies on the fact that the babel message is the last \typeout >> in \everyjob. I have to check whether this is really true. Angus> Can you explain it to someone who doesn't read LaTeX (me)? OK, what you have to know is that \the\everyjob contains something like \typeout{LaTeX2e <2001/06/01>} \typeout{Babel and hyphenation patterns for american, french, german, ngerman, nohyphenation, loaded.} This is the command which is executed when the format is loaded (displays info on screen). Angus> +{\def\typeout#1{\global\def\mesg{#1}} Angus> + \the\everyjob} Here, we replace locally \typeout by a macro that defines \mesg as its argument. We use \global\def so that the definition of \mesg survives the {} group. Note that we are only interested by the second typeout (this is the assumption I am the less comfortable with, actually). Angus> +\def\strip#1patterns for #2, loaded.{\def\langs{#2}} When you define a macro like \def\foo#1bar#2baz{...} and invoke it like \foo abcbardefbaz, then you get #1=abc and #2=def The net effect of \strip is to extract the list of languages from the babel message. The #1 argument is just ignored. Angus> +\expandafter\strip\mesg I want the \strip macro to see the _contents_ of \mesg, so I use \expandafter that first expands \mesg and then invokes \strip as if it was followed by the expansion of \mesg (kind of like what backquoting does in unix shell). Angus> +\message{^^J\prefix checking for available hyphenation patterns... \langs} Kind of obvious Angus> +\AddVariable{languages}{\langs} This creates the sed pattern. Clear? JMarc
Re: [PATCH] Hyphenation, the latex way
Jean-Marc Lasgouttes wrote: > Angus> Can you explain it to someone who doesn't read LaTeX (me)? > > OK, what you have to know is that \the\everyjob contains something > like > \typeout{LaTeX2e <2001/06/01>} > \typeout{Babel and hyphenation patterns for american, french, > german, ngerman, nohyphenation, loaded.} > > This is the command which is executed when the format is loaded > (displays info on screen). > > Angus> +{\def\typeout#1{\global\def\mesg{#1}} > Angus> + \the\everyjob} > > Here, we replace locally \typeout by a macro that defines \mesg as its > argument. We use \global\def so that the definition of \mesg survives > the {} group. Note that we are only interested by the second typeout > (this is the assumption I am the less comfortable with, actually). So, {\def\typeout#1#2{\global\def\mesg{#1}}\the\everyjob} would mean you were interested in the third typeout? > Angus> +\def\strip#1patterns for #2, loaded.{\def\langs{#2}} > > When you define a macro like \def\foo#1bar#2baz{...} and invoke it > like > \foo abcbardefbaz, then you get #1=abc and #2=def > > The net effect of \strip is to extract the list of languages from the > babel message. The #1 argument is just ignored. Ok, understood. > Angus> +\expandafter\strip\mesg > > I want the \strip macro to see the _contents_ of \mesg, so I use > \expandafter that first expands \mesg and then invokes \strip as if it > was followed by the expansion of \mesg (kind of like what backquoting > does in unix shell). Again, understood. > Angus> +\message{^^J\prefix checking for available hyphenation > patterns... \langs} > > Kind of obvious > > Angus> +\AddVariable{languages}{\langs} > > This creates the sed pattern. > > Clear? I'm reminded of how I used to feel when my father explained my maths homework to me. I sort of see how it works, but if you were to ask me to do it myself, you'd find me creeping back into the room to grab the scrumpled up notes from the waste paper basket... -- Angus
Re: [PATCH] Hyphenation, the latex way
> "Angus" == Angus Leeming <[EMAIL PROTECTED]> writes: Angus> So, {\def\typeout#1#2{\global\def\mesg{#1}}\the\everyjob} would Angus> mean you were interested in the third typeout? No, there are two \typeout, each with one argument. \merg is defined twice, and the last definition is the one that remains. Angus> I'm reminded of how I used to feel when my father explained my Angus> maths homework to me. I sort of see how it works, but if you Angus> were to ask me to do it myself, you'd find me creeping back Angus> into the room to grab the scrumpled up notes from the waste Angus> paper basket... It is like when you try to make me understand sed loops... JMarc
Re: [PATCH] Hyphenation, the latex way
Jean-Marc Lasgouttes wrote: >> "Angus" == Angus Leeming <[EMAIL PROTECTED]> >> writes: > > Angus> So, {\def\typeout#1#2{\global\def\mesg{#1}}\the\everyjob} would > Angus> mean you were interested in the third typeout? > > No, there are two \typeout, each with one argument. \merg is defined > twice, and the last definition is the one that remains. Thank you. Now I understand. > Angus> I'm reminded of how I used to feel when my father explained my > Angus> maths homework to me. I sort of see how it works, but if you > Angus> were to ask me to do it myself, you'd find me creeping back > Angus> into the room to grab the scrumpled up notes from the waste > Angus> paper basket... > > It is like when you try to make me understand sed loops... Sure. I'm perfectly aware of that. $ grep -r '\typeout' \usr\share\texmf | grep -v 'Binary file' | \ cut -d':' -f1 | sort -u | wc -l 288 So 288 files in my texmf tree output '\typeout'. What makes you think that only Babel does? -- Angus
Re: [PATCH] Hyphenation, the latex way
> "Angus" == Angus Leeming <[EMAIL PROTECTED]> writes: Angus> $ grep -r '\typeout' \usr\share\texmf | grep -v 'Binary file' | Angus> \ cut -d':' -f1 | sort -u | wc -l 288 Angus> So 288 files in my texmf tree output '\typeout'. What makes you Angus> think that only Babel does? Well, typeout is used all over the place indeed. What is more interesting is \everyjob: fantomas: grep -rl everyjob /usr/local/tetex/share/texmf/tex/|wc -l 41 Inspection of these things show only a few possible problems, that are IMO: /usr/local/tetex/share/texmf/tex/latex/base/latex.ltx /usr/local/tetex/share/texmf/tex/latex/mltex/mlltxchg.def /usr/local/tetex/share/texmf/tex/latex/hyperref/hylatex.ltx /usr/local/tetex/share/texmf/tex/cslatex/cslatex.ini /usr/local/tetex/share/texmf/tex/csplain/skhyphen.tex /usr/local/tetex/share/texmf/tex/csplain/csplain.ini /usr/local/tetex/share/texmf/tex/csplain/cseplain.ini /usr/local/tetex/share/texmf/tex/csplain/czhyphen.tex /usr/local/tetex/share/texmf/tex/fontinst/base/fontinst.ini /usr/local/tetex/share/texmf/tex/enctex/enc-k.tex /usr/local/tetex/share/texmf/tex/enctex/enc-p.tex /usr/local/tetex/share/texmf/tex/enctex/enc-w.tex /usr/local/tetex/share/texmf/tex/generic/xypic/xy.tex /usr/local/tetex/share/texmf/tex/generic/hyphen/czhyph.tex /usr/local/tetex/share/texmf/tex/generic/hyphen/skhyph.tex /usr/local/tetex/share/texmf/tex/generic/hyphen/skhyph2e.tex /usr/local/tetex/share/texmf/tex/platex/config/hyphen.cfg JMarc
Re: [PATCH] Hyphenation, the latex way
Jean-Marc Lasgouttes wrote: > Angus> $ grep -r '\typeout' \usr\share\texmf | grep -v 'Binary file' | > Angus> \ cut -d':' -f1 | sort -u | wc -l 288 > > Angus> So 288 files in my texmf tree output '\typeout'. What makes you > Angus> think that only Babel does? > > Well, typeout is used all over the place indeed. What is more > interesting is \everyjob: > > fantomas: grep -rl everyjob /usr/local/tetex/share/texmf/tex/|wc -l > 41 > > Inspection of these things show only a few possible problems, that are > IMO: In an earlier explanation, you wrote: > OK, what you have to know is that \the\everyjob contains something > like > \typeout{LaTeX2e <2001/06/01>} > \typeout{Babel and hyphenation patterns for american, french, > german, ngerman, nohyphenation, loaded.} Isn't it possible to define \mesg only when \typeout's argument starts "Babel": {\def\typeout#1{if #1 starts with "Babel" then \global\def\mesg{#1}} \the\everyjob} ? -- Angus