From mboxrd@z Thu Jan 1 00:00:00 1970 From: Neeum Zawan Subject: Re: Literate Programming - Continue a Source Block? Date: Wed, 08 Jun 2011 08:20:14 -0700 Message-ID: <87fwnkjqoh.fsf@fester.com> References: <87pqmokh6d.fsf@fester.com> <80k4cw22uf.fsf@somewhere.org> Mime-Version: 1.0 Content-Type: text/plain; charset=us-ascii Return-path: Received: from eggs.gnu.org ([140.186.70.92]:40420) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1QUKWj-0005Lg-JZ for emacs-orgmode@gnu.org; Wed, 08 Jun 2011 11:18:38 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1QUKWh-0000Jt-Qv for emacs-orgmode@gnu.org; Wed, 08 Jun 2011 11:18:37 -0400 Received: from lo.gmane.org ([80.91.229.12]:48142) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1QUKWg-0000Jm-FM for emacs-orgmode@gnu.org; Wed, 08 Jun 2011 11:18:35 -0400 Received: from list by lo.gmane.org with local (Exim 4.69) (envelope-from ) id 1QUKWf-0002wP-3Y for emacs-orgmode@gnu.org; Wed, 08 Jun 2011 17:18:33 +0200 Received: from c-71-237-233-41.hsd1.or.comcast.net ([71.237.233.41]) by main.gmane.org with esmtp (Gmexim 0.1 (Debian)) id 1AlnuQ-0007hv-00 for ; Wed, 08 Jun 2011 17:18:33 +0200 Received: from mailinglists by c-71-237-233-41.hsd1.or.comcast.net with local (Gmexim 0.1 (Debian)) id 1AlnuQ-0007hv-00 for ; Wed, 08 Jun 2011 17:18:33 +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 "Sebastien Vauban" writes: > Hi Neeum, > > Neeum Zawan wrote: >> With noweb, one can continue a source block that one started >> earlier. Can this not be done with Babel? >> >> If not, I'm struggling a little with how to do LP using Babel... > > Of course, this can be done here as well: simply reuse the same "tangle" > target (file), and blocks are concatenated in the order they appear. But this will only allow me to append to the end of the file (up to that point), correct? I want to append to a source block that may be in the middle. Consider the following example: (Begin-example) #+BABEL: :noweb yes * Outline The structure of the configuration file will be: #+srcname: outline #+begin_src emacs-lisp :tangle .emacs :exports code ;; Store configurations that impact appearance <> ;; Languages configurations <> ;; GNUS configurations <> #+end_src * General Appearance This section controls the general appearance (color of cursor, fonts, etc). #+srcname: visual-config #+begin_src emacs-lisp :exports code ;; Config here. #+end_src * GNUS configuration #+srcname: gnus-config #+begin_src emacs-lisp :exports code ;; Config here. #+end_src * Languages #+srcname: lang-config #+begin_src emacs-lisp :exports code <> <> #+end_src ** Python Now here's where the problem begins. I want to add some configurations that impact some Python settings. I can dump those in python-config. However, I also want to add some visual settings for python-mode (change font colors, etc). For whatever reason, I think that part should go into visual-config. How do I now append the relevant portion to visual-config while I'm in _this_ portion of the org document? (End-example) The above is somewhat artificial, but in a proper programming project something like this will occur frequently: A new feature will be added at some later point and I'll want to update various blocks of code. > Second solution: create one sole block that will be tangled, and which > contains your other blocks (using the <> syntax), in the order you want. I had thought of this, but I find it somewhat lacking. Consider my example above. I could have created a <> in my <> block. However: 1. That requires me to know I'm going to need it later when I write visual-config. 2. If I didn't know I'd need it, I'd have to continually modify various parts of the org document every time I add a new feature to my code. I find this suboptimal and error prone. 3. For me, one of the main motivations to do LP is to document the evolution of the project, such that someone else can read the document and understand. Part of this is that I want all aspects of a single feature to appear under a single heading. When the reader reads the document, he shouldn't have to see too many aspects of the code early on that will be explained much later in the document. Now the original noweb allows what I'm asking for. If you begin a source block with a name of an existing block but append an "=" symbol, it knows to append to that source block. It would be great if org-mode could add that capability. Another approach is that if multiple source blocks with the same name are found, the default behavior is to concatenate all those source blocks together (and then add a header option for overwrite if the user wanted to overwrite instead of append). Thoughts?