diff options
author | Karl Berry <karl@freefriends.org> | 2014-06-17 22:32:09 +0000 |
---|---|---|
committer | Karl Berry <karl@freefriends.org> | 2014-06-17 22:32:09 +0000 |
commit | 3c2f50b92407533aabaef1823006032eedd6ef90 (patch) | |
tree | eb67245dd952c951b95c485a5eb66f9539ac83df /Master/texmf-dist/source/latex/l3kernel/l3keys.dtx | |
parent | 4aa0b8110f2fdb3044d8b26d54e12cbb49a9a3dc (diff) |
l3
git-svn-id: svn://tug.org/texlive/trunk@34268 c570f23f-e606-0410-a88d-b1316a301751
Diffstat (limited to 'Master/texmf-dist/source/latex/l3kernel/l3keys.dtx')
-rw-r--r-- | Master/texmf-dist/source/latex/l3kernel/l3keys.dtx | 125 |
1 files changed, 70 insertions, 55 deletions
diff --git a/Master/texmf-dist/source/latex/l3kernel/l3keys.dtx b/Master/texmf-dist/source/latex/l3kernel/l3keys.dtx index 4aa9f0d1692..b13c1a32ff0 100644 --- a/Master/texmf-dist/source/latex/l3kernel/l3keys.dtx +++ b/Master/texmf-dist/source/latex/l3kernel/l3keys.dtx @@ -37,7 +37,7 @@ \documentclass[full]{l3doc} %</driver> %<*driver|package> -\GetIdInfo$Id: l3keys.dtx 4753 2014-05-08 20:12:49Z joseph $ +\GetIdInfo$Id: l3keys.dtx 5093 2014-06-08 20:33:14Z joseph $ {L3 Key-value interfaces} %</driver|package> %<*driver> @@ -1312,32 +1312,76 @@ % \end{macrocode} % \end{macro} % -% \begin{macro}[int]{\@@_choice_make:} +% \begin{macro}[int]{\@@_choice_make:, \@@_multichoice_make:} +% \begin{macro}[int]{\@@_choice_make:N} +% \begin{macro}[aux]{\@@_choice_make_aux:N} +% \begin{macro}[aux]{\@@_parent:n, \@@_parent:o} +% \begin{macro}[aux]{\@@_parent:wn} % To make a choice from a key, two steps: set the code, and set the -% unknown key. +% unknown key. There is one point to watch here: choice keys cannot be +% nested! As multichoices and choices are essentially the same bar one +% function, the code is given together. % \begin{macrocode} \cs_new_protected_nopar:Npn \@@_choice_make: + { \@@_choice_make:N \@@_choice_find:n } +\cs_new_protected_nopar:Npn \@@_multichoice_make: + { \@@_choice_make:N \@@_multichoice_find:n } +\cs_new_protected_nopar:Npn \@@_choice_make:N #1 + { + \prop_if_exist:cTF { \c_@@_info_root_tl \@@_parent:o \l_keys_path_tl } + { + \prop_get:cnNTF { \c_@@_info_root_tl \@@_parent:o \l_keys_path_tl } + { choice } \l_keys_value_tl + { + \__msg_kernel_error:nnxx { kernel } { nested-choice-key } + { \l_keys_path_tl } { \@@_parent:o \l_keys_path_tl } + } + { \@@_choice_make_aux:N #1 } + } + { \@@_choice_make_aux:N #1 } + } +\cs_new_protected_nopar:Npn \@@_choice_make_aux:N #1 { - \@@_cmd_set:nn { \l_keys_path_tl } - { \@@_choice_find:n {##1} } + \@@_cmd_set:nn { \l_keys_path_tl } { #1 {##1} } + \prop_put:cnn { \c__keys_info_root_tl \l_keys_path_tl } { choice } + { true } \@@_cmd_set:nn { \l_keys_path_tl / unknown } { \__msg_kernel_error:nnxx { kernel } { key-choice-unknown } { \l_keys_path_tl } {##1} } } +\cs_new:Npn \@@_parent:n #1 + { \@@_parent:wn #1 / / \q_stop { } } +\cs_generate_variant:Nn \@@_parent:n { o } +\cs_new:Npn \@@_parent:wn #1 / #2 / #3 \q_stop #4 + { + \tl_if_blank:nTF {#2} + { \use_none:n #4 } + { + \@@_parent:wn #2 / #3 \q_stop { #4 / #1 } + } + } % \end{macrocode} % \end{macro} +% \end{macro} +% \end{macro} +% \end{macro} % -% \begin{macro}[int]{\@@_choices_make:nn} +% \begin{macro}[int]{\@@_choices_make:nn, \@@_multichoices_make:nn} +% \begin{macro}[aux]{\@@_choices_make:Nnn} % Auto-generating choices means setting up the root key as a choice, then % defining each choice in turn. % \begin{macrocode} -\cs_new_protected:Npn \@@_choices_make:nn #1#2 +\cs_new_protected_nopar:Npn \@@_choices_make:nn + { \@@_choices_make:Nnn \@@_choice_make: } +\cs_new_protected_nopar:Npn \@@_multichoices_make:nn + { \@@_choices_make:Nnn \@@_multichoice_make: } +\cs_new_protected:Npn \@@_choices_make:Nnn #1#2#3 { - \@@_choice_make: + #1 \int_zero:N \l_keys_choice_int - \clist_map_inline:nn {#1} + \clist_map_inline:nn {#2} { \int_incr:N \l_keys_choice_int \@@_cmd_set:nx { \l_keys_path_tl / ##1 } @@ -1345,12 +1389,13 @@ \tl_set:Nn \exp_not:N \l_keys_choice_tl {##1} \int_set:Nn \exp_not:N \l_keys_choice_int { \int_use:N \l_keys_choice_int } - \exp_not:n {#2} + \exp_not:n {#3} } } } % \end{macrocode} % \end{macro} +% \end{macro} % % \begin{macro}[int] % {\@@_cmd_set:nn, \@@_cmd_set:nx, \@@_cmd_set:Vn, \@@_cmd_set:Vo} @@ -1423,47 +1468,6 @@ % \end{macro} % \end{macro} % -% \begin{macro}[int]{\@@_multichoice_find:n} -% \begin{macro}[int]{\@@_multichoice_make:} -% \begin{macro}[int]{\@@_multichoices_make:nn} -% Choices where several values can be selected are very similar to normal -% exclusive choices. There is just a slight change in implementation to -% map across a comma-separated list. This then requires that the appropriate -% set up takes place elsewhere. -% \begin{macrocode} -\cs_new:Npn \@@_multichoice_find:n #1 - { \clist_map_function:nN {#1} \@@_choice_find:n } -\cs_new_protected_nopar:Npn \@@_multichoice_make: - { - \@@_cmd_set:nn { \l_keys_path_tl } - { \@@_multichoice_find:n {##1} } - \@@_cmd_set:nn { \l_keys_path_tl / unknown } - { - \__msg_kernel_error:nnxx { kernel } { key-choice-unknown } - { \l_keys_path_tl } {##1} - } - } -\cs_new_protected:Npn \@@_multichoices_make:nn #1#2 - { - \@@_multichoice_make: - \int_zero:N \l_keys_choice_int - \clist_map_inline:nn {#1} - { - \int_incr:N \l_keys_choice_int - \@@_cmd_set:nx { \l_keys_path_tl / ##1 } - { - \tl_set:Nn \exp_not:N \l_keys_choice_tl {##1} - \int_set:Nn \exp_not:N \l_keys_choice_int - { \int_use:N \l_keys_choice_int } - \exp_not:n {#2} - } - } - } -% \end{macrocode} -% \end{macro} -% \end{macro} -% \end{macro} -% % \begin{macro}[int]{\@@_value_requirement:n} % Values can be required or forbidden by having the appropriate marker % set. First, both the required and forbidden ones are clear, just in case! @@ -2079,17 +2083,22 @@ % \end{macro} % % \begin{macro}[int, EXP]{\@@_choice_find:n} +% \begin{macro}[int, EXP]{\@@_multichoice_find:n} % Executing a choice has two parts. First, try the choice given, then % if that fails call the unknown key. That will exist, as it is created % when a choice is first made. So there is no need for any escape code. +% For multiple choices, the same code ends up used in a mapping. % \begin{macrocode} \cs_new:Npn \@@_choice_find:n #1 { \@@_execute:nn { \l_keys_path_tl / \tl_to_str:n {#1} } { \@@_execute:nn { \l_keys_path_tl / unknown } { } } } +\cs_new:Npn \@@_multichoice_find:n #1 + { \clist_map_function:nN {#1} \@@_choice_find:n } % \end{macrocode} % \end{macro} +% \end{macro} % % \subsection{Utilities} % @@ -2146,7 +2155,7 @@ \__msg_kernel_new:nnnn { kernel } { key-no-property } { No~property~given~in~definition~of~key~'#1'. } { - \c_msg_coding_error_text_tl + \c__msg_coding_error_text_tl Inside~\keys_define:nn each~key~name~ needs~a~property: \\ \\ \iow_indent:n { #1 .<property> } \\ \\ @@ -2158,17 +2167,23 @@ The~module~'#2'~does~not~have~a~key~called~#1'.\\ Check~that~you~have~spelled~the~key~name~correctly. } +\__msg_kernel_new:nnnn { kernel } { nested-choice-key } + { Attempt~to~define~'#1'~as~a~nested~choice~key. } + { + The~key~'#1'~cannot~be~defined~as~a~choice~as~the~parent~key~'#2'~is~ + itself~a~choice. + } \__msg_kernel_new:nnnn { kernel } { property-requires-value } { The~property~'#1'~requires~a~value. } { - \c_msg_coding_error_text_tl + \c__msg_coding_error_text_tl LaTeX~was~asked~to~set~property~'#1'~for~key~'#2'.\\ No~value~was~given~for~the~property,~and~one~is~required. } \__msg_kernel_new:nnnn { kernel } { property-unknown } { The~key~property~'#1'~is~unknown. } { - \c_msg_coding_error_text_tl + \c__msg_coding_error_text_tl LaTeX~has~been~asked~to~set~the~property~'#1'~for~key~'#2':~ this~property~is~not~defined. } @@ -2240,7 +2255,7 @@ \__msg_kernel_new:nnnn { kernel } { generate-choices-before-code } { No~code~available~to~generate~choices~for~key~'#1'. } { - \c_msg_coding_error_text_tl + \c__msg_coding_error_text_tl Before~using~.generate_choices:n~the~code~should~be~defined~ with~'.choice_code:n'~or~'.choice_code:x'. } |