* two sets of default header arguments for one language @ 2015-09-10 13:54 Alan Schmitt 2015-09-10 21:00 ` Thomas S. Dye ` (2 more replies) 0 siblings, 3 replies; 13+ messages in thread From: Alan Schmitt @ 2015-09-10 13:54 UTC (permalink / raw) To: emacs-orgmode [-- Attachment #1: Type: text/plain, Size: 701 bytes --] Hello, I’m writing some lab exercises where I have a fairly long list of header arguments for each source block. I know I can use language-specific default arguments, but I need to switch between questions (short list): #+begin_src ocaml :tangle tp1.ml and answers #+begin_src ocaml :exports results :results verbatim drawer :post wrap-myres(text=*this*) :tangle tp1_ans.ml Is there a way to have two sets of default arguments for a given language, or can I declare a new language just for the sake of different arguments? Thanks, Alan -- OpenPGP Key ID : 040D0A3B4ED2E5C7 Last week athmospheric CO₂ average (Updated September 6, 2015, Mauna Loa Obs.): 377.86 ppm [-- Attachment #2: signature.asc --] [-- Type: application/pgp-signature, Size: 472 bytes --] ^ permalink raw reply [flat|nested] 13+ messages in thread
* Re: two sets of default header arguments for one language 2015-09-10 13:54 two sets of default header arguments for one language Alan Schmitt @ 2015-09-10 21:00 ` Thomas S. Dye 2015-09-11 9:30 ` Alan Schmitt 2015-09-10 21:16 ` Rainer M Krug 2015-09-10 22:28 ` Charles C. Berry 2 siblings, 1 reply; 13+ messages in thread From: Thomas S. Dye @ 2015-09-10 21:00 UTC (permalink / raw) To: Alan Schmitt; +Cc: emacs-orgmode Aloha Alan, Alan Schmitt <alan.schmitt@polytechnique.org> writes: > Hello, > > I’m writing some lab exercises where I have a fairly long list of header > arguments for each source block. I know I can use language-specific > default arguments, but I need to switch between questions (short list): > > #+begin_src ocaml :tangle tp1.ml > > and answers > > #+begin_src ocaml :exports results :results verbatim drawer :post wrap-myres(text=*this*) :tangle tp1_ans.ml > > Is there a way to have two sets of default arguments for a given > language, or can I declare a new language just for the sake of different > arguments? Perhaps you could specify language specific header arguments in properties and keep the questions under one heading and the answers under another heading? * Questions :PROPERTIES: :header-args:ocaml: :tangle tp1.ml :END: ... *Answers :PROPERTIES: :header-args:ocaml: :exports results :results verbatim drawer :post wrap-myres(text=*this*) :tangle tp1_ans.ml :END: hth, Tom -- Thomas S. Dye http://www.tsdye.com ^ permalink raw reply [flat|nested] 13+ messages in thread
* Re: two sets of default header arguments for one language 2015-09-10 21:00 ` Thomas S. Dye @ 2015-09-11 9:30 ` Alan Schmitt 0 siblings, 0 replies; 13+ messages in thread From: Alan Schmitt @ 2015-09-11 9:30 UTC (permalink / raw) To: Thomas S. Dye; +Cc: emacs-orgmode [-- Attachment #1: Type: text/plain, Size: 911 bytes --] Hi Thomas, On 2015-09-10 23:00, Thomas S. Dye <tsd@tsdye.com> writes: >> Is there a way to have two sets of default arguments for a given >> language, or can I declare a new language just for the sake of different >> arguments? > > Perhaps you could specify language specific header arguments in > properties and keep the questions under one heading and the answers > under another heading? > > * Questions > :PROPERTIES: > :header-args:ocaml: :tangle tp1.ml > :END: > > ... > > *Answers > :PROPERTIES: > :header-args:ocaml: :exports results :results verbatim drawer :post > wrap-myres(text=*this*) :tangle tp1_ans.ml > :END: Thank you for the suggestion, but it really goes against the structure of the document I have in mind. Alan -- OpenPGP Key ID : 040D0A3B4ED2E5C7 Last week athmospheric CO₂ average (Updated September 9, 2015, Mauna Loa Obs.): 377.86 ppm [-- Attachment #2: signature.asc --] [-- Type: application/pgp-signature, Size: 472 bytes --] ^ permalink raw reply [flat|nested] 13+ messages in thread
* Re: two sets of default header arguments for one language 2015-09-10 13:54 two sets of default header arguments for one language Alan Schmitt 2015-09-10 21:00 ` Thomas S. Dye @ 2015-09-10 21:16 ` Rainer M Krug 2015-09-10 21:25 ` Nicolas Goaziou 2015-09-10 22:28 ` Charles C. Berry 2 siblings, 1 reply; 13+ messages in thread From: Rainer M Krug @ 2015-09-10 21:16 UTC (permalink / raw) To: Alan Schmitt; +Cc: emacs-orgmode Envoyé de mon iPhone > Le 10 sept. 2015 à 15:54, Alan Schmitt <alan.schmitt@polytechnique.org> a écrit : > > Hello, > > I’m writing some lab exercises where I have a fairly long list of header > arguments for each source block. I know I can use language-specific > default arguments, but I need to switch between questions (short list): > > #+begin_src ocaml :tangle tp1.ml > > and answers > > #+begin_src ocaml :exports results :results verbatim drawer :post wrap-myres(text=*this*) :tangle tp1_ans.ml > > Is there a way to have two sets of default arguments for a given > language, or can I declare a new language just for the sake of different > arguments? > Do macros work for properties ? If yes, you could degine two macro, one for each set of properties. Rainer > Thanks, > > Alan > > -- > OpenPGP Key ID : 040D0A3B4ED2E5C7 > Last week athmospheric CO₂ average (Updated September 6, 2015, Mauna Loa Obs.): > 377.86 ppm ^ permalink raw reply [flat|nested] 13+ messages in thread
* Re: two sets of default header arguments for one language 2015-09-10 21:16 ` Rainer M Krug @ 2015-09-10 21:25 ` Nicolas Goaziou 2015-09-11 7:09 ` Rainer M Krug 0 siblings, 1 reply; 13+ messages in thread From: Nicolas Goaziou @ 2015-09-10 21:25 UTC (permalink / raw) To: Rainer M Krug; +Cc: Alan Schmitt, emacs-orgmode Hello, Rainer M Krug <r.m.krug@gmail.com> writes: > Do macros work for properties ? If yes, you could degine two macro, > one for each set of properties. No, they don't. Regards, -- Nicolas Goaziou ^ permalink raw reply [flat|nested] 13+ messages in thread
* Re: two sets of default header arguments for one language 2015-09-10 21:25 ` Nicolas Goaziou @ 2015-09-11 7:09 ` Rainer M Krug 2015-09-11 9:33 ` Alan Schmitt 2015-09-11 16:27 ` Nicolas Goaziou 0 siblings, 2 replies; 13+ messages in thread From: Rainer M Krug @ 2015-09-11 7:09 UTC (permalink / raw) To: Rainer M Krug; +Cc: Alan Schmitt, emacs-orgmode [-- Attachment #1: Type: text/plain, Size: 1712 bytes --] Nicolas Goaziou <mail@nicolasgoaziou.fr> writes: > Hello, > > Rainer M Krug <r.m.krug@gmail.com> writes: > >> Do macros work for properties ? If yes, you could degine two macro, >> one for each set of properties. > > No, they don't. That's a pity. It would be really great if one could define different sets of hearer-args and then, at thr beginning of a code block, simply use: #+MACRO: forTangle :tangle ./test.R :export none #+MACRO: forExecution :tangle no :export both :session Test14 #+MACRO: forNoSession :tangle no :export both #+:header-args {{{forTangle}}} #+begin_src R :tangle no cat(13) #+end_src #+:header-args {{{forExecution}}} #+begin_src R :tangle no cat(14) #+end_src #+:header-args {{{forNoSession}}} #+begin_src R :tangle no cat(14) #+end_src This would make it much easier to work with header-args and solve many problems which were discussed in earlier threads. The example might not be the best as it could be implemented by header-args+ but if the code blocks using the different sets of header-args are at different locations in the org document, changing them would be much easier with macro expansion (or similar). Would it be difficult to include this feature? Thanks, Rainer > > Regards, -- Rainer M. Krug, PhD (Conservation Ecology, SUN), MSc (Conservation Biology, UCT), Dipl. Phys. (Germany) Centre of Excellence for Invasion Biology Stellenbosch University South Africa Tel : +33 - (0)9 53 10 27 44 Cell: +33 - (0)6 85 62 59 98 Fax : +33 - (0)9 58 10 27 44 Fax (D): +49 - (0)3 21 21 25 22 44 email: Rainer@krugs.de Skype: RMkrug PGP: 0x0F52F982 [-- Attachment #2: signature.asc --] [-- Type: application/pgp-signature, Size: 480 bytes --] ^ permalink raw reply [flat|nested] 13+ messages in thread
* Re: two sets of default header arguments for one language 2015-09-11 7:09 ` Rainer M Krug @ 2015-09-11 9:33 ` Alan Schmitt 2015-09-11 16:27 ` Nicolas Goaziou 1 sibling, 0 replies; 13+ messages in thread From: Alan Schmitt @ 2015-09-11 9:33 UTC (permalink / raw) To: Rainer M Krug; +Cc: emacs-orgmode, Rainer M Krug [-- Attachment #1: Type: text/plain, Size: 901 bytes --] On 2015-09-11 09:09, Rainer M Krug <Rainer@krugs.de> writes: > Nicolas Goaziou <mail@nicolasgoaziou.fr> writes: > >> Hello, >> >> Rainer M Krug <r.m.krug@gmail.com> writes: >> >>> Do macros work for properties ? If yes, you could degine two macro, >>> one for each set of properties. >> >> No, they don't. > > That's a pity. > > It would be really great if one could define different sets of > hearer-args and then, at thr beginning of a code block, simply use: This would be great indeed. I’m still going to look at macros as I noticed the code always has the shape - source block with the answer - source block for a test for the students - source block for tests to grade the students answers Thanks for the suggestion! Alan -- OpenPGP Key ID : 040D0A3B4ED2E5C7 Last week athmospheric CO₂ average (Updated September 9, 2015, Mauna Loa Obs.): 377.86 ppm [-- Attachment #2: signature.asc --] [-- Type: application/pgp-signature, Size: 472 bytes --] ^ permalink raw reply [flat|nested] 13+ messages in thread
* Re: two sets of default header arguments for one language 2015-09-11 7:09 ` Rainer M Krug 2015-09-11 9:33 ` Alan Schmitt @ 2015-09-11 16:27 ` Nicolas Goaziou 2015-09-18 10:17 ` Rainer M Krug 1 sibling, 1 reply; 13+ messages in thread From: Nicolas Goaziou @ 2015-09-11 16:27 UTC (permalink / raw) To: Rainer M Krug; +Cc: Alan Schmitt, emacs-orgmode, Rainer M Krug Rainer M Krug <Rainer@krugs.de> writes: > That's a pity. > > It would be really great if one could define different sets of > hearer-args and then, at thr beginning of a code block, simply use: > > #+MACRO: forTangle :tangle ./test.R :export none > #+MACRO: forExecution :tangle no :export both :session Test14 > #+MACRO: forNoSession :tangle no :export both It might be great. Probably hackish too. Anyway simplicity of macros is one of its features, IMO. They are limited, yet useful for simple things. Fortunately, there are other ways to achieve what you want without them. > Would it be difficult to include this feature? Probably not. The most permissive model for macros is even simpler to implement than the current one, i.e., something like (replace-regexp-in-string macro-regexp macro-template buffer) However macros actually follow a different paradigm, in which they are required to be parsed. As a consequence they cannot really break the structure of their container, which turns them into "safe" tools. For example, you can compare the model above and the current one in the following document A paragraph Paragraph{{{this(arg #+name: table | cell | )}}} | Your proposal in to allow them where the parser doesn't look, e.g., Babel header arguments, but probably also other places (node properties, keywords...). It is difficult to draw a line. In any case, I'm not sure macros would benefit from it. Babel can already do a lot of destructuring in a document, not every tool needs to be as versatile as Babel. Regards, ^ permalink raw reply [flat|nested] 13+ messages in thread
* Re: two sets of default header arguments for one language 2015-09-11 16:27 ` Nicolas Goaziou @ 2015-09-18 10:17 ` Rainer M Krug 0 siblings, 0 replies; 13+ messages in thread From: Rainer M Krug @ 2015-09-18 10:17 UTC (permalink / raw) To: Nicolas Goaziou; +Cc: Alan Schmitt, emacs-orgmode [-- Attachment #1: Type: text/plain, Size: 3209 bytes --] Nicolas Goaziou <mail@nicolasgoaziou.fr> writes: > Rainer M Krug <Rainer@krugs.de> writes: > >> That's a pity. >> >> It would be really great if one could define different sets of >> hearer-args and then, at thr beginning of a code block, simply use: >> >> #+MACRO: forTangle :tangle ./test.R :export none >> #+MACRO: forExecution :tangle no :export both :session Test14 >> #+MACRO: forNoSession :tangle no :export both > > It might be great. Probably hackish too. > > Anyway simplicity of macros is one of its features, IMO. They are > limited, yet useful for simple things. > > Fortunately, there are other ways to achieve what you want without them. > >> Would it be difficult to include this feature? > > Probably not. The most permissive model for macros is even simpler to > implement than the current one, i.e., something like > > (replace-regexp-in-string macro-regexp macro-template buffer) > > However macros actually follow a different paradigm, in which they are > required to be parsed. As a consequence they cannot really break the > structure of their container, which turns them into "safe" tools. For > example, you can compare the model above and the current one in the > following document > > A paragraph Paragraph{{{this(arg > #+name: table > | cell | )}}} | > > Your proposal in to allow them where the parser doesn't look, e.g., > Babel header arguments, but probably also other places (node properties, > keywords...). It is difficult to draw a line. In any case, I'm not sure > macros would benefit from it. Babel can already do a lot of > destructuring in a document, not every tool needs to be as versatile as > Babel. Thanks for your explanations - I am not using macros regularly (not yet...) so I was not aware of these aspects. I was just using macros as an example - I am not advocating to change macros if this would change something. A simpler option would be possibly to use properties. Assuming I have the following properties defined: ,---- | #+PROPERTY: headerArgsForTangline :tangle ./testfile.R | #+PROPERTY: headerArgsForSession :tangle no :session *MyRSession* | #+PROPERTY: headerArgsForNoSession :tangle no `---- then I could do ,---- | :header-args*: headerArgsForSession `---- and the header arguments would be set to the value of headerArgsForSession and be ":tangle no :session *MyRSession*". This would make it possible to define sets of header arguments for certain aspects (one example I would use it for: creating graphs and define the width and height properties. Depending if I want portrait or landscape graphs, I would use the one or the other property and they could be ca=hanged easily for the whole document.) Cheers, Rainer > > -- Rainer M. Krug, PhD (Conservation Ecology, SUN), MSc (Conservation Biology, UCT), Dipl. Phys. (Germany) Centre of Excellence for Invasion Biology Stellenbosch University South Africa Tel : +33 - (0)9 53 10 27 44 Cell: +33 - (0)6 85 62 59 98 Fax : +33 - (0)9 58 10 27 44 Fax (D): +49 - (0)3 21 21 25 22 44 email: Rainer@krugs.de Skype: RMkrug PGP: 0x0F52F982 [-- Attachment #2: signature.asc --] [-- Type: application/pgp-signature, Size: 454 bytes --] ^ permalink raw reply [flat|nested] 13+ messages in thread
* Re: two sets of default header arguments for one language 2015-09-10 13:54 two sets of default header arguments for one language Alan Schmitt 2015-09-10 21:00 ` Thomas S. Dye 2015-09-10 21:16 ` Rainer M Krug @ 2015-09-10 22:28 ` Charles C. Berry 2015-09-10 22:39 ` Charles C. Berry 2 siblings, 1 reply; 13+ messages in thread From: Charles C. Berry @ 2015-09-10 22:28 UTC (permalink / raw) To: Alan Schmitt; +Cc: emacs-orgmode [-- Attachment #1: Type: text/plain, Size: 1098 bytes --] On Thu, 10 Sep 2015, Alan Schmitt wrote: > Hello, > > I’m writing some lab exercises where I have a fairly long list of header > arguments for each source block. I know I can use language-specific > default arguments, but I need to switch between questions (short list): > > #+begin_src ocaml :tangle tp1.ml > > and answers > > #+begin_src ocaml :exports results :results verbatim drawer :post wrap-myres(text=*this*) :tangle tp1_ans.ml > > Is there a way to have two sets of default arguments for a given > language, or can I declare a new language just for the sake of different > arguments? > I'd use two new `languages'. For most uses, I think you can get away with as little as this: (defalias 'org-babel-execute:ocaml-a 'org-babel-execute:ocaml) (defalias 'org-babel-execute:ocaml-q 'org-babel-execute:ocaml) (defvar org-babel-default-header-args:ocaml-a '((:exports . "results") [fill in the rest] )) (defvar org-babel-default-header-args:ocaml-q '((:tangle . "tp1.ml"))) and have acceptable behavior without stepping on the original language. Untested, of course. HTH, Chuck ^ permalink raw reply [flat|nested] 13+ messages in thread
* Re: two sets of default header arguments for one language 2015-09-10 22:28 ` Charles C. Berry @ 2015-09-10 22:39 ` Charles C. Berry 2015-09-11 9:36 ` Alan Schmitt 0 siblings, 1 reply; 13+ messages in thread From: Charles C. Berry @ 2015-09-10 22:39 UTC (permalink / raw) To: Alan Schmitt; +Cc: emacs-orgmode [-- Attachment #1: Type: text/plain, Size: 1508 bytes --] One more thing ... On Thu, 10 Sep 2015, Charles C. Berry wrote: > On Thu, 10 Sep 2015, Alan Schmitt wrote: > >> Hello, >> >> I’m writing some lab exercises where I have a fairly long list of header >> arguments for each source block. I know I can use language-specific >> default arguments, but I need to switch between questions (short list): >> >> #+begin_src ocaml :tangle tp1.ml >> >> and answers >> >> #+begin_src ocaml :exports results :results verbatim drawer :post >> wrap-myres(text=*this*) :tangle tp1_ans.ml >> >> Is there a way to have two sets of default arguments for a given >> language, or can I declare a new language just for the sake of different >> arguments? >> > > I'd use two new `languages'. > > For most uses, I think you can get away with as little as this: > > (defalias 'org-babel-execute:ocaml-a 'org-babel-execute:ocaml) > (defalias 'org-babel-execute:ocaml-q 'org-babel-execute:ocaml) > > (defvar org-babel-default-header-args:ocaml-a > '((:exports . "results") [fill in the rest] )) > (defvar org-babel-default-header-args:ocaml-q > '((:tangle . "tp1.ml"))) > > > and have acceptable behavior without stepping on the original language. You also want to customize `org-src-lang-modes' to be able to edit the src code natively. > > Untested, of course. > > HTH, > > Chuck Charles C. Berry Dept of Family Medicine & Public Health cberry at ucsd edu UC San Diego / La Jolla, CA 92093-0901 http://famprevmed.ucsd.edu/faculty/cberry/ ^ permalink raw reply [flat|nested] 13+ messages in thread
* Re: two sets of default header arguments for one language 2015-09-10 22:39 ` Charles C. Berry @ 2015-09-11 9:36 ` Alan Schmitt 2015-09-14 14:39 ` Alan Schmitt 0 siblings, 1 reply; 13+ messages in thread From: Alan Schmitt @ 2015-09-11 9:36 UTC (permalink / raw) To: Charles C. Berry; +Cc: emacs-orgmode [-- Attachment #1: Type: text/plain, Size: 1053 bytes --] On 2015-09-11 00:39, "Charles C. Berry" <ccberry@ucsd.edu> writes: >>> Is there a way to have two sets of default arguments for a given >>> language, or can I declare a new language just for the sake of different >>> arguments? >>> >> >> I'd use two new `languages'. >> >> For most uses, I think you can get away with as little as this: >> >> (defalias 'org-babel-execute:ocaml-a 'org-babel-execute:ocaml) >> (defalias 'org-babel-execute:ocaml-q 'org-babel-execute:ocaml) >> >> (defvar org-babel-default-header-args:ocaml-a >> '((:exports . "results") [fill in the rest] )) >> (defvar org-babel-default-header-args:ocaml-q >> '((:tangle . "tp1.ml"))) >> >> >> and have acceptable behavior without stepping on the original language. > > > You also want to customize `org-src-lang-modes' to be able to edit the src > code natively. Very nice! I’ll give it a try. Thanks a lot, Alan -- OpenPGP Key ID : 040D0A3B4ED2E5C7 Last week athmospheric CO₂ average (Updated September 9, 2015, Mauna Loa Obs.): 377.86 ppm [-- Attachment #2: signature.asc --] [-- Type: application/pgp-signature, Size: 472 bytes --] ^ permalink raw reply [flat|nested] 13+ messages in thread
* Re: two sets of default header arguments for one language 2015-09-11 9:36 ` Alan Schmitt @ 2015-09-14 14:39 ` Alan Schmitt 0 siblings, 0 replies; 13+ messages in thread From: Alan Schmitt @ 2015-09-14 14:39 UTC (permalink / raw) To: Charles C. Berry; +Cc: emacs-orgmode [-- Attachment #1: Type: text/plain, Size: 1249 bytes --] On 2015-09-11 11:36, Alan Schmitt <alan.schmitt@polytechnique.org> writes: > On 2015-09-11 00:39, "Charles C. Berry" <ccberry@ucsd.edu> writes: > >>>> Is there a way to have two sets of default arguments for a given >>>> language, or can I declare a new language just for the sake of different >>>> arguments? >>>> >>> >>> I'd use two new `languages'. >>> >>> For most uses, I think you can get away with as little as this: >>> >>> (defalias 'org-babel-execute:ocaml-a 'org-babel-execute:ocaml) >>> (defalias 'org-babel-execute:ocaml-q 'org-babel-execute:ocaml) >>> >>> (defvar org-babel-default-header-args:ocaml-a >>> '((:exports . "results") [fill in the rest] )) >>> (defvar org-babel-default-header-args:ocaml-q >>> '((:tangle . "tp1.ml"))) >>> >>> >>> and have acceptable behavior without stepping on the original language. >> >> >> You also want to customize `org-src-lang-modes' to be able to edit the src >> code natively. > > Very nice! I’ll give it a try. Thanks a lot, I would like to report that this worked perfectly and out of the box. Thanks a lot! Alan -- OpenPGP Key ID : 040D0A3B4ED2E5C7 Last week athmospheric CO₂ average (Updated September 13, 2015, Mauna Loa Obs.): 397.77 ppm [-- Attachment #2: signature.asc --] [-- Type: application/pgp-signature, Size: 472 bytes --] ^ permalink raw reply [flat|nested] 13+ messages in thread
end of thread, other threads:[~2015-09-18 10:17 UTC | newest] Thread overview: 13+ messages (download: mbox.gz follow: Atom feed -- links below jump to the message on this page -- 2015-09-10 13:54 two sets of default header arguments for one language Alan Schmitt 2015-09-10 21:00 ` Thomas S. Dye 2015-09-11 9:30 ` Alan Schmitt 2015-09-10 21:16 ` Rainer M Krug 2015-09-10 21:25 ` Nicolas Goaziou 2015-09-11 7:09 ` Rainer M Krug 2015-09-11 9:33 ` Alan Schmitt 2015-09-11 16:27 ` Nicolas Goaziou 2015-09-18 10:17 ` Rainer M Krug 2015-09-10 22:28 ` Charles C. Berry 2015-09-10 22:39 ` Charles C. Berry 2015-09-11 9:36 ` Alan Schmitt 2015-09-14 14:39 ` Alan Schmitt
Code repositories for project(s) associated with this public inbox https://git.savannah.gnu.org/cgit/emacs/org-mode.git This is a public inbox, see mirroring instructions for how to clone and mirror all data and code used for this inbox; as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).