From mboxrd@z Thu Jan 1 00:00:00 1970 From: Daniele Pizzolli Subject: Re: example filter for code blocks? Date: Thu, 26 Sep 2013 10:40:46 +0200 Message-ID: <5243F30E.4070200@toel.it> References: Mime-Version: 1.0 Content-Type: text/plain; charset=UTF-8; format=flowed Content-Transfer-Encoding: 7bit Return-path: Received: from eggs.gnu.org ([2001:4830:134:3::10]:42114) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1VP78J-0008Rb-35 for emacs-orgmode@gnu.org; Thu, 26 Sep 2013 04:41:18 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1VP789-00004x-Pw for emacs-orgmode@gnu.org; Thu, 26 Sep 2013 04:41:11 -0400 Received: from relay3-d.mail.gandi.net ([217.70.183.195]:42183) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1VP789-0008WL-If for emacs-orgmode@gnu.org; Thu, 26 Sep 2013 04:41:01 -0400 In-Reply-To: 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: John Kitchin Cc: emacs-orgmode@gnu.org John Kitchin wrote: >Hi everyone, > >I have an idea for putting links in a pdf that would open python code >blocks in an editor. To do that, I need to modify what happens when an >org-file is published to latex. Hello John, Few days ago, I did some research on the general problem: - not python specific (code agnostic) - not latex specific (export back-end agnostic) Unfortunately I ended up only for specific parts, but hope that can be useful starting points. I think that the ability to attach code blocks in a easy and general way can be a nice improvement. >Essentially I want it to do exactly what it already does in terms of >running pygments, and making nicely formatted and syntax highlighted >code blocks and output. >After that though, I want to tangle the code block to a file in a >directory, and insert a new link after the rendered code block. I >would prefer not to have to put :tangle headings in each code block >because there are many (e.g. hundreds) of them in course notes. >sufficient if they were just sequentially numbered as dir/1.py, >dir/2.py, etc... and it is fine if these get overwritten on each >export. If can live with a different file per section instead of per code block you can group the common setting, eg: :PROPERTIES: :header-args: octave :session *octave-sess* :exports both :results output :tangle lab1-ex1.m :END: >the link that would go after the code block in the latex export would >be something like: \LaunchPython{dir/1.py}{Open code} >Then clicking on it would open dir/1.py in whatever editor your >system is configured for. \LaunchPython is a newcommand I have >defined that works already. My hack with limited use to latex and html (and probably will not copy the tangled file with html publish) is: #+LATEX_HEADER: \usepackage{attachfile} #+MACRO: embed-matlab @@latex:\textattachfile[mimetype=text/x-matlab,color=0 0 0.5]{$1}{$1}@@ @@html:$1@@ #+NAME: code:2 #+BEGIN_SRC octave x = 1:10 #+END_SRC Snippets of octave source code for this exercise {{{embed-matlab(lab1-ex1.m)}}} >It seems like the new export engine should make this easy to do, but >I am not sure where to start. Could anyone point me to a starting >place? Thanks! I only have limited lisp knowledge, but I am interested as well in pointers for a general solution. Regards, Daniele