Take the 2-minute tour ×
TeX - LaTeX Stack Exchange is a question and answer site for users of TeX, LaTeX, ConTeXt, and related typesetting systems. It's 100% free, no registration required.

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}
share|improve this question
    
This is clearly a bug: I will investigate and look to fix on CTAN a.s.a.p. –  Joseph Wright May 6 '11 at 14:35
    
Thanks, @Joseph! –  AlexG May 6 '11 at 14:39
    
@Caramdir: Wouldn't {package-writing} be more appropriate as a tag here? –  AlexG May 9 '11 at 7:08
    
Of course. –  Caramdir May 9 '11 at 15:58
add comment

1 Answer

up vote 3 down vote accepted

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.

share|improve this answer
add comment

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.