8

The code of the trivial package mypkg.sty below defines key draft. If draft is given as a class option, LaTeX hangs at the command \ProcessKeysOptions. This seems to be a bug. Or is there something wrong with my code?

Package file mypkg.sty:

\RequirePackage{expl3}
\RequirePackage{l3keys2e}
\ProvidesExplPackage{mypkg}{2011/05/06}{0.1}{triv. example pkg.}

\newcommand\isdraft{no}
\keys_define:nn{mypkg}{
  draft .choice:,
  draft / true .code:n = {\renewcommand\isdraft{yes}},
  draft / false .code:n = {\renewcommand\isdraft{no}},
  draft .default:n = {true}
}
\ProcessKeysOptions{mypkg}

Test file:

\documentclass[draft]{article} %LaTeX hangs at \ProcessKeysOptions{...}
\usepackage{mypkg}

\begin{document}
Draft mode: \isdraft.
\end{document}
3
  • This is clearly a bug: I will investigate and look to fix on CTAN a.s.a.p.
    – Joseph Wright
    May 6, 2011 at 14:35
  • @Caramdir: Wouldn't {package-writing} be more appropriate as a tag here?
    – AlexG
    May 9, 2011 at 7:08
  • Of course.
    – Caramdir
    May 9, 2011 at 15:58

1 Answer 1

3

There is a one letter bug in l3keys2e: the function

\cs_new_protected:Npn \keys_latexe_options_package:n #1 {
  \clist_map_inline:Nn \@classoptionslist 
    {
      \cs_if_exist:cTF 
        { 
          \c_keys_root_tl #1 / 
            \keys_latexe_remove_equals:n {##1} .cmd:n
        }
        {
          \clist_put_right:Nn \keys_latexe_options_clist {##1}
          \clist_remove_element:Nn \@unusedoptionlist {##1}
        }
    }
}

should read

\cs_new_protected:Npn \keys_latexe_options_package:n #1 {
  \clist_map_inline:Nn \@classoptionslist 
    {
      \cs_if_exist:cT % CHANGE HERE
        { 
          \c_keys_root_tl #1 / 
            \keys_latexe_remove_equals:n {##1} .cmd:n
        }
        {
          \clist_put_right:Nn \keys_latexe_options_clist {##1}
          \clist_remove_element:Nn \@unusedoptionlist {##1}
        }
    }
}

As a temporary fix, you can \cs_set_protected:Npn the correct definition after loading the package, but if you wait a day or so CTAN will be updated.

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .