From 429023b977a74e57f5588c35fba36efdc76672fc Mon Sep 17 00:00:00 2001
From: Robert Alessi <alessi@robertalessi.net>
Date: Fri, 28 Jul 2023 21:05:53 +0200
Subject: nolem: removed unwanted space

---
 ekdosis.dtx | 202 ++++++++++++++++++++++++++++++------------------------------
 1 file changed, 102 insertions(+), 100 deletions(-)

(limited to 'ekdosis.dtx')

diff --git a/ekdosis.dtx b/ekdosis.dtx
index 936d9a4..af71c7d 100644
--- a/ekdosis.dtx
+++ b/ekdosis.dtx
@@ -9715,8 +9715,7 @@ Sample text with a \textcolor{red}{word} in red.
 % line label\---which are manually inserted---and returns the formatted
 % reference to be inserted in the apparatus criticus.
 %    \begin{macrocode}
-\def\current@ref@arg#1#2{
-  \bgroup %\textdir TLT%
+\def\current@ref@arg#1#2{{%\textdir TLT%
   \unexpanded\expandafter{\ekd@refnumstyle}%
   \ifnum
     \pdf@strcmp{\getpagerefnumber{#1}}{\getpagerefnumber{#2}}
@@ -9786,31 +9785,79 @@ Sample text with a \textcolor{red}{word} in red.
     \LRnum{\getrefnumber{#1}}%
     \unexpanded\expandafter{\ekd@postrefnum}% force the no
   \fi
-  \egroup
-}
+}}
 %    \end{macrocode}
 % \cs{current@ref} is pretty much the same as \cs{current@reg@arg},
 % but takes no argument. It is used by commands such as \cs{lem} when
 % references to page and line numbers can be returned by \textsf{Lua}.
 %    \begin{macrocode}
-\def\current@ref{%
-  \bgroup %\textdir TLT%
-  \unexpanded\expandafter{\ekd@refnumstyle}%
-  \ifnum % if the whole lemma falls on the same page...
-    \pdf@strcmp{%
-      \getpagerefnumber{\luadirect{tex.sprint(ekdosis.getlnlab())}-b}}%
-    {\getpagerefnumber{\luadirect{tex.sprint(ekdosis.getlnlab())}-e}}
-    =
-    0
-    \ifnum % ... and on the same line
+\def\current@ref{{%\textdir TLT%
+    \unexpanded\expandafter{\ekd@refnumstyle}%
+    \ifnum % if the whole lemma falls on the same page...
       \pdf@strcmp{%
-        \getrefnumber{\luadirect{tex.sprint(ekdosis.getlnlab())}-b}}%
-      {\getrefnumber{\luadirect{tex.sprint(ekdosis.getlnlab())}-e}}
+        \getpagerefnumber{\luadirect{tex.sprint(ekdosis.getlnlab())}-b}}%
+      {\getpagerefnumber{\luadirect{tex.sprint(ekdosis.getlnlab())}-e}}
       =
       0
-      % 
-      \ifekd@mapps % then, if multiple layers have been defined...
-        \ifbool{subsq@unit@\ekdan@type}{%
+      \ifnum % ... and on the same line
+        \pdf@strcmp{%
+          \getrefnumber{\luadirect{tex.sprint(ekdosis.getlnlab())}-b}}%
+        {\getrefnumber{\luadirect{tex.sprint(ekdosis.getlnlab())}-e}}
+        =
+        0
+        % 
+        \ifekd@mapps % then, if multiple layers have been defined:
+          \ifbool{subsq@unit@\ekdan@type}{% given a subsequent entry ...
+              \ifnum %  ... when it begins on the same line as the
+                % previous one ...
+                \pdf@strcmp{\getrefnumber{\luadirect{tex.sprint(
+                      ekdosis.getlnlab())}-b}}%
+                {\getrefnumber{\luadirect{tex.sprint(
+                      ekdosis.getprevlnlab())}-b}}
+                =
+                0
+                %%% begin
+                \ifnum % ... and ends likewise, then do nothing,
+                  \pdf@strcmp{\getrefnumber{\luadirect{tex.sprint(
+                        ekdosis.getlnlab())}-e}}%
+                  {\getrefnumber{\luadirect{tex.sprint(
+                        ekdosis.getprevlnlab())}-e}}
+                  =
+                  0
+                  \ifekd@appinapp % (this is for nested \app entries.)
+                    \ifnum
+                      \pdf@strcmp{\getrefnumber{\luadirect{tex.sprint(
+                            ekdosis.getlnlab())}-b}}%
+                      {\getrefnumber{\luadirect{tex.sprint(
+                            ekdosis.getprevprevlnlab())}-b}}
+                      =
+                      0
+                    \else
+                      \LRnum{\getrefnumber{\luadirect{tex.sprint(
+                            ekdosis.getlnlab())}-b}}%
+                      \unexpanded\expandafter{\ekd@postrefnum}% issue
+                      % the no
+                    \fi
+                  \fi
+                \else % otherwise, print the line number:
+                  \LRnum{\getrefnumber{\luadirect{tex.sprint(
+                        ekdosis.getlnlab())}-b}}%
+                  \unexpanded\expandafter{\ekd@postrefnum}% issue the no
+                \fi
+                %%% end
+              \else % if the entry begins on a new line, print the
+                % number:
+                \LRnum{\getrefnumber{\luadirect{tex.sprint(
+                      ekdosis.getlnlab())}-b}}%
+                \unexpanded\expandafter{\ekd@postrefnum}% issue the no
+              \fi
+            }% and always print the line number ahead of first entries:
+            {\LRnum{\getrefnumber{\luadirect{tex.sprint(
+                    ekdosis.getlnlab())}-b}}%
+              \unexpanded\expandafter{\ekd@postrefnum}}% issue the no
+        \else % now if there is only one default layer
+          \ifsubsq@unit
+            % 
             \ifnum
               \pdf@strcmp{\getrefnumber{\luadirect{tex.sprint(
                     ekdosis.getlnlab())}-b}}%
@@ -9851,97 +9898,51 @@ Sample text with a \textcolor{red}{word} in red.
                     ekdosis.getlnlab())}-b}}%
               \unexpanded\expandafter{\ekd@postrefnum}% issue the no
             \fi
-          }{\LRnum{\getrefnumber{\luadirect{tex.sprint(
-                  ekdosis.getlnlab())}-b}}%
-            \unexpanded\expandafter{\ekd@postrefnum}}% issue the no
-      \else
-        \ifsubsq@unit
-          % 
-          \ifnum
-            \pdf@strcmp{\getrefnumber{\luadirect{tex.sprint(
-                  ekdosis.getlnlab())}-b}}%
-            {\getrefnumber{\luadirect{tex.sprint(
-                  ekdosis.getprevlnlab())}-b}}
-            =
-            0
-            %%% begin
-            \ifnum
-              \pdf@strcmp{\getrefnumber{\luadirect{tex.sprint(
-                    ekdosis.getlnlab())}-e}}%
-              {\getrefnumber{\luadirect{tex.sprint(
-                    ekdosis.getprevlnlab())}-e}}
-              =
-              0
-              \ifekd@appinapp
-                \ifnum
-                  \pdf@strcmp{\getrefnumber{\luadirect{tex.sprint(
-                        ekdosis.getlnlab())}-b}}%
-                  {\getrefnumber{\luadirect{tex.sprint(
-                        ekdosis.getprevprevlnlab())}-b}}
-                  =
-                  0
-                \else
-                  \LRnum{\getrefnumber{\luadirect{tex.sprint(
-                        ekdosis.getlnlab())}-b}}%
-                  \unexpanded\expandafter{\ekd@postrefnum}% issue the no
-                \fi
-              \fi
-            \else
-              \LRnum{\getrefnumber{\luadirect{tex.sprint(
-                    ekdosis.getlnlab())}-b}}%
-              \unexpanded\expandafter{\ekd@postrefnum}% issue the no
-            \fi
-            %%% end
+            % 
           \else
             \LRnum{\getrefnumber{\luadirect{tex.sprint(
                   ekdosis.getlnlab())}-b}}%
             \unexpanded\expandafter{\ekd@postrefnum}% issue the no
           \fi
-          % 
+        \fi
+        % 
+      \else
+        \ifekd@elidednumbers
+          \luadirect{tex.sprint(ekdosis.numrange(
+            \luastring{\getrefnumber{\luadirect{tex.sprint(
+                  ekdosis.getlnlab())}-b}},
+            \luastring{\getrefnumber{\luadirect{tex.sprint(
+                  ekdosis.getlnlab())}-e}}))}%
+          \unexpanded\expandafter{\ekd@postrefnum}% issue the nos
         \else
           \LRnum{\getrefnumber{\luadirect{tex.sprint(
-                ekdosis.getlnlab())}-b}}%
-          \unexpanded\expandafter{\ekd@postrefnum}% issue the no
+                ekdosis.getlnlab())}-b}}--%
+          \LRnum{\getrefnumber{\luadirect{tex.sprint(
+                ekdosis.getlnlab())}-e}}%
+          \unexpanded\expandafter{\ekd@postrefnum}% issue the nos
         \fi
       \fi
-      % 
-    \else
-      \ifekd@elidednumbers
-        \luadirect{tex.sprint(ekdosis.numrange(
-          \luastring{\getrefnumber{\luadirect{tex.sprint(
-                ekdosis.getlnlab())}-b}},
-          \luastring{\getrefnumber{\luadirect{tex.sprint(
-                ekdosis.getlnlab())}-e}}))}%
-        \unexpanded\expandafter{\ekd@postrefnum}% issue the nos
-      \else
-        \LRnum{\getrefnumber{\luadirect{tex.sprint(
-              ekdosis.getlnlab())}-b}}--%
-        \LRnum{\getrefnumber{\luadirect{tex.sprint(
-              ekdosis.getlnlab())}-e}}%
-        \unexpanded\expandafter{\ekd@postrefnum}% issue the nos
-      \fi
+    \else % now if the lemma breaks across pages
+      \ifboolexpr{bool {ekd@pagelineation} or bool {ekd@pagevlineation}}
+          {\LRnum{\getrefnumber{\luadirect{tex.sprint(
+                  ekdosis.getlnlab())}-b}}--%
+            \LRnum{\getpagerefnumber{\luadirect{tex.sprint(
+                  ekdosis.getlnlab())}-e}}.%
+            \LRnum{\getrefnumber{\luadirect{tex.sprint(
+                  ekdosis.getlnlab())}-e}}%
+            \unexpanded\expandafter{\ekd@postrefnum}}% issue pg and ln nos
+          {\LRnum{\getrefnumber{\luadirect{tex.sprint(
+                  ekdosis.getlnlab())}-b}}--%
+            \LRnum{\getrefnumber{\luadirect{tex.sprint(
+                  ekdosis.getlnlab())}-e}}%
+            \unexpanded\expandafter{\ekd@postrefnum}}% issue the nos
     \fi
-  \else
-    \ifboolexpr{bool {ekd@pagelineation} or bool {ekd@pagevlineation}}
-      {\LRnum{\getrefnumber{\luadirect{tex.sprint(
-              ekdosis.getlnlab())}-b}}--%
-        \LRnum{\getpagerefnumber{\luadirect{tex.sprint(
-              ekdosis.getlnlab())}-e}}.%
-        \LRnum{\getrefnumber{\luadirect{tex.sprint(
-              ekdosis.getlnlab())}-e}}%
-        \unexpanded\expandafter{\ekd@postrefnum}}% issue pg and ln nos
-      {\LRnum{\getrefnumber{\luadirect{tex.sprint(
-              ekdosis.getlnlab())}-b}}--%
-        \LRnum{\getrefnumber{\luadirect{tex.sprint(
-              ekdosis.getlnlab())}-e}}%
-        \unexpanded\expandafter{\ekd@postrefnum}}% issue the nos
-  \fi
-  \ifekdl@forcenum
-    \LRnum{\getrefnumber{\luadirect{tex.sprint(
-          ekdosis.getlnlab())}-b}}%
-    \unexpanded\expandafter{\ekd@postrefnum}% force the no
-  \fi
-  \egroup
+    \ifekdl@forcenum
+      \LRnum{\getrefnumber{\luadirect{tex.sprint(
+            ekdosis.getlnlab())}-b}}%
+      \unexpanded\expandafter{\ekd@postrefnum}% force the no
+    \fi
+  }%
 }
 %    \end{macrocode}
 % Define keys to be used by the optional arguments of \cs{lem} and
@@ -10086,6 +10087,7 @@ Sample text with a \textcolor{red}{word} in red.
         \fi
       \fi%
       \unless\ifekdl@nonum\current@ref\fi
+      \relax
     }%\hskip .25em}%
   \else%
   \ifbool{al@rlmode}{%
-- 
cgit v1.2.3

