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 s539At90000747 for ; Tue, 3 Jun 2014 11:10:56 +0200 Received: from relay.uni-heidelberg.de ([129.206.100.212]) by mx-ha.gmx.net (mxgmx108) with ESMTPS (Nemesis) id 0MNvXz-1WuDi741gB-007Tph for ; Tue, 03 Jun 2014 11:10:49 +0200 Received: from listserv.uni-heidelberg.de (listserv.uni-heidelberg.de [129.206.100.94]) by relay.uni-heidelberg.de (8.14.1/8.14.1) with ESMTP id s5396l7I006865 (version=TLSv1/SSLv3 cipher=DHE-RSA-AES256-SHA bits=256 verify=NO); Tue, 3 Jun 2014 11:06:47 +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 s52M13a6018232; Tue, 3 Jun 2014 11:06:47 +0200 Received: by LISTSERV.UNI-HEIDELBERG.DE (LISTSERV-TCP/IP release 16.0) with spool id 11066134 for LATEX-L@LISTSERV.UNI-HEIDELBERG.DE; Tue, 3 Jun 2014 11:06:47 +0200 Received: from relay.uni-heidelberg.de (relay.uni-heidelberg.de [129.206.100.212]) by listserv.uni-heidelberg.de (8.13.8/8.13.8) with ESMTP id s5396kbj024222 for ; Tue, 3 Jun 2014 11:06:46 +0200 Received: from smtp3.easily.co.uk (smtp3.easily.co.uk [95.130.72.151]) by relay.uni-heidelberg.de (8.14.1/8.14.1) with ESMTP id s5394QRn004593 (version=TLSv1/SSLv3 cipher=DHE-RSA-AES256-SHA bits=256 verify=NO) for ; Tue, 3 Jun 2014 11:04:29 +0200 Received: from [139.222.113.100] (port=52743 helo=[139.222.113.100]) by smtp3.easily.co.uk with esmtpa (Exim 4.43) id 1WrldH-0004qd-Uo for LATEX-L@LISTSERV.UNI-HEIDELBERG.DE; Tue, 03 Jun 2014 11:07:51 +0100 User-Agent: Mozilla/5.0 (Windows NT 6.1; WOW64; rv:24.0) Gecko/20100101 Thunderbird/24.5.0 MIME-Version: 1.0 References: <538C959C.3060904@morningstar2.co.uk> <538CA727.1000203@morningstar2.co.uk> <538D0DD2.2090106@nag.co.uk> X-Enigmail-Version: 1.6 Content-Type: text/plain; charset=ISO-8859-1 Content-Transfer-Encoding: 7bit Message-ID: <538D8F99.3010400@morningstar2.co.uk> Date: Tue, 3 Jun 2014 10:04:25 +0100 Reply-To: Mailing list for the LaTeX3 project Sender: Mailing list for the LaTeX3 project From: Joseph Wright Subject: Re: 'Preseting' keys To: LATEX-L@LISTSERV.UNI-HEIDELBERG.DE In-Reply-To: <538D0DD2.2090106@nag.co.uk> Precedence: list List-Help: , List-Unsubscribe: List-Subscribe: List-Owner: List-Archive: 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:idI/r3FLA8w=:Kjb5a53ZkeMGOCcr9PtflkaJmI 7dTj1L5+6ksX7q9bx/cWhZCRgLF7OgHkB0lG1QoOsl2LC/OobQcwR9rxcNXKq9BvOhh+3004i kTXvkQqVYm0OFQQ+xBWI4qNPuUJjYp+N60gon61LrWgjasC93yX5Ga1sP/dLDbBs4iqSjdvN2 2Vdo7Jdyu6vRDdG+lXDRg+L61lVE2QZgar0uLrmwbG3bf7qplqe3rAf+Y1eul6VtUg2njwD3j CNK4IPzD/d7nb5ZvzJCOyeqN5bXMh/+dIa+bEh0shc51xOprfPPuDy93hvnukZEOMXmYgebB5 w7xTkd+Eyd1/NZsDVdg9anlh8VE6FFs+367F+Ne2sigdctEDdbuJI6z/7seMGWsGZ3EzK3mi8 cwuALbVFcdVGVbPBRVXVWom0NSFuybActJplQn4Or7HxeI2DWw2Y0BwPYRiXpq0r93uHE/F7V 2ZJUBWnJi5fuK9aj/s8E4rxbdV0Acb2mz4U0UaURlPc8Os06j//OUSToWnRgbuC9cczNH1lA3 smyFceUrYlN2yM7fwzO7xnepNZ+yc9B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636mU=:xyEZDLuJL5D+QN6UBBjR5vkEF+dl+swHfLzLnLZilNE= Status: R X-Status: X-Keywords: X-UID: 7483 On 03/06/2014 00:50, David Carlisle wrote: > On 02/06/2014 17:32, Joseph Wright wrote: >> On 02/06/2014 16:17, Joseph Wright wrote: >>> Hello all, >>> >>> A reasonably common use case for keyval method is is the situation where >>> one or more keys are set to a value implicitly. This is often managed in >>> LaTeX using grouping. >>> >>> % Set up keys >>> \keys_define:nn { mymod } >>> { >>> key-a .tl_set:N = \l_mya_tl , >>> ... >>> } >>> \keys_set:nn { mymod } >>> { >>> key-a = value % Applies unless set otherwise >>> } >>> ... >>> \group_begin: >>> \keys_set:nn { mymod } >>> { >>> key-a = new-value >>> } >>> \group-end: >>> % key-a will be "value" again >>> \group_begin: >>> \keys_set:nn { mymod } >>> { >>> % No key-a set => "value" >>> } >>> >>> However, there are cases where you'd like to 'preset' the key every >>> time. Currently, that would require >>> >>> \cs_new_protected:Npn \foo #1#2 % #1 = keys >>> { >>> \keys_set:nn { mymod } >>> { >>> key-a = new-value , >>> #1 >>> } >>> >>> but that is not that efficient and also not that clear. >>> >>> An alternative approach is to provide a method to 'preset' keys from >>> within the key system, something like >>> >>> \keys_define:nn { mymod } >>> { >>> key-a .tl_set:N = \l_mya_tl , >>> key-a .preset:n = value >>> ... >>> } >>> >>> where the presetting can avoid having to parse the keys each time it's >>> run (cf. what happens in xtemplate). >>> >>> The team have some use cases where this makes sense, so I will be >>> looking to add it as an experimental idea. Before I do, thought, I'd >>> like to know if the name, etc., makes sense. It's distinct from >>> ".default:n" (used if a key name is given with no property) and >>> ".initial:n" (a 'set up' shortcut). >>> >>> I note that xkeyval offers the idea of preset keys, but in a slightly >>> more complex fashion as it allows 'tail' keys and does some tests for >>> the presence of keys before doing presetting. I don't see a similar >>> concept in the pgfkeys manual: I have a feeling there just the 'manual' >>> approach is used. >>> >>> Thoughts? >> Particular questions here as well as the name are whether 'presetting' >> depends on what is in the key list (should keys be preset if they are >> found in the key list?) and what, if anything, should be done >> differently in the key filtering cases. > > > This reminds me of > > http://tex.stackexchange.com/questions/164116/which-arguments-of-includegraphics-cannot-be-set-beforehand/164132#164132 > > > graphics essentially pre-sets scale=1 (it shouldn't, but it does) > > the unexpected user experience as a result of that is that you can go > > \includegraphics[scale=2]{...} > > but (unlike almost all other keys) you can't go > > \setkeys{Gin}{scale=2} > \includegraphics[]{...} > > as the key gets set to 2 then "preset" back to 1 before any keys in the > actual graphics call are handled. > > I can't change graphics now, but I suspect that either of the following > two alternatives would have been better > > > 1) initialise the key _at the point of definition_ > so scale always had a value (defaulting to 1). > > > 2) preset the key at the point of use, but only if it is > currently unset (ie some internal macro is either undefined or > has some \NoValue value, however it's implemented). > > > > This seems to be a general feature not something specific to graphics/scale > so I wonder if it would be possible to accommodate these choices in a > declarative > l3keys interface Presetting is I think quite a specialist case: as you say, with graphics one would expect \setkeys{Gin}{scale=2} \includegraphics{...} to use the 'normal' convention that keys set globally automatically apply to individual uses unless overwritten: very common approach in packages, normally based on applying a group. I can see how one might set up a 'preset if not already set' approach, but I'm not sure how it's different from simply starting off with a default. The point, as I understand it, of allowing presetting is to cover cases where each 'set' operation should have a know starting point that isn't influenced by the 'surroundings'. -- Joseph Wright