Re: Source Block header arguments
On Thu, Feb 18, 2021 at 07:10:52PM +0800, Timothy wrote: > > Hi Russel, > > Russell Adams writes: > > > I know I can easily create templates for frequently used code blocks. > > > > My question is, is there a completion or in-place documentation for > > valid header arguments to code blocks? The options are rather buried > > in the manual. > > As it so happens, I have had the exact same annoyance. > > My solution was using snippets, you can see the details by looking at: > + https://tecosaur.github.io/emacs-config/config.html#snippet-helpers > + https://tecosaur.github.io/emacs-config/config.html#snippets-org-mode That is interesting. That's kind of what I was thinking could already be implemented without my knowing. ;] Maybe we need to buff the block insertion code? -- Russell Adamsrlad...@adamsinfoserv.com PGP Key ID: 0x1160DCB3 http://www.adamsinfoserv.com/ Fingerprint:1723 D8CA 4280 1EC9 557F 66E8 1154 E018 1160 DCB3
Re: Source Block header arguments
On Thu, Feb 18, 2021 at 11:08:32AM +0800, Ihor Radchenko wrote: > Russell Adams writes: > > > I know I can easily create templates for frequently used code blocks. > > > > My question is, is there a completion or in-place documentation for > > valid header arguments to code blocks? The options are rather buried > > in the manual. > > I use helm-info-org for this. I have helm, and never saw this. Good tip! -- Russell Adamsrlad...@adamsinfoserv.com PGP Key ID: 0x1160DCB3 http://www.adamsinfoserv.com/ Fingerprint:1723 D8CA 4280 1EC9 557F 66E8 1154 E018 1160 DCB3
Re: Source Block header arguments
Hi Russel, Russell Adams writes: > I know I can easily create templates for frequently used code blocks. > > My question is, is there a completion or in-place documentation for > valid header arguments to code blocks? The options are rather buried > in the manual. As it so happens, I have had the exact same annoyance. My solution was using snippets, you can see the details by looking at: + https://tecosaur.github.io/emacs-config/config.html#snippet-helpers + https://tecosaur.github.io/emacs-config/config.html#snippets-org-mode I hope that might be of some help/interest :) -- Timothy
Re: Source Block header arguments
Russell Adams writes: > I know I can easily create templates for frequently used code blocks. > > My question is, is there a completion or in-place documentation for > valid header arguments to code blocks? The options are rather buried > in the manual. I use helm-info-org for this. Best, Ihor
Source Block header arguments
I know I can easily create templates for frequently used code blocks. My question is, is there a completion or in-place documentation for valid header arguments to code blocks? The options are rather buried in the manual. -- Russell Adamsrlad...@adamsinfoserv.com PGP Key ID: 0x1160DCB3 http://www.adamsinfoserv.com/ Fingerprint:1723 D8CA 4280 1EC9 557F 66E8 1154 E018 1160 DCB3
Re: [O] accessing source block header arguments from exporters
I agree with Not exactly. In this post http://kitchingroup.cheme.cmu.edu/blog/2014/09/22/Showing-what-data-went-into-a-code-block-on-export/ I did something where I wanted to get information about the variables passed into a block and show that on export. You might get some inspiration from that. The result is at http://kitchingroup.cheme.cmu.edu/media/2014-09-22-Showing-what-data-went-into-a-code-block-on-export/custom-src-table-export-3.html Charles Berry writes: Robert Klein roklein at roklein.de writes: Hi, is there a way, to read header arguments to source blocks in the exporters org-exporter-src-block funktions? Not directly. org-babel-exp-code has no provision for headers. They get dropped. E.g. is there a way to access :firstline in the example below? Not exactly, but ... If you precede the code block with #+attr_firstline: 23 then with point in the src block (org-element-property :attr_firstline (org-element-context)) will return (23). And org-*-src-block functions can use it. If you really want to use the :firstline idiom, you can add a hook in `org-export-before-processing-hook' to find :firstline headers and insert #+attr_firstline lines in the buffer copy that the exporter is using. #+begin_src c++ -n :firstline 23 static struct { char*entity; unsigned char equiv; } entities[] = { { lt, '' } , { gt, '' } , { amp, '' } , { quot, '' } , { trade,153 } , /* trade mark */ #+end_src I didn't find it in the `element' structure. However, if I use #+begin_src c++ firstline=23 // random C++ #+end_src I could access :parameters from `element' and parse the string. However I'm not sure if I'd break some babel stuff or not. C-c C-v C-i on that src block shows that 'firstline=23' is treated as a switch by babel. So if there is any language that tries to use that as a switch (or has a regexp that matches it), there could be trouble. But in C it looks innocuous. If I'm trying to implement a firstline feature -- source blocks with new line numbering (-n) beginning at a given line number -- I'd prefer to use :firstline, but I didn't find anything to suggest `:XXX ZZ' header arguments to source blocks are available to the exporters. HTH, Chuck -- Professor John Kitchin Doherty Hall A207F Department of Chemical Engineering Carnegie Mellon University Pittsburgh, PA 15213 412-268-7803 @johnkitchin http://kitchingroup.cheme.cmu.edu
[O] accessing source block header arguments from exporters
Hi, is there a way, to read header arguments to source blocks in the exporters org-exporter-src-block funktions? E.g. is there a way to access :firstline in the example below? #+begin_src c++ -n :firstline 23 static struct { char*entity; unsigned char equiv; } entities[] = { { lt, '' } , { gt, '' } , { amp, '' } , { quot, '' } , { trade,153 } , /* trade mark */ #+end_src I didn't find it in the `element' structure. However, if I use #+begin_src c++ firstline=23 // random C++ #+end_src I could access :parameters from `element' and parse the string. However I'm not sure if I'd break some babel stuff or not. If I'm trying to implement a firstline feature -- source blocks with new line numbering (-n) beginning at a given line number -- I'd prefer to use :firstline, but I didn't find anything to suggest `:XXX ZZ' header arguments to source blocks are available to the exporters. Any advice? Thank you very much Robert
Re: [O] accessing source block header arguments from exporters
Robert Klein roklein at roklein.de writes: Hi, is there a way, to read header arguments to source blocks in the exporters org-exporter-src-block funktions? Not directly. org-babel-exp-code has no provision for headers. They get dropped. E.g. is there a way to access :firstline in the example below? Not exactly, but ... If you precede the code block with #+attr_firstline: 23 then with point in the src block (org-element-property :attr_firstline (org-element-context)) will return (23). And org-*-src-block functions can use it. If you really want to use the :firstline idiom, you can add a hook in `org-export-before-processing-hook' to find :firstline headers and insert #+attr_firstline lines in the buffer copy that the exporter is using. #+begin_src c++ -n :firstline 23 static struct { char*entity; unsigned char equiv; } entities[] = { { lt, '' } , { gt, '' } , { amp, '' } , { quot, '' } , { trade,153 } , /* trade mark */ #+end_src I didn't find it in the `element' structure. However, if I use #+begin_src c++ firstline=23 // random C++ #+end_src I could access :parameters from `element' and parse the string. However I'm not sure if I'd break some babel stuff or not. C-c C-v C-i on that src block shows that 'firstline=23' is treated as a switch by babel. So if there is any language that tries to use that as a switch (or has a regexp that matches it), there could be trouble. But in C it looks innocuous. If I'm trying to implement a firstline feature -- source blocks with new line numbering (-n) beginning at a given line number -- I'd prefer to use :firstline, but I didn't find anything to suggest `:XXX ZZ' header arguments to source blocks are available to the exporters. HTH, Chuck