From mboxrd@z Thu Jan 1 00:00:00 1970 From: Rainer M Krug Subject: Automatically adding local variables to tangled file Date: Wed, 05 Jun 2013 16:04:59 +0200 Message-ID: <878v2omz5g.fsf@krugs.de> Mime-Version: 1.0 Content-Type: multipart/signed; boundary="=-=-="; micalg=pgp-sha1; protocol="application/pgp-signature" Return-path: Received: from eggs.gnu.org ([2001:4830:134:3::10]:33724) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1UkEKv-0003H1-Jj for emacs-orgmode@gnu.org; Wed, 05 Jun 2013 10:05:19 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1UkEKs-00013j-43 for emacs-orgmode@gnu.org; Wed, 05 Jun 2013 10:05:13 -0400 Received: from mail-we0-x232.google.com ([2a00:1450:400c:c03::232]:36931) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1UkEKr-00013T-Ul for emacs-orgmode@gnu.org; Wed, 05 Jun 2013 10:05:10 -0400 Received: by mail-we0-f178.google.com with SMTP id u53so1358520wes.9 for ; Wed, 05 Jun 2013 07:05:08 -0700 (PDT) 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: Eric Schulte Cc: Vitalie Spinu , emacs-orgmode --=-=-= Content-Type: text/plain Content-Transfer-Encoding: quoted-printable Hi=20 I am trying to improve my workflow of literate programming of R in org. My org file is tangled into many R files and I am using ESS to debug. If an error occurs, I can jump via ESS to the .R file, and in a second step via calling org-babel-tangle-jump-to-org into the org file where the buggy line sits. Now this is error prone, as one (or is it only me?) is easily tempted to edit the R file which is reverted after the next tangle. So I was thinking: what about calling org-babel-tangle-jump-to-org directly from ESS. Vitalie Spinu looked into this option, and came up with = the following suggestion: If the tangled .R file contains a local variable, one could easily identify that it is a tangled file and call org-babel-tangle-jump-to-org and would be at the line causing the error. Therefore my question: Would it be possible and reasonable, to add a local variable to each tangled file which identifies the file as an file tangled from an org mode file? He added the following to his config file to test the approach: ,---- | (defvar org-babel-tangled-file nil | "If non-nill, current file was tangled with org-babel-tangle") | (put 'org-babel-tangled-file 'safe-local-variable 'booleanp) |=20=20=20=20 | (defun org-babel-mark-file-as-tangled () | (add-file-local-variable 'org-babel-tangled-file t) | (basic-save-buffer)) |=20 | (add-hook 'org-babel-post-tangle-hook 'org-babel-mark-file-as-tangled) `---- and he also already added automatic redirection to the org mode file via org-babel-tangle-jump-to-org to ESS on SVN. To keep backwards compatibility, a variable org-babel-tangle-add-tangled-file-variable could be introduced, which can have the following values: =2D nil :: (default) do not add anything =2D t :: org-babel-tangled-file is added as t to the tangled files =2D "name" :: org-babel-tangled-file is set to the org file name =2D "path" :: org-babel-tangled-file is set to the path of the org file =2D "all" :: org-babel-tangled-file is set to the full name including path of the org file I can even imagine many more possibilities for the use of local file variables to store meta data in the tangled file (VCS info comes to mind, which would enable one to even go back to older revisions based on the tangled code rather easily). Cheers, Rainer =2D-=20 Rainer M. Krug, PhD (Conservation Ecology, SUN), MSc (Conservation Biology,= UCT), Dipl. Phys. (Germany) Centre of Excellence for Invasion Biology Stellenbosch University South Africa Tel : +33 - (0)9 53 10 27 44 Cell: +33 - (0)6 85 62 59 98 Fax : +33 - (0)9 58 10 27 44 Fax (D): +49 - (0)3 21 21 25 22 44 email: Rainer@krugs.de Skype: RMkrug --=-=-= Content-Type: application/pgp-signature -----BEGIN PGP SIGNATURE----- Version: GnuPG v1.4.12 (GNU/Linux) iQEcBAEBAgAGBQJRr0WLAAoJENvXNx4PUvmCT/cIAM5fcE/1Z3n+2qbE29Xe094W b5+R0haEG6PAawcfF9eRJNcRIZI2lHkRwB7kvTVlFF6dexa/e0JWfX1iGFlf+k+w lYkVw7G4EvrIRYJkH2YWt1LB+QOxAPFx7s+veDd86ivgnstOfWqmN7zMmizkIyZu NZIshIkjnE2WCsbt4epWe7BFCl/hPiunMa3Sk6E+WBkiQOibF9OxXF+wQCVzm1JK BOGfEFRmzPeXq6+S0bPdci4Pb+AcOBropM9Ddqn/trP67N+93k4Q72mLc2e/DfWi fUuFa7BsSjlXyV9Xks1fqePw5WvzdzSsmfID3NPK9J1yTVHZURt+9Kg+w6sFcEc= =TF1/ -----END PGP SIGNATURE----- --=-=-=--