From mboxrd@z Thu Jan 1 00:00:00 1970 From: "Eric Schulte" Subject: Re: [babel] Painless integration of source blocks with language Date: Sun, 16 Jan 2011 08:31:03 -0700 Message-ID: <87hbd8kgqw.fsf@gmail.com> References: <87lj2ukfia.fsf@gmail.com> <87k4icegwl.fsf@ucl.ac.uk> <87wrmbwdsm.fsf@gmail.com> <87aaj5tbgl.fsf@ucl.ac.uk> <87bp3ka458.fsf@gmail.com> Mime-Version: 1.0 Content-Type: text/plain Return-path: Received: from [140.186.70.92] (port=36499 helo=eggs.gnu.org) by lists.gnu.org with esmtp (Exim 4.43) id 1PeUZY-0003Yi-RD for emacs-orgmode@gnu.org; Sun, 16 Jan 2011 10:31:18 -0500 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1PeUZV-0000Ax-Ex for emacs-orgmode@gnu.org; Sun, 16 Jan 2011 10:31:14 -0500 Received: from mail-iw0-f169.google.com ([209.85.214.169]:49057) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1PeUZV-0000Ag-B3 for emacs-orgmode@gnu.org; Sun, 16 Jan 2011 10:31:13 -0500 Received: by iwn40 with SMTP id 40so4480232iwn.0 for ; Sun, 16 Jan 2011 07:31:12 -0800 (PST) In-Reply-To: (Seth Burleigh's message of "Thu, 13 Jan 2011 17:44:19 -0600") List-Id: "General discussions about Org-mode." List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Sender: emacs-orgmode-bounces+geo-emacs-orgmode=m.gmane.org@gnu.org Errors-To: emacs-orgmode-bounces+geo-emacs-orgmode=m.gmane.org@gnu.org To: Seth Burleigh Cc: emacs-orgmode@gnu.org Seth Burleigh writes: >>As for how to trace back through noweb links, the best option seem to be >>using the existing jump function to navigate from raw source to the >>embedded block, keeping track of the point's offset form the beginning >>of the block, then using `org-babel-expand-src-block' to expand the body >>of the embedded code block marking noweb references with text properties >>as they are inserted into the expanding body, and then using the point >>offset to place the point into the appropriate noweb reference. This >>process could then recurse on the embedded noweb code block until it >>ends up in a non-noweb portion of an expanded code block body. > > If you dont have any comment anchors in the text, how would you know which > noweb block you are in? If your org file and raw files are synched, then > you could, but if they become unsynched, which is the way it should be > (change raw code until done, then detangle to org), i dont exactly see how > you can do it. > Yea, I think you're right. I can't come up with any way of marking or remembering the boundaries of noweb reference sections without inserting comment wrappers around such sections. I've just pushed up a new header argument combination ":comments noweb" which will wrap all embedded noweb sections in link comments, as demonstrated in the following example. Hopefully this should be sufficient for a complete mapping from a pure code file back to the original org-mode file. #+source: wrappable #+begin_src emacs-lisp (setq x (+ 4 x)) #+end_src #+begin_src emacs-lisp :comments noweb :noweb yes :tangle yes (let ((x 1)) (message "x=%s" x) <> (message "x=%s" x)) #+end_src which tangles out the following emacs-lisp #+begin_src emacs-lisp ;; [[file:~/src/babel-dev/scraps.org::*wrap%20noweb%20references%20in%20comments][wrap-noweb-references-in-comments:2]] (let ((x 1)) (message "x=%s" x) ;; [[file:~/src/babel-dev/scraps.org::*wrap%20noweb%20references%20in%20comments][wrappable]] (setq x (+ 4 x)) ;; wrappable ends here (message "x=%s" x)) ;; wrap-noweb-references-in-comments:2 ends here #+end_src Cheers -- Eric