emacs-orgmode@gnu.org archives
 help / color / mirror / code / Atom feed
* Automatically adding local variables to tangled file
@ 2013-06-05 14:04 Rainer M Krug
  2013-06-05 14:32 ` Darlan Cavalcante Moreira
  2013-06-05 17:10 ` Thorsten Jolitz
  0 siblings, 2 replies; 25+ messages in thread
From: Rainer M Krug @ 2013-06-05 14:04 UTC (permalink / raw)
  To: Eric Schulte; +Cc: Vitalie Spinu, emacs-orgmode

[-- Attachment #1: Type: text/plain, Size: 2768 bytes --]

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

[-- Attachment #2: Type: application/pgp-signature, Size: 489 bytes --]

^ permalink raw reply	[flat|nested] 25+ messages in thread

end of thread, other threads:[~2013-06-13  7:28 UTC | newest]

Thread overview: 25+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2013-06-05 14:04 Automatically adding local variables to tangled file Rainer M Krug
2013-06-05 14:32 ` Darlan Cavalcante Moreira
2013-06-05 15:41   ` Vitalie Spinu
2013-06-05 16:15   ` Rainer M Krug
2013-06-06  7:53   ` Sebastien Vauban
2013-06-06 16:01   ` Eric Schulte
2013-06-07  7:57     ` Rainer M Krug
2013-06-07  8:32       ` Rainer M Krug
2013-06-07 10:57         ` [PATCH] Don't ask "File changed on disk" in org-babel-post-tangle-hook Vitalie Spinu
2013-06-07 13:23           ` Eric Schulte
2013-06-07 13:47             ` Rainer M Krug
2013-06-08 18:23       ` Automatically adding local variables to tangled file Eric Schulte
2013-06-08 20:59         ` Achim Gratz
2013-06-08 21:17           ` Eric Schulte
2013-06-10  8:02         ` Rainer M Krug
2013-06-10 10:12           ` Problem in tangle-mode -- WAS: " Rainer M Krug
2013-06-10 15:58             ` Eric Schulte
2013-06-11  7:25               ` BUG - Problem in tangle-mode Rainer M Krug
2013-06-11 13:09                 ` Eric Schulte
2013-06-11 18:25                   ` Rainer M Krug
2013-06-12 15:15                     ` Rainer M Krug
2013-06-12 21:42                       ` Eric Schulte
2013-06-13  7:28                         ` Rainer M Krug
2013-06-10 11:32     ` SOLVED: Automatically adding local variables to tangled file Rainer M Krug
2013-06-05 17:10 ` Thorsten Jolitz

Code repositories for project(s) associated with this public inbox

	https://git.savannah.gnu.org/cgit/emacs/org-mode.git

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).