% Maintained by Matthew Bertucci, 2024-present
% Please report all issues and feature requests at https://github.com/mbertucci47/keytheorems
% This work is licensed under the LPPL version 1.3c or later: https://www.latex-project.org/lppl.txt
\ProvidesExplFile{keythms-memoir-support}{2024-09-22}{0.1.4}
  {keytheorems~support~for~the~memoir~class}

\bool_new:N \l__keythms_support_titlecode_bool

\keys_define:nn { keytheorems/listof }
  {
    indent     .initial:n = 0pt,
    title-code .code:n    =
      {
        \bool_set_true:N \l__keythms_support_titlecode_bool
        \cs_set:Npn \__keythms_listof_titlecmd:n ##1 { #1 }
      },
  }

% use memoir's list function; not using \newlistentry, though
\newlistof{ keythms_support_memoir_listof:w }{ thlist }
  { \l__keythms_listof_title_tl }

\RenewDocumentCommand \listofkeytheorems { O{} }
  {
    \bool_gset_true:N \g__keythms_listof_writefile_bool
    \group_begin:
    \keys_set:nn { keytheorems/listof } { #1 }
    \bool_if:NT \l__keythms_listof_nochapskip_bool
      {
        \cs_set_eq:NN \KeyThmsAddvspace \use_none:n
      }
    \bool_if:NTF \l__keythms_listof_notitle_bool
      {
        \cs_set:Npn \@thlistmaketitle {}
        \keythms_support_memoir_listof:w*
      }
      {
        \bool_if:NT \l__keythms_support_titlecode_bool
          {
            \cs_set:Npn \@thlistmaketitle
              { \__keythms_listof_titlecmd:n { \l__keythms_listof_title_tl } }
          }
        \bool_if:NTF \l__keythms_listof_notoc_bool
          { \keythms_support_memoir_listof:w* }
          { \keythms_support_memoir_listof:w }
      }
    \group_end:
  }