From 350aaae632c485af3b136301b0763ce61c5c8b66 Mon Sep 17 00:00:00 2001
From: Robert Alessi <alessi@robertalessi.net>
Date: Sun, 24 Nov 2019 21:22:20 +0100
Subject: new command \arind{} specialized in the construction of indexes

---
 arabluatex.dtx | 52 ++++++++++++++++++++++++++++++++++++++++++++++++++++
 1 file changed, 52 insertions(+)

(limited to 'arabluatex.dtx')

diff --git a/arabluatex.dtx b/arabluatex.dtx
index 423583f..efc5d70 100644
--- a/arabluatex.dtx
+++ b/arabluatex.dtx
@@ -4847,6 +4847,58 @@
 %    \end{macrocode}
 % \end{macro}
 % \end{environment}
+% \begin{macro}{\arind}
+% \changes{v1.18}{2019/11/24}{New command \cs{arind} for building
+% indexes}
+% \cs{arind}\marg{root} is a command specialized in the contruction of
+% indexes. As a mandadory argument, it takes the Arabic root under
+% which a given word is to be indexed. Additionally, it may receive
+% three optional \enquote*{named} arguments: |index|, |root| and
+% |form|.
+%    \begin{macrocode}
+\NewDocumentCommand{\SetDefaultIndex}{m}{
+  \edef\@tempa{#1}
+  \ifx\@tempa\empty
+    \def\al@default@index{\jobname}
+  \else
+    \def\al@default@index{#1}
+  \fi
+}
+%    \end{macrocode}
+%    \begin{macrocode}
+\def\al@index@mode{\al@mode}
+\NewDocumentCommand{\SetIndexMode}{m}{
+  \def\al@index@mode{#1}
+}
+%    \end{macrocode}
+%    \begin{macrocode}
+\define@cmdkeys[al]{index}[alind@]{index,root,form}
+\NewDocumentCommand{\arind}{o m}{%
+  \IfNoValueTF{#1}{%
+    \ifdefined\al@default@index%
+      \csname index\endcsname[\al@default@index]{#2}%
+    \else%
+      \csname index\endcsname{#2}%
+    \fi%
+  }{%
+    \bgroup
+    \setkeys[al]{index}{#1}%
+    \def\al@one{%
+      \ifdefined\alind@root!\LR{\alind@root}\else!\LR{1}\fi}%
+    \def\al@two{%
+      \ifdefined\alind@form @\arb[\al@index@mode]{\alind@form}\else\fi}%
+    \ifdefined\alind@index%
+      \csname index\endcsname[\alind@index]{#2\al@one\al@two}%
+    \else%
+      \ifdefined\al@default@index%
+        \csname index\endcsname[\al@default@index]{#2\al@one\al@two}%
+      \else%
+        \csname index\endcsname{#2\al@one\al@two}%
+      \fi%
+    \fi%
+    \egroup}}
+%    \end{macrocode}
+% \end{macro}
 % \begin{macro}{\abjad} \cs{abjad}\marg{number} expresses its argument
 %   in Arabic letters in accordance with the \arb[trans]{'abjad}
 %   arrangement of the alphabet. \meta{number} must be between 1 and
-- 
cgit v1.2.3

