From mboxrd@z Thu Jan 1 00:00:00 1970 From: Rainer M Krug Subject: Re: Automatically adding local variables to tangled file Date: Wed, 5 Jun 2013 18:15:38 +0200 Message-ID: References: <878v2omz5g.fsf@krugs.de> <51af4bfd.0c95ec0a.2372.097e@mx.google.com> Mime-Version: 1.0 Content-Type: multipart/alternative; boundary=089e013c5d6e2a929904de6a829d Return-path: Received: from eggs.gnu.org ([2001:4830:134:3::10]:48468) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1UkGNB-0008CJ-Oh for emacs-orgmode@gnu.org; Wed, 05 Jun 2013 12:15:43 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1UkGN9-0007ii-64 for emacs-orgmode@gnu.org; Wed, 05 Jun 2013 12:15:41 -0400 Received: from mail-vb0-x232.google.com ([2607:f8b0:400c:c02::232]:46016) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1UkGN8-0007ie-Vm for emacs-orgmode@gnu.org; Wed, 05 Jun 2013 12:15:39 -0400 Received: by mail-vb0-f50.google.com with SMTP id w16so1220644vbb.23 for ; Wed, 05 Jun 2013 09:15:38 -0700 (PDT) In-Reply-To: <51af4bfd.0c95ec0a.2372.097e@mx.google.com> 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: Darlan Cavalcante Moreira Cc: emacs-orgmode , Rainer M Krug , Vitalie Spinu , Eric Schulte --089e013c5d6e2a929904de6a829d Content-Type: text/plain; charset=ISO-8859-1 On Wednesday, June 5, 2013, Darlan Cavalcante Moreira wrote: > > It's a good idea to have useful information in the tangled file that can > help these functions. But since org-mode can already tangle with comments > containing useful information, isn't this enough to detect that the file > is a tangled file? Yes and no. In regards to jumping to the source code, it would necessitate a searching in the text, but it would be much easier to have it in a file local variable. This is more standardized then a comment. > > On the other hand, a local variable in the tangled files to set the buffer > to read-only could be very useful to avoid the mistake of editing the > tangled files directly. My reasoning - and I would make all tangled R files read only. Cheers, Rainer > > -- > Darlan > > At Wed, 05 Jun 2013 16:04:59 +0200, > Rainer M Krug wrote: > > > > Hi > > > > 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) > > | > > | (defun org-babel-mark-file-as-tangled () > > | (add-file-local-variable 'org-babel-tangled-file t) > > | (basic-save-buffer)) > > | > > | (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: > > > > - nil :: (default) do not add anything > > - t :: org-babel-tangled-file is added as t to the tangled files > > - "name" :: org-babel-tangled-file is set to the org file name > > - "path" :: org-babel-tangled-file is set to the path of the org file > > - "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 > > > > -- > > 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 > -- 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 (F): +33 - (0)9 58 10 27 44 Fax (D): +49 - (0)3 21 21 25 22 44 email: Rainer@krugs.de Skype: RMkrug --089e013c5d6e2a929904de6a829d Content-Type: text/html; charset=ISO-8859-1 Content-Transfer-Encoding: quoted-printable

On Wednesday, June 5, 2013, Darlan Cavalcante Moreira wrote:

It's a good idea to have useful information in the tangled file that ca= n
help these functions. But since org-mode can already tangle with comments containing useful information, isn't this enough to detect that the fil= e
is a tangled file?

Yes and no. In regards t= o jumping to the source code, it would necessitate a searching in the text,= but it would be much easier to have it in a file local variable. This is m= ore standardized then a comment.
=A0

On the other hand, a local variable in the tangled files to set the buffer<= br> to read-only could be very useful to avoid the mistake of editing the
tangled files directly.

My reasoning - and = I would make all tangled R files read only.

Cheers= ,

Rainer
=A0

--
Darlan

At Wed, 05 Jun 2013 16:04:59 +0200,
Rainer M Krug wrote:
>
> Hi
>
> 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<= br> > 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-o= rg
> 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<= br> > mode file?
>
> He added the following to his config file to test the approach:
>
> ,----
> | =A0(defvar org-babel-tangled-file nil
> | =A0 =A0 =A0"If non-nill, current file was tangled with org-babe= l-tangle")
> | =A0 =A0(put 'org-babel-tangled-file 'safe-local-variable = 9;booleanp)
> |
> | =A0 =A0(defun org-babel-mark-file-as-tangled ()
> | =A0 =A0 =A0(add-file-local-variable 'org-babel-tangled-file t) > | =A0 =A0 =A0(basic-save-buffer))
> |
> | =A0 =A0(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 v= ia
> 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<= br> > can have the following values:
>
> - nil :: (default) do not add anything
> - t :: org-babel-tangled-file is added as t to the tangled files
> - "name" :: org-babel-tangled-file is set to the org file na= me
> - "path" :: org-babel-tangled-file is set to the path of the= org file
> - "all" :: org-babel-tangled-file is set to the full name in= cluding path
> =A0 =A0 =A0 =A0 =A0 =A0of 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
>
> --
> Rainer M. Krug, PhD (Conservation Ecology, SUN), MSc (Conservation Bio= logy, UCT), Dipl. Phys. (Germany)
>
> Centre of Excellence for Invasion Biology
> Stellenbosch University
> South Africa
>
> Tel : =A0 =A0 =A0 +33 - (0)9 53 10 27 44
> Cell: =A0 =A0 =A0 +33 - (0)6 85 62 59 98
> Fax : =A0 =A0 =A0 +33 - (0)9 58 10 27 44
>
> Fax (D): =A0 =A0+49 - (0)3 21 21 25 22 44
>
> email: =A0 =A0 =A0Rainer@krugs.de
>
> Skype: =A0 =A0 =A0RMkrug


--
Rainer M. Krug, PhD (Conservation Ecology, SUN)= , MSc (Conservation Biology, UCT), Dipl. Phys. (Germany)

Centre of E= xcellence for Invasion Biology
Stellenbosch University
South Africa
Tel : =A0 =A0 =A0 +33 - (0)9 53 10 27 44
Cell: =A0 =A0 =A0 +33 - (0)= 6 85 62 59 98
Fax (F): =A0 =A0 =A0 +33 - (0)9 58 10 27 44

Fax (D)= : =A0 =A0+49 - (0)3 21 21 25 22 44

email: =A0 =A0 =A0Rainer@krugs.de

Skype: =A0 =A0 =A0RMkrug

--089e013c5d6e2a929904de6a829d--