diff options
author | Karl Berry <karl@freefriends.org> | 2022-03-11 22:04:51 +0000 |
---|---|---|
committer | Karl Berry <karl@freefriends.org> | 2022-03-11 22:04:51 +0000 |
commit | 41bf581d1e01e395d0eaeb2fc50b36d0cd3c92bc (patch) | |
tree | b9f337374b98fdf7d3e27331951e6b3429998bb6 /Master/texmf-dist/tex/optex/base/ref-file.opm | |
parent | 594f56d8c6dd122d6841c134070753e69276d5cf (diff) |
optex (11mar22) (branch)
git-svn-id: svn://tug.org/texlive/branches/branch2021.final@62641 c570f23f-e606-0410-a88d-b1316a301751
Diffstat (limited to 'Master/texmf-dist/tex/optex/base/ref-file.opm')
-rw-r--r-- | Master/texmf-dist/tex/optex/base/ref-file.opm | 23 |
1 files changed, 17 insertions, 6 deletions
diff --git a/Master/texmf-dist/tex/optex/base/ref-file.opm b/Master/texmf-dist/tex/optex/base/ref-file.opm index 95e960bc12a..7f9c619009e 100644 --- a/Master/texmf-dist/tex/optex/base/ref-file.opm +++ b/Master/texmf-dist/tex/optex/base/ref-file.opm @@ -59,6 +59,7 @@ \_gdef\_wref ##1##2{\_write\_reffile{\_bslash\_csstring##1##2}}% \_immediate\_write\_reffile {\_pcent\_pcent\_space OpTeX <\_optexversion> - REF file}% \_immediate\_wref \Xrefversion{{\_REFversion}}% + \_ifx\_refdecldata\_empty \_else \_refdeclwrite \_fi \_gdef\_openref{}% } \_def\_ewref #1#2{\_edef\_ewrefA{#2}\_ea\_wref\_ea#1\_ea{\_ewrefA}} @@ -88,7 +89,7 @@ You cannot define your own `.ref` macros before `.ref` file is read because it is read in `\everyjob`. But you can define such macros by using \`\refdecl``{<definitions of your ref macros>}`. - This command immediately writes `<definitions of your ref macros>` to the + This command writes `<definitions of your ref macros>` to the `.ref` file. Then the next lines written to the `.ref` file can include your macros. An example from CTUstyle2: @@ -100,13 +101,23 @@ } \endtt We must read `<definitions of your ref macros>` while `#` has the catcode 12, - because we don't want to duplicate each `#` in the `.ref` file. + because we don't want to duplicate each `#` in the `.ref` file.\nl + `\refdecl` appends its data to the \`\_refdecldata` macro. It is + pushed to the `.ref` file immediatelly only if the file is opened + already. Otherwise we are waiting to `\openref` because we don't want + to open the `.ref` file if it is unnecessary. \_cod \_fin ----------------- -\_def\_refdecl{\_bgroup \_catcode`\#=12 \_refdeclA} -\_def\_refdeclA #1{\egroup\_openref - \_immediate\_write\_reffile {\_pcent\_space \_string \refdecl:}% - \_immediate\_write\_reffile {\_detokenize{#1}}% +\_def\_refdecldata{} +\_def\_refdecl{\_bgroup \_catcode`\#=12 \_catcode`\\=12 \_catcode`\ =12 \_refdeclA} +\_def\_refdeclA#1{\_egroup + \_ifx\_refdecldata\_empty\_else \_global\_addto\_refdecldata{^^J}\_fi + \_global\_addto\_refdecldata{#1}% + \_ifx\_openref\_empty \_refdeclwrite \_fi +} +\_def\_refdeclwrite{% + \_immediate\_write\_reffile{\_pcent\_space \_string\refdecl:^^J\_detokenize\_ea{\_refdecldata}}% + \_gdef\_refdecldata{}% } \_public \refdecl ; |