From mboxrd@z Thu Jan 1 00:00:00 1970 From: Dr Rainer M Krug Subject: Re: [BABEL] tangling with leaving non-source code lines as empty lines? Date: Tue, 13 Jul 2010 09:47:31 +0200 Message-ID: <4C3C1A13.506@googlemail.com> References: <871vb8lgoq.fsf@gmail.com> Mime-Version: 1.0 Content-Type: text/plain; charset=ISO-8859-1 Content-Transfer-Encoding: 7bit Return-path: Received: from [140.186.70.92] (port=38877 helo=eggs.gnu.org) by lists.gnu.org with esmtp (Exim 4.43) id 1OYaDa-0005Pz-Ct for emacs-orgmode@gnu.org; Tue, 13 Jul 2010 03:50:04 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.69) (envelope-from ) id 1OYaDL-0002ru-LF for emacs-orgmode@gnu.org; Tue, 13 Jul 2010 03:47:41 -0400 Received: from mail-ww0-f49.google.com ([74.125.82.49]:59694) by eggs.gnu.org with esmtp (Exim 4.69) (envelope-from ) id 1OYaDL-0002rZ-B2 for emacs-orgmode@gnu.org; Tue, 13 Jul 2010 03:47:39 -0400 Received: by wwb39 with SMTP id 39so869819wwb.30 for ; Tue, 13 Jul 2010 00:47:37 -0700 (PDT) In-Reply-To: <871vb8lgoq.fsf@gmail.com> 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: emacs-orgmode -----BEGIN PGP SIGNED MESSAGE----- Hash: SHA1 Hi Eric, On Mon, Jul 12, 2010 at 8:04 PM, Eric Schulte wrote: > Hi Rainer, > > If I'm understand you correctly you want the absolute position (by LOC) > of the lines of R code to be the same in both the original org file and > the tangled file or R code. That's right - that's what I was thinking about. > I don't think this is possible. It is > possible to tangle code blocks in any order (not just the order in which > they appear in the original org file), so there are many valid tangling > scenarios in which this feature could not work. > Accepted - under these circumstances it would only concern a special case where the whole file is tangled in order to another R file. I agree, that other solutions would be more useful - please see comments below. > Rather, I think that it may make sense to have a function for jumping > back and forth between tangled code blocks and the related Org file. In > that case the R errors could be followed to the tangled R code file, > from which you could easily jump to the relevant line in the relevant > code block in the Org file. That sounds perfect to me. > If you are tangling with comments, then it > should be possible to have a function called from a line in a tangled > code file which when called > > 1) finds it's enclosing comments > 2) remembers it's offset from the comments (which would then be it's > offset in the code block in the Org file) > 3) read the comment to learn which code block in which Org file it's > tangled from > 4) jump to the relevant line, in the relevant block, in the relevant > file > > That would be really be useful for literate programming and the following debugging. > Similarly when called form within a code block in an Org file the > function could > > 1) read it's header argument to find the relevant tangled code file > 2) jump to that file > 3) use the comments in that file to move to the appropriate section of > code and related line > Also quite useful, although I don't see an immediate use for this, as the code file is dynamic, and changing it would not make much sense (unless, and now I am probably dreaming, one could sync the changes back into the .org file into the blocks. In that way, one could debug the code file as one would a normal code file and sync it, after it is working, back into the .org file. Comments could be used to define the blocks. Although, I guess that could cause problems with more advanced features on babel, which I am not using (yet?).) Another important aspect of a function lie that could be to be able to type in the line number in the code file (from e.g. an error message) and to jump to the corresponding line in the .org file. That would directly address my suggestion above in a MUCH more elegant and efficient way. > I'll think about such a function, and if it makes sense to implement it > apart from a more general "activate org-mode links in comments" minor > mode. Any ideas or suggestions would be welcome! > I think that both functions would be extremely useful. The one outlined above as a tool for debugging and the "links in org-mode comments" as kind of backward linking documentation. Let me know if you have anything you want me to test. Cheers, Rainer > > Thanks -- Eric > > Rainer M Krug writes: > > > Hi Eric, > > > > would it be possible, when tangling, to leave lines without source code > in > > the resulting code file as empty lines? The reasoning would be that error > > messages (at least in R) give the line in which the error occurred. If > the > > line numbers in which the code sits would be preserved (by leaving empty > > lines where no code is in the .org file), debugging would be much easier. > > > > By the way: I am using the after tangle hook and it works absolutely > > perfectly. > > > > Thanks and cheers, > > > > Rainer > - -- NEW GERMAN FAX NUMBER!!! Rainer M. Krug, PhD (Conservation Ecology, SUN), MSc (Conservation Biology, UCT), Dipl. Phys. (Germany) Centre of Excellence for Invasion Biology Natural Sciences Building Office Suite 2039 Stellenbosch University Main Campus, Merriman Avenue Stellenbosch South Africa Cell: +27 - (0)83 9479 042 Fax: +27 - (0)86 516 2782 Fax: +49 - (0)321 2125 2244 email: Rainer@krugs.de Skype: RMkrug Google: R.M.Krug@gmail.com -----BEGIN PGP SIGNATURE----- Version: GnuPG v1.4.10 (GNU/Linux) Comment: Using GnuPG with Mozilla - http://enigmail.mozdev.org/ iEYEARECAAYFAkw8GhMACgkQoYgNqgF2egqtdQCfY9TTM9MRWftZHEQhbA4zLqMe qZ8AnjT2p3hRf/vr+lMTCbe9djOk7HAC =i/Z5 -----END PGP SIGNATURE-----