OSDN Git Service

added lltjp-atbegshi.sty
authorHironori Kitagawa <h_kitagawa2001@yahoo.co.jp>
Mon, 27 Jul 2020 06:26:04 +0000 (15:26 +0900)
committerHironori Kitagawa <h_kitagawa2001@yahoo.co.jp>
Mon, 27 Jul 2020 06:26:04 +0000 (15:26 +0900)
src/ltj-base.sty
src/luatexja-core.sty
src/patches/lltjp-atbegshi.sty [new file with mode: 0644]

index 717105e..605797f 100644 (file)
@@ -13,7 +13,7 @@
 
 \ifltj@in@latex                 %<*LaTeX>
   \NeedsTeXFormat{LaTeX2e}
-  \ProvidesPackage{ltj-base}[2017/05/05]
+  \ProvidesPackage{ltj-base}[2020-07-27]
 \fi                             %</LaTeX>
 
 %%------------------ Tiny helpers
 %! つまり単なる \luatexescape.
 \let\ltj@luaxescape\luatexluaescapestring
 
-%%------------------ Fully-expandable error messaging
-
-%! ixerrtrick パッケージから移植.
-%! 展開限定文脈でも使える \PackageError 等.
-%! Lua 関数版(luatexja/base.lua 参照)もある.
-
-%% \ltj@@error@message@a
-\begingroup
-\def~{ }
-\xdef\ltj@@error@message@a{%
-  Type~~H <return>~~for immediate help%
-}%
-\endgroup
-
-%%<+> \ltj@MessageBreak
-% An analogue of \MessageBreak that is used in \ltj@GenericError, etc.
-% (\MessageBreak cannot be used there.)
-% NB: It is realized as a macro that expands to two instances
-% of the character of code 127. This marker is later detected
-% by the Lua process.
-\begingroup
-\lccode42=127
-\lowercase{
-  \gdef\ltj@MessageBreak{**}
-  \directlua{
-    luatexja.base._error_set_break("**")
-  }
-}
-\endgroup
-
-%%<+> \ltj@GenericError{<cont>}{<msg-main>}{<msg-ref>}{<msg-help>}
-% A variant of \GenericError that can be used in expansion-only
-% situation. The meanings of arguments are the same as the original
-% \GenericError.
-%%<+> \ltj@PlainError{<msg-main>}{<msg-help>}
-% A simpler error messenger available in expansion-only situations.
-% It behaves similarly to:
-%   \errhelp{<msg-help}\errmessage{<msg-main>}
-\begingroup
-% with the same hack as in \GenericError...
-\lccode`\@=`\ %
-\lccode`\~=`\ %
-\lccode`\}=`\ %
-\lccode`\{=`\ %
-\catcode`\ =11\relax%
-\lowercase{%
-\endgroup%
-\def\ltj@GenericError#1#2#3#4{% not protected
-\directlua{%
-luatexja.base._error_set_message("\ltj@luaxescape{#1}",%
-"\ltj@luaxescape{#2.^^J^^J#3^^J\ltj@@error@message@a}",%
-"\ltj@luaxescape{#4}")%
-}%
-\    % use csname with four spaces as last expander
-}
-\def\    {% csname with four spaces
-\directlua{%
-luatexja.base._error_show(false)% and many spaces trail!
-                                        %
-                                        %
-}%
-}%
-\def\ltj@PlainError#1#2{%
-\directlua{%
-luatexja.base._error_set_message("  ",%
-"\ltj@luaxescape{#1}",%
-"\ltj@luaxescape{#2}")%
-}%
-\error  % again a weird name is used
-}
-\def\error  {% csname with two trailing spaces
-\directlua{%
-luatexja.base._error_show(true)% and many spaces trail!
-                                        %
-                                        %
-}%
-}%
-}
-
-%% \ltj@@error@on@line
-\def\ltj@@error@on@line{
-  on input line \the \inputlineno
-}
-
-%% \ltj@generic@warn@info
-\def\ltj@@generic@warn@info#1#2#3#4{
-  \begingroup
-    \directlua{
-      luatexja.base._generic_warn_info("\ltj@luaxescape{#3}",
-        "\ltj@luaxescape{#4}", (#1 > 0), (#2 > 0))
-    }
-  \endgroup
-}
-
-%% \ltj@GenericWarning{<cont>}{<msg-main>}
-\def\ltj@GenericWarning{
-  \ltj@@generic@warn@info{1}{1}
-}
-%% \ltj@GenericWarningNoLine{<cont>}{<msg-main>}
-\def\ltj@GenericWarningNoLine{
-  \ltj@@generic@warn@info{1}{0}
-}
-%% \ltj@GenericInfo{<cont>}{<msg-main>}
-\def\ltj@GenericInfo{
-  \ltj@@generic@warn@info{0}{1}
-}
-%% \ltj@GenericInfoNoLine{<cont>}{<msg-main>}
-\def\ltj@GenericInfoNoLine{
-  \ltj@@generic@warn@info{0}{0}
-}
-
-%% \ltj@@space@seq@a
-\begingroup
-\def~{ }
-\xdef\ltj@@space@seq@a{~~~~~~~~~~~~~~~~}
-\xdef\ltj@@space@seq@b{~~~~~~~~~~~~~}
-\endgroup
-
-%% \ltj@PackageError{<pkg-name>}{<msg-main>}{<msg-help>}
-\def\ltj@PackageError#1#2#3{%
-  \ltj@GenericError{(#1)\ltj@@space@seq@a}%
-   {Package #1 Error: #2}%
-   {See the #1 package documentation for explanation.}%
-   {#3}%
-}
-%% \ltj@PackageWarning{<pkg-name>}{<msg-main>}
-\def\ltj@PackageWarning#1#2{%
-  \ltj@GenericWarning{(#1)\ltj@@space@seq@a}%
-   {Package #1 Warning: #2}%
-}
-%% \ltj@PackageWarningNoLine{<pkg-name>}{<msg-main>}
-\def\ltj@PackageWarningNoLine#1#2{%
-  \ltj@GenericWarningNoLine{(#1)\ltj@@space@seq@a}%
-   {Package #1 Warning: #2}%
-}
-%% \ltj@PackageInfo{<pkg-name>}{<msg-main>}
-\def\ltj@PackageInfo#1#2{%
-  \ltj@GenericInfo{(#1)\ltj@@space@seq@b}%
-   {Package #1 Info: #2}%
-}
-%% \ltj@PackageInfoNoLine{<pkg-name>}{<msg-main>}
-\def\ltj@PackageInfoNoLine#1#2{%
-  \ltj@GenericInfoNoLine{(#1)\ltj@@space@seq@b}%
-   {Package #1 Info: #2}%
-}
 
 %%------------------ debug logging
 \ifdefined\LuaTeXjaDebugEnabled
index c8e5449..4acc74c 100644 (file)
@@ -65,7 +65,7 @@
   \expandafter\let\csname ifltj@in@latex\expandafter\endcsname
     \csname iftrue\endcsname
   \NeedsTeXFormat{LaTeX2e}
-  \ProvidesPackage{luatexja-core}[2017/11/12 Core of LuaTeX-ja]
+  \ProvidesPackage{luatexja-core}[2020-07-27 Core of LuaTeX-ja]
 \fi                             %</LaTeX>
 
 %% Load prerequisite packages.
@@ -78,8 +78,8 @@
   \RequirePackage{ltxcmds}    [2011/11/09] % v1.22
   \RequirePackage{pdftexcmds} [2011/11/29] % v0.20
   \RequirePackage{xkeyval}    [2012/10/14] % v2.6b
-  \RequirePackage{atbegshi}
   \RequirePackage{etoolbox}
+  \RequirePackage{lltjp-atbegshi}
   \AtBeginShipoutInit
   \IfFileExists{everyhook.sty}{\RequirePackage{everyhook}\ltj@everyhook@availtrue}{}
 \else                           %<*!LaTeX>
@@ -88,7 +88,7 @@
   \input ltxcmds.sty
   \input pdftexcmds.sty
   \input xkeyval
-  \input atbegshi.sty
+  \input lltjp-atbegshi.sty
   \AtBeginShipoutInit
 \fi                             %</LaTeX>
 \endlinechar=-1 %
     \directlua{luatexja.jfmglue.diffmet_rule = math.two_paverage}\or
     \directlua{luatexja.jfmglue.diffmet_rule = math.two_add}
   \fi
-}{\ltj@PackageError{luatexja}{invalid argument `#1' for `differentjfm'}{%
+}{\@PackageError{luatexja}{invalid argument `#1' for `differentjfm'}{%
   Argument for `differentjfm' must be one of `large', `small', `average',^^J%
   `pleft', `pright', 'paverage' or `both'. }}
   % large, small, average, pleft, pright, paverage, both
diff --git a/src/patches/lltjp-atbegshi.sty b/src/patches/lltjp-atbegshi.sty
new file mode 100644 (file)
index 0000000..e9b56ac
--- /dev/null
@@ -0,0 +1,80 @@
+%
+% lltjp-atbegshi.sty
+%
+
+\ifdefined\NeedsTeXFormat
+  \NeedsTeXFormat{LaTeX2e}
+  \ProvidesPackage{lltjp-atbegshi}[2020-07-27 Patch to atbegshi for LuaTeX-ja]
+  \RequirePackage{atbegshi}
+\else
+  \input atbegshi.sty
+\fi
+
+%--------------------------------------
+% following codes are almost copied from
+%   pxatbegshi.sty 2019/09/07 v0.5 (in platex-tools bundle, by H. Yamashita).
+
+%% internal macros are locally effective
+\begingroup
+
+%--------------------------------------- helpers
+
+%% unique tokens
+\def\pxabgs@mark{\pxabgs@mark@}
+\def\pxabgs@fin{\pxabgs@fin@}
+
+%% \pxabgs@patch@cmd\CMD{<orig>}{<new>}
+\@onlypreamble\pxabgs@patch@cmd
+\def\pxabgs@patch@cmd#1#2#3{%
+  \ifx#1\relax\else
+  \def\pxabgs@next##1#2##2\pxabgs@mark##3\pxabgs@fin{%
+    \ifx\pxabgs@mark##3\pxabgs@mark
+      \let#1\relax
+    \else
+      \def\pxabgs@fragment{##2}%
+      \def#1{##1#3##2}%
+    \fi}%
+  \expandafter\pxabgs@next#1\pxabgs@mark#2\pxabgs@mark\pxabgs@fin
+  \fi
+}
+
+%---------------------------------------
+
+% concept: execute all hooks inside yoko direction \vbox
+
+% prepare
+\let\pxabgs@AtBegShi@Output\AtBegShi@Output
+% try first patch
+\pxabgs@patch@cmd\pxabgs@AtBegShi@Output
+  {\let\AtBegShi@OrgProtect\protect}%
+  {\setbox8\vbox\bgroup\yoko\let\AtBegShi@OrgProtect\protect}
+\pxabgs@patch@cmd\pxabgs@AtBegShi@Output
+    {\AtBeginShipoutOriginalShipout\box\AtBeginShipoutBox}%
+    {\AtBeginShipoutOriginalShipout\box\AtBeginShipoutBox\egroup}
+\pxabgs@patch@cmd\pxabgs@AtBegShi@Output
+  {%
+    \begingroup
+      \setbox\AtBeginShipoutBox\box\AtBeginShipoutBox
+    \endgroup
+    \let\protect\AtBegShi@OrgProtect
+  }{%
+    \begingroup
+      \setbox\AtBeginShipoutBox\box\AtBeginShipoutBox
+    \endgroup
+    \let\protect\AtBegShi@OrgProtect
+    \egroup
+  }
+% commit the change only when successful
+\ifx\pxabgs@AtBegShi@Output\relax
+  \@PackageWarningNoLine{lltjp-atbegshi}{%
+    Failed in patching \string\AtBegShi@Output.\MessageBreak
+    This may cause error in tate direction%
+  }
+\else
+  \global\let\AtBegShi@Output\pxabgs@AtBegShi@Output
+\fi
+
+\endgroup
+%% internal macros are no longer effective
+
+\endinput