xkeyval — read keys from file Announcing the arrival of Valued Associate #679: Cesar Manara Planned maintenance scheduled April 23, 2019 at 23:30 UTC (7:30pm US/Eastern)Strip one level of braces for using keyval-value within nested keyvalxkeyval declaring package option keys that are choice keys or boolkeysResolve xkeyval key from a definitionProgramming with LaTeX xkeyvalGenerate xkeyval boolean keys 'on the fly'Command with xkeyval keys from different familiesDefining xkeyval keys within a loopOverride optional parameters of newtcblisting from tcolorboxConfusion with “xkeyval” and “newcommand”: Better Way to Use with “lstinputlisting”How to integrate xkeyval keys with Lua code
Why not use the yoke to control yaw, as well as pitch and roll?
What is the definining line between a helicopter and a drone a person can ride in?
“Since the train was delayed for more than an hour, passengers were given a full refund.” – Why is there no article before “passengers”?
Why aren't these two solutions equivalent? Combinatorics problem
Does GDPR cover the collection of data by websites that crawl the web and resell user data
Why does BitLocker not use RSA?
Does Prince Arnaud cause someone holding the Princess to lose?
Can a Wizard take the Magic Initiate feat and select spells from the Wizard list?
xkeyval -- read keys from file
Why did Israel vote against lifting the American embargo on Cuba?
Like totally amazing interchangeable sister outfit accessory swapping or whatever
Protagonist's race is hidden - should I reveal it?
Network Switch Upgrade Planning questions
reduction from 3-SAT to Subset Sum problem
What helicopter has the most rotor blades?
tabularx column has extra padding at right?
Alternative to "rest in peace" (RIP)
Reflections in a Square
How to get a single big right brace?
Has a Nobel Peace laureate ever been accused of war crimes?
Are there any AGPL-style licences that require source code modifications to be public?
Unix AIX passing variable and arguments to expect and spawn
How to break 信じようとしていただけかも知れない into separate parts?
Book about a teenager and alien
xkeyval — read keys from file
Announcing the arrival of Valued Associate #679: Cesar Manara
Planned maintenance scheduled April 23, 2019 at 23:30 UTC (7:30pm US/Eastern)Strip one level of braces for using keyval-value within nested keyvalxkeyval declaring package option keys that are choice keys or boolkeysResolve xkeyval key from a definitionProgramming with LaTeX xkeyvalGenerate xkeyval boolean keys 'on the fly'Command with xkeyval keys from different familiesDefining xkeyval keys within a loopOverride optional parameters of newtcblisting from tcolorboxConfusion with “xkeyval” and “newcommand”: Better Way to Use with “lstinputlisting”How to integrate xkeyval keys with Lua code
I want to read xkeyval options from an external file, like:
setkeysmy@keysinputconf
I tried several combinations of edef and expandafter, but to no avail. Any ideas?
Best regards,
Nicolas
xkeyval
add a comment |
I want to read xkeyval options from an external file, like:
setkeysmy@keysinputconf
I tried several combinations of edef and expandafter, but to no avail. Any ideas?
Best regards,
Nicolas
xkeyval
add a comment |
I want to read xkeyval options from an external file, like:
setkeysmy@keysinputconf
I tried several combinations of edef and expandafter, but to no avail. Any ideas?
Best regards,
Nicolas
xkeyval
I want to read xkeyval options from an external file, like:
setkeysmy@keysinputconf
I tried several combinations of edef and expandafter, but to no avail. Any ideas?
Best regards,
Nicolas
xkeyval
xkeyval
asked 4 hours ago
NicolaF_NicolaF_
563
563
add a comment |
add a comment |
1 Answer
1
active
oldest
votes
You can't edef an input because it isn't expandable. You have to first read the contents of the file to a temporary variable and then pass that to setkeys.
Here's an expl3 implementation of setkeysFile. It's the same as the standard setkeys except that the second argument is a file that (should) contain a comma separated list of key-value pairs.
RequirePackagefilecontents
beginfilecontents*conf.tex
hello = world :D,
goodnews = everyone!,
endfilecontents*
documentclassarticle
usepackagexkeyval
makeatletter
define@keymy@keyshellodeftowhom#1
define@keymy@keysgoodnewsdefwho#1
makeatother
usepackagexparse
ExplSyntaxOn
tl_new:N l__nicolas_setkeys_tl
NewDocumentCommand setkeysFile m m
file_get:nnNTF #2 l__nicolas_setkeys_tl
exp_args:NnV setkeys #1 l__nicolas_setkeys_tl
__kernel_msg_error:nnn kernel file-not-found #2
ExplSyntaxOff
begindocument
setkeysFilemy@keysconf
Hello towhom
Good news who
enddocument
this prints:
1
exp_args:NnV setkeys#1 l__nicolas_setkeys_tlalready supplies the braces and is more correct code anyhow. Theior_open:Nnbusiness is useless.
– egreg
3 hours ago
Thanks :-) But why more correct? Oh, nevermind, it's becauseVgets the value of a register, and a register is anNtype. Am I correct?
– Phelype Oleinik
3 hours ago
1
@PhelypeOleinik Because aV-type argument must be a single token
– Joseph Wright♦
3 hours ago
@JosephWright Thanks! Some day I'll learn how to useexpl3properly :)
– Phelype Oleinik
3 hours ago
add a comment |
Your Answer
StackExchange.ready(function()
var channelOptions =
tags: "".split(" "),
id: "85"
;
initTagRenderer("".split(" "), "".split(" "), channelOptions);
StackExchange.using("externalEditor", function()
// Have to fire editor after snippets, if snippets enabled
if (StackExchange.settings.snippets.snippetsEnabled)
StackExchange.using("snippets", function()
createEditor();
);
else
createEditor();
);
function createEditor()
StackExchange.prepareEditor(
heartbeatType: 'answer',
autoActivateHeartbeat: false,
convertImagesToLinks: false,
noModals: true,
showLowRepImageUploadWarning: true,
reputationToPostImages: null,
bindNavPrevention: true,
postfix: "",
imageUploader:
brandingHtml: "Powered by u003ca class="icon-imgur-white" href="https://imgur.com/"u003eu003c/au003e",
contentPolicyHtml: "User contributions licensed under u003ca href="https://creativecommons.org/licenses/by-sa/3.0/"u003ecc by-sa 3.0 with attribution requiredu003c/au003e u003ca href="https://stackoverflow.com/legal/content-policy"u003e(content policy)u003c/au003e",
allowUrls: true
,
onDemand: true,
discardSelector: ".discard-answer"
,immediatelyShowMarkdownHelp:true
);
);
Sign up or log in
StackExchange.ready(function ()
StackExchange.helpers.onClickDraftSave('#login-link');
);
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
StackExchange.ready(
function ()
StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2ftex.stackexchange.com%2fquestions%2f486074%2fxkeyval-read-keys-from-file%23new-answer', 'question_page');
);
Post as a guest
Required, but never shown
1 Answer
1
active
oldest
votes
1 Answer
1
active
oldest
votes
active
oldest
votes
active
oldest
votes
You can't edef an input because it isn't expandable. You have to first read the contents of the file to a temporary variable and then pass that to setkeys.
Here's an expl3 implementation of setkeysFile. It's the same as the standard setkeys except that the second argument is a file that (should) contain a comma separated list of key-value pairs.
RequirePackagefilecontents
beginfilecontents*conf.tex
hello = world :D,
goodnews = everyone!,
endfilecontents*
documentclassarticle
usepackagexkeyval
makeatletter
define@keymy@keyshellodeftowhom#1
define@keymy@keysgoodnewsdefwho#1
makeatother
usepackagexparse
ExplSyntaxOn
tl_new:N l__nicolas_setkeys_tl
NewDocumentCommand setkeysFile m m
file_get:nnNTF #2 l__nicolas_setkeys_tl
exp_args:NnV setkeys #1 l__nicolas_setkeys_tl
__kernel_msg_error:nnn kernel file-not-found #2
ExplSyntaxOff
begindocument
setkeysFilemy@keysconf
Hello towhom
Good news who
enddocument
this prints:
1
exp_args:NnV setkeys#1 l__nicolas_setkeys_tlalready supplies the braces and is more correct code anyhow. Theior_open:Nnbusiness is useless.
– egreg
3 hours ago
Thanks :-) But why more correct? Oh, nevermind, it's becauseVgets the value of a register, and a register is anNtype. Am I correct?
– Phelype Oleinik
3 hours ago
1
@PhelypeOleinik Because aV-type argument must be a single token
– Joseph Wright♦
3 hours ago
@JosephWright Thanks! Some day I'll learn how to useexpl3properly :)
– Phelype Oleinik
3 hours ago
add a comment |
You can't edef an input because it isn't expandable. You have to first read the contents of the file to a temporary variable and then pass that to setkeys.
Here's an expl3 implementation of setkeysFile. It's the same as the standard setkeys except that the second argument is a file that (should) contain a comma separated list of key-value pairs.
RequirePackagefilecontents
beginfilecontents*conf.tex
hello = world :D,
goodnews = everyone!,
endfilecontents*
documentclassarticle
usepackagexkeyval
makeatletter
define@keymy@keyshellodeftowhom#1
define@keymy@keysgoodnewsdefwho#1
makeatother
usepackagexparse
ExplSyntaxOn
tl_new:N l__nicolas_setkeys_tl
NewDocumentCommand setkeysFile m m
file_get:nnNTF #2 l__nicolas_setkeys_tl
exp_args:NnV setkeys #1 l__nicolas_setkeys_tl
__kernel_msg_error:nnn kernel file-not-found #2
ExplSyntaxOff
begindocument
setkeysFilemy@keysconf
Hello towhom
Good news who
enddocument
this prints:
1
exp_args:NnV setkeys#1 l__nicolas_setkeys_tlalready supplies the braces and is more correct code anyhow. Theior_open:Nnbusiness is useless.
– egreg
3 hours ago
Thanks :-) But why more correct? Oh, nevermind, it's becauseVgets the value of a register, and a register is anNtype. Am I correct?
– Phelype Oleinik
3 hours ago
1
@PhelypeOleinik Because aV-type argument must be a single token
– Joseph Wright♦
3 hours ago
@JosephWright Thanks! Some day I'll learn how to useexpl3properly :)
– Phelype Oleinik
3 hours ago
add a comment |
You can't edef an input because it isn't expandable. You have to first read the contents of the file to a temporary variable and then pass that to setkeys.
Here's an expl3 implementation of setkeysFile. It's the same as the standard setkeys except that the second argument is a file that (should) contain a comma separated list of key-value pairs.
RequirePackagefilecontents
beginfilecontents*conf.tex
hello = world :D,
goodnews = everyone!,
endfilecontents*
documentclassarticle
usepackagexkeyval
makeatletter
define@keymy@keyshellodeftowhom#1
define@keymy@keysgoodnewsdefwho#1
makeatother
usepackagexparse
ExplSyntaxOn
tl_new:N l__nicolas_setkeys_tl
NewDocumentCommand setkeysFile m m
file_get:nnNTF #2 l__nicolas_setkeys_tl
exp_args:NnV setkeys #1 l__nicolas_setkeys_tl
__kernel_msg_error:nnn kernel file-not-found #2
ExplSyntaxOff
begindocument
setkeysFilemy@keysconf
Hello towhom
Good news who
enddocument
this prints:
You can't edef an input because it isn't expandable. You have to first read the contents of the file to a temporary variable and then pass that to setkeys.
Here's an expl3 implementation of setkeysFile. It's the same as the standard setkeys except that the second argument is a file that (should) contain a comma separated list of key-value pairs.
RequirePackagefilecontents
beginfilecontents*conf.tex
hello = world :D,
goodnews = everyone!,
endfilecontents*
documentclassarticle
usepackagexkeyval
makeatletter
define@keymy@keyshellodeftowhom#1
define@keymy@keysgoodnewsdefwho#1
makeatother
usepackagexparse
ExplSyntaxOn
tl_new:N l__nicolas_setkeys_tl
NewDocumentCommand setkeysFile m m
file_get:nnNTF #2 l__nicolas_setkeys_tl
exp_args:NnV setkeys #1 l__nicolas_setkeys_tl
__kernel_msg_error:nnn kernel file-not-found #2
ExplSyntaxOff
begindocument
setkeysFilemy@keysconf
Hello towhom
Good news who
enddocument
this prints:
edited 3 hours ago
egreg
736k8919353261
736k8919353261
answered 4 hours ago
Phelype OleinikPhelype Oleinik
25.9k54691
25.9k54691
1
exp_args:NnV setkeys#1 l__nicolas_setkeys_tlalready supplies the braces and is more correct code anyhow. Theior_open:Nnbusiness is useless.
– egreg
3 hours ago
Thanks :-) But why more correct? Oh, nevermind, it's becauseVgets the value of a register, and a register is anNtype. Am I correct?
– Phelype Oleinik
3 hours ago
1
@PhelypeOleinik Because aV-type argument must be a single token
– Joseph Wright♦
3 hours ago
@JosephWright Thanks! Some day I'll learn how to useexpl3properly :)
– Phelype Oleinik
3 hours ago
add a comment |
1
exp_args:NnV setkeys#1 l__nicolas_setkeys_tlalready supplies the braces and is more correct code anyhow. Theior_open:Nnbusiness is useless.
– egreg
3 hours ago
Thanks :-) But why more correct? Oh, nevermind, it's becauseVgets the value of a register, and a register is anNtype. Am I correct?
– Phelype Oleinik
3 hours ago
1
@PhelypeOleinik Because aV-type argument must be a single token
– Joseph Wright♦
3 hours ago
@JosephWright Thanks! Some day I'll learn how to useexpl3properly :)
– Phelype Oleinik
3 hours ago
1
1
exp_args:NnV setkeys#1 l__nicolas_setkeys_tl already supplies the braces and is more correct code anyhow. The ior_open:Nn business is useless.– egreg
3 hours ago
exp_args:NnV setkeys#1 l__nicolas_setkeys_tl already supplies the braces and is more correct code anyhow. The ior_open:Nn business is useless.– egreg
3 hours ago
Thanks :-) But why more correct? Oh, nevermind, it's because
V gets the value of a register, and a register is an N type. Am I correct?– Phelype Oleinik
3 hours ago
Thanks :-) But why more correct? Oh, nevermind, it's because
V gets the value of a register, and a register is an N type. Am I correct?– Phelype Oleinik
3 hours ago
1
1
@PhelypeOleinik Because a
V-type argument must be a single token– Joseph Wright♦
3 hours ago
@PhelypeOleinik Because a
V-type argument must be a single token– Joseph Wright♦
3 hours ago
@JosephWright Thanks! Some day I'll learn how to use
expl3 properly :)– Phelype Oleinik
3 hours ago
@JosephWright Thanks! Some day I'll learn how to use
expl3 properly :)– Phelype Oleinik
3 hours ago
add a comment |
Thanks for contributing an answer to TeX - LaTeX Stack Exchange!
- Please be sure to answer the question. Provide details and share your research!
But avoid …
- Asking for help, clarification, or responding to other answers.
- Making statements based on opinion; back them up with references or personal experience.
To learn more, see our tips on writing great answers.
Sign up or log in
StackExchange.ready(function ()
StackExchange.helpers.onClickDraftSave('#login-link');
);
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
StackExchange.ready(
function ()
StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2ftex.stackexchange.com%2fquestions%2f486074%2fxkeyval-read-keys-from-file%23new-answer', 'question_page');
);
Post as a guest
Required, but never shown
Sign up or log in
StackExchange.ready(function ()
StackExchange.helpers.onClickDraftSave('#login-link');
);
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
Sign up or log in
StackExchange.ready(function ()
StackExchange.helpers.onClickDraftSave('#login-link');
);
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
Sign up or log in
StackExchange.ready(function ()
StackExchange.helpers.onClickDraftSave('#login-link');
);
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
