xkeyval — read keys from fileStrip one level of braces for using keyval-value within nested keyvalExpand command read from fileGenerate xkeyval boolean keys 'on the fly'Command with xkeyval keys from different familiesDefining xkeyval keys within a loopHow to compare and see if an expanded command is equal to anotherHow to create and manage hierarchically dependent PGF keys?Confusion with “xkeyval” and “newcommand”: Better Way to Use with “lstinputlisting”Loading pgfkeys key values from an external file without Expl3?How to integrate xkeyval keys with Lua code

Is the claim "Employers won't employ people with no 'social media presence'" realistic?

Can I criticise the more senior developers around me for not writing clean code?

How exactly does Hawking radiation decrease the mass of black holes?

Is there a way to generate a list of distinct numbers such that no two subsets ever have an equal sum?

Can SQL Server create collisions in system generated constraint names?

Minor Revision with suggestion of an alternative proof by reviewer

Why was the Spitfire's elliptical wing almost uncopied by other aircraft of World War 2?

Is there really no use for MD5 anymore?

What are the characteristics of a typeless programming language?

Relationship between strut and baselineskip

What happened to Captain America in Endgame?

How to limit Drive Letters Windows assigns to new removable USB drives

Mistake in years of experience in resume?

Alignment of various blocks in tikz

If a planet has 3 moons, is it possible to have triple Full/New Moons at once?

Re-entry to Germany after vacation using blue card

What term is being referred to with "reflected-sound-of-underground-spirits"?

acheter à, to mean both "from" and "for"?

As an international instructor, should I openly talk about my accent?

How to stop co-workers from teasing me because I know Russian?

What happens to Mjolnir (Thor's hammer) at the end of Endgame?

Check if a string is entirely made of the same substring

How did Captain America manage to do this?

Pulling the rope with one hand is as heavy as with two hands?



xkeyval — read keys from file


Strip one level of braces for using keyval-value within nested keyvalExpand command read from fileGenerate xkeyval boolean keys 'on the fly'Command with xkeyval keys from different familiesDefining xkeyval keys within a loopHow to compare and see if an expanded command is equal to anotherHow to create and manage hierarchically dependent PGF keys?Confusion with “xkeyval” and “newcommand”: Better Way to Use with “lstinputlisting”Loading pgfkeys key values from an external file without Expl3?How to integrate xkeyval keys with Lua code













5















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










share|improve this question




























    5















    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










    share|improve this question


























      5












      5








      5








      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










      share|improve this question
















      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







      expansion key-value xkeyval






      share|improve this question















      share|improve this question













      share|improve this question




      share|improve this question








      edited Apr 22 at 21:33









      Phelype Oleinik

      26.2k54791




      26.2k54791










      asked Apr 22 at 16:51









      NicolaF_NicolaF_

      585




      585




















          1 Answer
          1






          active

          oldest

          votes


















          6














          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:




          enter image description here







          share|improve this answer




















          • 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
            Apr 22 at 17:32












          • 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
            Apr 22 at 17:35







          • 1





            @PhelypeOleinik Because a V-type argument must be a single token

            – Joseph Wright
            Apr 22 at 17:38











          • @JosephWright Thanks! Some day I'll learn how to use expl3 properly :)

            – Phelype Oleinik
            Apr 22 at 17:43






          • 1





            Thanks, that did the trick. My texlive distrib did not have get_file used catchfile's CatchFileEdef instead.

            – NicolaF_
            Apr 23 at 4:40











          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
          );



          );













          draft saved

          draft discarded


















          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









          6














          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:




          enter image description here







          share|improve this answer




















          • 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
            Apr 22 at 17:32












          • 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
            Apr 22 at 17:35







          • 1





            @PhelypeOleinik Because a V-type argument must be a single token

            – Joseph Wright
            Apr 22 at 17:38











          • @JosephWright Thanks! Some day I'll learn how to use expl3 properly :)

            – Phelype Oleinik
            Apr 22 at 17:43






          • 1





            Thanks, that did the trick. My texlive distrib did not have get_file used catchfile's CatchFileEdef instead.

            – NicolaF_
            Apr 23 at 4:40















          6














          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:




          enter image description here







          share|improve this answer




















          • 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
            Apr 22 at 17:32












          • 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
            Apr 22 at 17:35







          • 1





            @PhelypeOleinik Because a V-type argument must be a single token

            – Joseph Wright
            Apr 22 at 17:38











          • @JosephWright Thanks! Some day I'll learn how to use expl3 properly :)

            – Phelype Oleinik
            Apr 22 at 17:43






          • 1





            Thanks, that did the trick. My texlive distrib did not have get_file used catchfile's CatchFileEdef instead.

            – NicolaF_
            Apr 23 at 4:40













          6












          6








          6







          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:




          enter image description here







          share|improve this answer















          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:




          enter image description here








          share|improve this answer














          share|improve this answer



          share|improve this answer








          edited Apr 22 at 17:48









          egreg

          737k8919373265




          737k8919373265










          answered Apr 22 at 17:30









          Phelype OleinikPhelype Oleinik

          26.2k54791




          26.2k54791







          • 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
            Apr 22 at 17:32












          • 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
            Apr 22 at 17:35







          • 1





            @PhelypeOleinik Because a V-type argument must be a single token

            – Joseph Wright
            Apr 22 at 17:38











          • @JosephWright Thanks! Some day I'll learn how to use expl3 properly :)

            – Phelype Oleinik
            Apr 22 at 17:43






          • 1





            Thanks, that did the trick. My texlive distrib did not have get_file used catchfile's CatchFileEdef instead.

            – NicolaF_
            Apr 23 at 4:40












          • 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
            Apr 22 at 17:32












          • 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
            Apr 22 at 17:35







          • 1





            @PhelypeOleinik Because a V-type argument must be a single token

            – Joseph Wright
            Apr 22 at 17:38











          • @JosephWright Thanks! Some day I'll learn how to use expl3 properly :)

            – Phelype Oleinik
            Apr 22 at 17:43






          • 1





            Thanks, that did the trick. My texlive distrib did not have get_file used catchfile's CatchFileEdef instead.

            – NicolaF_
            Apr 23 at 4:40







          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
          Apr 22 at 17:32






          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
          Apr 22 at 17:32














          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
          Apr 22 at 17:35






          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
          Apr 22 at 17:35





          1




          1





          @PhelypeOleinik Because a V-type argument must be a single token

          – Joseph Wright
          Apr 22 at 17:38





          @PhelypeOleinik Because a V-type argument must be a single token

          – Joseph Wright
          Apr 22 at 17:38













          @JosephWright Thanks! Some day I'll learn how to use expl3 properly :)

          – Phelype Oleinik
          Apr 22 at 17:43





          @JosephWright Thanks! Some day I'll learn how to use expl3 properly :)

          – Phelype Oleinik
          Apr 22 at 17:43




          1




          1





          Thanks, that did the trick. My texlive distrib did not have get_file used catchfile's CatchFileEdef instead.

          – NicolaF_
          Apr 23 at 4:40





          Thanks, that did the trick. My texlive distrib did not have get_file used catchfile's CatchFileEdef instead.

          – NicolaF_
          Apr 23 at 4:40

















          draft saved

          draft discarded
















































          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.




          draft saved


          draft discarded














          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





















































          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







          Popular posts from this blog

          Sum ergo cogito? 1 nng

          三茅街道4182Guuntc Dn precexpngmageondP