From mboxrd@z Thu Jan 1 00:00:00 1970 From: Charles Berry Subject: Re: accessing source block header arguments from exporters Date: Fri, 10 Apr 2015 22:17:42 +0000 (UTC) Message-ID: References: <55282A05.8040203@roklein.de> Mime-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Transfer-Encoding: 7bit Return-path: Received: from eggs.gnu.org ([2001:4830:134:3::10]:35097) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1YghFP-0003Ft-Mm for emacs-orgmode@gnu.org; Fri, 10 Apr 2015 18:18:01 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1YghFM-00078m-Fb for emacs-orgmode@gnu.org; Fri, 10 Apr 2015 18:17:59 -0400 Received: from plane.gmane.org ([80.91.229.3]:47513) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1YghFM-00078a-8K for emacs-orgmode@gnu.org; Fri, 10 Apr 2015 18:17:56 -0400 Received: from list by plane.gmane.org with local (Exim 4.69) (envelope-from ) id 1YghFI-0003zF-UO for emacs-orgmode@gnu.org; Sat, 11 Apr 2015 00:17:53 +0200 Received: from 137.110.38.143 ([137.110.38.143]) by main.gmane.org with esmtp (Gmexim 0.1 (Debian)) id 1AlnuQ-0007hv-00 for ; Sat, 11 Apr 2015 00:17:52 +0200 Received: from ccberry by 137.110.38.143 with local (Gmexim 0.1 (Debian)) id 1AlnuQ-0007hv-00 for ; Sat, 11 Apr 2015 00:17:52 +0200 List-Id: "General discussions about Org-mode." List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: emacs-orgmode-bounces+geo-emacs-orgmode=m.gmane.org@gnu.org Sender: emacs-orgmode-bounces+geo-emacs-orgmode=m.gmane.org@gnu.org To: emacs-orgmode@gnu.org Robert Klein roklein.de> writes: > > Hi, > > is there a way, to read header arguments to source blocks in the > exporters org--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