Received: from mout.gmx.net (mout.gmx.net [212.227.15.18]) by h1439878.stratoserver.net (8.14.2/8.14.2/Debian-2build1) with ESMTP id r69Ld54d001427 for ; Tue, 9 Jul 2013 23:39:06 +0200 Received: from relay2.uni-heidelberg.de ([129.206.210.211]) by mx-ha.gmx.net (mxgmx006) with ESMTP (Nemesis) id 0Mcyhu-1Ufghd3BHG-00IFQd for ; Tue, 09 Jul 2013 23:39:00 +0200 Received: from listserv.uni-heidelberg.de (listserv.uni-heidelberg.de [129.206.100.94]) by relay2.uni-heidelberg.de (8.13.8/8.13.8) with ESMTP id r69LaSXV005057 (version=TLSv1/SSLv3 cipher=DHE-RSA-AES256-SHA bits=256 verify=NO); Tue, 9 Jul 2013 23:36:28 +0200 Received: from listserv.uni-heidelberg.de (listserv.uni-heidelberg.de [127.0.0.1]) by listserv.uni-heidelberg.de (8.13.8/8.13.8) with ESMTP id r69KRlEB008350; Tue, 9 Jul 2013 23:36:27 +0200 Received: by LISTSERV.UNI-HEIDELBERG.DE (LISTSERV-TCP/IP release 16.0) with spool id 10295210 for LATEX-L@LISTSERV.UNI-HEIDELBERG.DE; Tue, 9 Jul 2013 23:36:27 +0200 Received: from relay2.uni-heidelberg.de (relay2.uni-heidelberg.de [129.206.210.211]) by listserv.uni-heidelberg.de (8.13.8/8.13.8) with ESMTP id r69LaRXf012496 for ; Tue, 9 Jul 2013 23:36:27 +0200 Received: from mail-wi0-f179.google.com (mail-wi0-f179.google.com [209.85.212.179]) by relay2.uni-heidelberg.de (8.13.8/8.13.8) with ESMTP id r69LaIfj005020 (version=TLSv1/SSLv3 cipher=RC4-SHA bits=128 verify=FAIL) for ; Tue, 9 Jul 2013 23:36:20 +0200 Received: by mail-wi0-f179.google.com with SMTP id hj3so5627122wib.0 for ; Tue, 09 Jul 2013 14:36:17 -0700 (PDT) MIME-Version: 1.0 X-Received: by 10.180.80.6 with SMTP id n6mr33528312wix.59.1373405777861; Tue, 09 Jul 2013 14:36:17 -0700 (PDT) Received: by 10.194.241.165 with HTTP; Tue, 9 Jul 2013 14:36:17 -0700 (PDT) Content-Type: text/plain; charset=UTF-8 X-MIME-Autoconverted: from quoted-printable to 8bit by listserv.uni-heidelberg.de id r69LaRXf012497 Message-ID: Date: Tue, 9 Jul 2013 17:36:17 -0400 Reply-To: Mailing list for the LaTeX3 project Sender: Mailing list for the LaTeX3 project From: "Joel C. Salomon" Subject: Using l3keys: choices, property-lists, defaults To: LATEX-L@LISTSERV.UNI-HEIDELBERG.DE Precedence: list List-Help: , List-Unsubscribe: List-Subscribe: List-Owner: List-Archive: Content-Transfer-Encoding: quoted-printable X-MIME-Autoconverted: from 8bit to quoted-printable by relay2.uni-heidelberg.de id r69LaSXV005057 Envelope-To: X-GMX-Antispam: 0 (Mail was not recognized as spam); Detail=V3; X-GMX-Antivirus: 0 (no virus found) X-UI-Filterresults: notjunk:1;V01:K0:zAarG266bkQ=:8vNsh+yxuP0fIdYop3ZL3M Cyuk7KoVHQQJVOhhL6WzkfTCnAUcDxAMgkF/iUX2wvG/06yBfUfJRwaFal2OSjNFsPwats8 Ilw2iNZU/kYS3ZnA6GLAFyc33fxIQKOtoxOs8hp8Da92ZfmQpyiGHuhr7wMG+8Sm5yEtN1K +Uv8dfpwJzEaSOUMunAmJ5SnW/0Fr9hwS8TTuMHn91G9fyxEJcjlMCJuirlfRLs75hMZiS3 cwfquNR3VKM2EYNbBmF0H66eecFd6uaUl8/fZ12d8HmEwS8bHTypnjqRt3ScxgZ523mZTht 1hAb+J3cH48Tpz0FAvUXKSmwHjPzUHLBgpNuhzAAp29H+Engh5tqgPsqX/KmP725wUGWNZ4 giLutark17/rZzkmR9+FnbiPVSQZMTahArySJjI+8W3u6ipYG+vBeYPhsnjoLYuHFTRLTlo LayEAB8tyyRFm7hcDnM44ZqfNp2BtyNDhmFrTKKJZJf8KvUq/Uc0JpyFcoFbe6Hcj1s2bLl 2w89D58LPmAzIpDAXBQcRPc1xIxBDo7aDDbJx90e3AXJweo0qnw0J/mIxcAzWW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V01:zQqIZJ08ubU=:Aa2HHupYVJLa2N/2E/5NTols6x+Dgc1yZ/m13c40A3Y= Status: R X-Status: X-Keywords: X-UID: 7226 Folks, I=E2=80=99ve been following the code changes here, and I=E2=80=99ve asked= two questions on this topic on TeX.SE (=E2=80=9CGenerate l3keys meta key from subkey=E2=80=9D and =E2=80=9C= Can I refer to key value in general code?=E2=80=9D ), but I think I need some direction on this. Here=E2=80=98s my use-case: I=E2=80=99ve got a r=C3=A9sum=C3=A9 class wi= th a set of pre-defined layout options. For example, for Constantia I want \DeclareDocumentCommand \& {} { \textit { \jcsres_ampersand: } } while for Fontin I=E2=80=99ve decided on \DeclareDocumentCommand \& {} { \textsc { \jcsres_ampersand: } } instead. Packages need to be included. And so on and so forth; there are between three and fifteen lines of code for each font-set option. Based on egreg=E2=80=99s suggestion (http://tex.stackexchange.com/a/120275/2966), my code looks something like this (or will, when the new Expl3 updates become available): \bool_if:nTF { \xetex_if_engine_p: || \luatex_if_engine_p: } { \clist_const:Nn \c_jcs_fonts_clist { fontin, constantia, lmodern } } { \clist_const:Nn \c_jcs_fonts_clist { kpfonts, lmodern } } \clist_get:NN \c_jcs_fonts_clist \c_jcs_default_font_tl \keys_define:nn { jcsres } { font .choices:Vn =3D \c_jcs_fonts_clist { \tl_gset:NV \g_jcs_font_option_tl \l_keys_choice_tl }, font .initial:V =3D \c_jcs_default_font_tl, font .value_required, font / unknown .code:n =3D { \msg_warning:nnn { jcsres } { unknown-font-option } { #1 } } } \msg_new:nnn { jcsres } { unknown-font-option } { unknown~font~option~`#1';~using~`\c_jcs_default_font_tl'~instead } \clist_map_inline:Nn \c_jcs_fonts_clist { \keys_define:nn { jcsres } { #1 .meta:n =3D { font =3D #1 }, #1 .value_forbidden: } } % Somewhere later in the code... \ProcessKeysOptions { jcsres } % Somewhere later yet... \str_case:VnF \g_jcs_font_option_tl { { fontin } { =E2=80=A6 } { constantia } { =E2=80=A6 } { lmodern } { =E2=80=A6 } { kpfonts } { =E2=80=A6 } } { \msg_error:nnn { jcsres } { still-unknown-font-option } { #1 } } \msg_new:nnn { jcsres } { still-unknown-font-option } { can't~happen:~unknown~font~option~`#1'. } This all works, but there=E2=80=99s a fair amount of repetition of inform= ation. Bruno has suggested (http://tex.stackexchange.com/a/123201/2966) using property lists instead. This feels like a more natural fit for the problem, and here=E2=80=99s the code I=E2=80=99ve come up with: \prop_new:N \g_jcs_fontcode_prop \prop_gput:Nnn \g_jcs_fontcode_prop { lmodern } { =E2=80=A6 } \bool_if:nT { \xetex_if_engine_p: || \luatex_if_engine_p: } { \prop_gput:Nnn \g_jcs_fontcode_prop { fontin } { =E2=80=A6 } } \bool_if:nT { \xetex_if_engine_p: || \luatex_if_engine_p: } { \prop_gput:Nnn \g_jcs_fontcode_prop { constantia } { =E2=80=A6 } } \bool_if:nF { \xetex_if_engine_p: || \luatex_if_engine_p: } { \prop_gput:Nnn \g_jcs_fontcode_prop { kpfonts } { =E2=80=A6 } } \tl_const:Nx \c_jcs_default_font_tl { \bool_if:nTF { \xetex_if_engine_p: || \luatex_if_engine_p: } { fontin } { kpfonts } } \tl_new:N \l_jcs_fontcode_tl \keys_define:nn { jcsres } { font .code:n =3D { \prop_get:NnNTF \g_jcs_fontcode_prop {#1} \l_jcs_fontcode_tl { \tl_gset_eq:NN \g_jcs_fontcode_tl \l_jcs_fontcode_tl } { \msg_warning:nnn { jcsres } { unknown-font-option } { #1 } \prop_get:NVN \g_jcs_fontcode_prop \c_jcs_default_font_tl \l_jcs_fontcode_tl \tl_gset_eq:NN \g_jcs_fontcode_tl \l_jcs_fontcode_tl } }, font .value_required:, font .initial:V =3D \c_jcs_default_font_tl } \prop_map_inline:Nn \g_jcs_fontcode_prop { \keys_define:nn { jcsres } { #1 .meta:n =3D { font =3D #1 }, #1 .value_forbidden: } } % Somewhere later in the code... \ProcessKeysOptions { jcsres } \tl_use:N \g_jcs_fontcode_tl The trick with copying the code sequence (rather than executing it within the call to \keys_define) is needed so the default code isn=E2=80=99= t run if an option is supplied, or in case the user writes \usepackage[font=3Dfontin, font=3Dconstantia]{jcsres} to execute both conflicting options. Does this begin to sound like the way forward? =E2=80=94Joel