all messages for Emacs-related lists mirrored at yhetil.org
 help / color / mirror / code / Atom feed
* org-babel-tangle tangles too much !
@ 2009-12-01 14:54 Nicolas Girard
  2009-12-01 15:43 ` Thomas S. Dye
                   ` (3 more replies)
  0 siblings, 4 replies; 8+ messages in thread
From: Nicolas Girard @ 2009-12-01 14:54 UTC (permalink / raw)
  To: emacs-orgmode

Hi,
I can't get tangle to work the way I want.
Given a file f.org which contains

=====
#+srcname: a
#+begin_src emacs-lisp
(a)
#+end_src

#+srcname: b
#+begin_src emacs-lisp
<<a>>
(b)
#+end_src
=====

I would like (a) to appear only once in the tangled file f.el.
All I could get is, that either (a) appears twice (default behaviour),
or (a) doesn't appear at all when I append ":tangle no" to #+srcname:
a.

Any thoughts ?

-- 
Nicolas

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

* Re: org-babel-tangle tangles too much !
  2009-12-01 14:54 org-babel-tangle tangles too much ! Nicolas Girard
@ 2009-12-01 15:43 ` Thomas S. Dye
  2009-12-01 15:53 ` Eric Schulte
                   ` (2 subsequent siblings)
  3 siblings, 0 replies; 8+ messages in thread
From: Thomas S. Dye @ 2009-12-01 15:43 UTC (permalink / raw)
  To: Nicolas Girard; +Cc: emacs-orgmode


[-- Attachment #1.1: Type: text/plain, Size: 1137 bytes --]

Hi Nicolas,

On Dec 1, 2009, at 4:54 AM, Nicolas Girard wrote:

> Hi,
> I can't get tangle to work the way I want.
> Given a file f.org which contains
>
> =====
> #+srcname: a
> #+begin_src emacs-lisp
> (a)
> #+end_src
>
> #+srcname: b
> #+begin_src emacs-lisp
> <<a>>
> (b)
> #+end_src
> =====
>
> I would like (a) to appear only once in the tangled file f.el.
> All I could get is, that either (a) appears twice (default behaviour),
> or (a) doesn't appear at all when I append ":tangle no" to #+srcname:
> a.
>
> Any thoughts ?

Your code snippet doesn't tangle at all here.  Perhaps you have a  
setting somewhere that has an effect on tangling?

This one does tangle:

* Nicolas Girard
#+srcname: a
#+begin_src emacs-lisp
(a)
#+end_src

#+srcname: b
#+begin_src emacs-lisp :tangle test.el
<<a>>
(b)
#+end_src

It yields:

;; generated by org-babel-tangle
;; [[file:~/Public/projects/worg/Worg/babel-doc/test.org::*Nicolas 
%20Girard][b]]
(a)
(b)
;; b ends here

Is this what you're after?

HTH,
Tom


Thomas S. Dye, Ph.D.
T. S. Dye & Colleagues, Archaeologists, Inc.
Phone: (808) 529-0866 Fax: (808) 529-0884
http://www.tsdye.com



[-- Attachment #1.2: Type: text/html, Size: 3980 bytes --]

[-- Attachment #2: Type: text/plain, Size: 201 bytes --]

_______________________________________________
Emacs-orgmode mailing list
Please use `Reply All' to send replies to the list.
Emacs-orgmode@gnu.org
http://lists.gnu.org/mailman/listinfo/emacs-orgmode

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

* Re: org-babel-tangle tangles too much !
  2009-12-01 14:54 org-babel-tangle tangles too much ! Nicolas Girard
  2009-12-01 15:43 ` Thomas S. Dye
@ 2009-12-01 15:53 ` Eric Schulte
  2009-12-01 16:26 ` Dan Davison
  2009-12-01 17:55 ` Nicolas Girard
  3 siblings, 0 replies; 8+ messages in thread
From: Eric Schulte @ 2009-12-01 15:53 UTC (permalink / raw)
  To: Nicolas Girard; +Cc: emacs-orgmode

Hi Nicolas,

At the moment org-babel believes that any time it sees a valid source
block name surrounded by <<>> characters it is responsible for expanding
them.  Is there a reason that you are abusing this syntax?  It looks as
though you are trying to setup multiple levels of tangling like
org-babel -> noweb -> source.

If you can make a good case for why the behavior you describe should be
supported then we could try to add it behind something like a

#+srcname: b
#+begin_src emacs-lisp :noweb no
  <<a>>
  (b)
#+end_src

header argument, but at first blush the option seems to present too much
opportunity for confusion.  Maybe I'm missing something.

Thanks -- Eric

Nicolas Girard <nicolas.girard@nerim.net> writes:

> Hi,
> I can't get tangle to work the way I want.
> Given a file f.org which contains
>
> =====
> #+srcname: a
> #+begin_src emacs-lisp
> (a)
> #+end_src
>
> #+srcname: b
> #+begin_src emacs-lisp
> <<a>>
> (b)
> #+end_src
> =====
>
> I would like (a) to appear only once in the tangled file f.el.
> All I could get is, that either (a) appears twice (default behaviour),
> or (a) doesn't appear at all when I append ":tangle no" to #+srcname:
> a.
>
> Any thoughts ?

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

* Re: org-babel-tangle tangles too much !
  2009-12-01 14:54 org-babel-tangle tangles too much ! Nicolas Girard
  2009-12-01 15:43 ` Thomas S. Dye
  2009-12-01 15:53 ` Eric Schulte
@ 2009-12-01 16:26 ` Dan Davison
  2009-12-01 17:55 ` Nicolas Girard
  3 siblings, 0 replies; 8+ messages in thread
From: Dan Davison @ 2009-12-01 16:26 UTC (permalink / raw)
  To: Nicolas Girard; +Cc: emacs-orgmode

Nicolas Girard <nicolas.girard@nerim.net> writes:

> Hi,
> I can't get tangle to work the way I want.
<...>
> All I could get is, that either (a) appears twice (default behaviour),
> or (a) doesn't appear at all when I append ":tangle no" to #+srcname:
> a.

Hi Nicolas,

Note that all header arguments (including :tangle) get appended to
the #+begin_src line and *not* to the #+srcname line, although it is an
easy mistake to make.

Dan


>
> Any thoughts ?

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

* Re: org-babel-tangle tangles too much !
  2009-12-01 14:54 org-babel-tangle tangles too much ! Nicolas Girard
                   ` (2 preceding siblings ...)
  2009-12-01 16:26 ` Dan Davison
@ 2009-12-01 17:55 ` Nicolas Girard
  2009-12-01 18:26   ` Thomas S. Dye
  2009-12-01 18:50   ` [babel] " Dan Davison
  3 siblings, 2 replies; 8+ messages in thread
From: Nicolas Girard @ 2009-12-01 17:55 UTC (permalink / raw)
  To: emacs-orgmode

On Tue, 01 Dec 2009 05:43:38 -1000, Thomas S. Dye wrote :
>
> Your code snippet doesn't tangle at all here.  Perhaps you have a
> setting somewhere that has an effect on tangling?
>

I'm intending my file (username.org) to be processed by Eric's
emacs-starter-kit during init (via org-babel-load-file I guess).

As none of the other starter-kit.org seemed to bother with ":tangle
yes" I didn't either.

On Tue, 01 Dec 2009 11:26:28 -0500, Dan Davison wrote :
>
> Note that all header arguments (including :tangle) get appended to
> the #+begin_src line and *not* to the #+srcname line, although it is
> an easy mistake to make.

Sure, I've been mistaken while posting my message but havent when
performing my tests. You're right that it's quite error prone.

On Tue, 01 Dec 2009 08:53:37 -0700, Eric Schulte wrote :
> #+srcname: b
> #+begin_src emacs-lisp :noweb no

I'm afraid I don't understand the meaning of the "noweb" option here,
or elsewhere in threads about org-babel. On [1] it can be read that
"the org-babel-tangle function (...) makes use of Noweb reference
syntax for tangling of code files" ; what it means to me is that
org-babel-tangle borrowed noweb's syntax but is completely independant
from it, am I wrong ?

[1] http://orgmode.org/worg/org-contrib/babel/org-babel.php#literate-programming

> If you can make a good case for why the behavior you describe should be
> supported then we could try to add it behind something like a
> (...)
> header argument, but at first blush the option seems to present too much
> opportunity for confusion.  Maybe I'm missing something.

I for sure must also be missing something ; hopefully the following
example will get things clarified to both of us:

Using your emacs-starter-kit, here's an excerpt of how I would like my
username.org to look like:

#---- begin username.org
* Publishing

** Default headers and document class

As for the default headers, the associated variable is
=org-export-latex-classes=. I choose to change its contents rather
than appending to it
#
#+begin_src emacs-lisp
(setq org-export-latex-classes '(
 <<org-export-memoir>>
 <<org-export-scrartcl>>
))
#+end_src

*** Configuration for the =memoir= class

#+srcname: org-export-memoir
#+begin_src emacs-lisp
  ("memoir"
  "<<latex_header_memoir>>"
  <<latex_header_sections>>)
#+end_src

#+srcname: latex_header_memoir
#+begin_src emacs-lisp
  \\documentclass[article,a4paper]{memoir}
  <<latex_header_common>>
  <<memoir_correct_article>>
  <<memoir_bug_chapapp>>
#+end_src

=memoir='s article option do not behave correctly with sections. Let's
correct this:
#
#+srcname: memoir_correct_article
#+begin_src emacs-lisp
\\let\\subsubsection\\subsection
\\let\\subsection\\section
\\let\\section\\chapter
#+end_src
#
#+srcname: memoir_bug_chapapp
#+begin_src emacs-lisp
\\makeatletter
\\renewcommand{\\@chapapp}{}
\\makeatother
#+end_src

*** Configuration for the =scrartcl= class

I've been using =memoir= for quite a long time ; but =scrartcl= is now
my default class
#
#+begin_src emacs-lisp
(setq org-export-latex-default-class "article")
#+end_src
#
#+srcname: org-export-scrartcl
#+begin_src emacs-lisp
("article"
"\\documentclass{scrartcl}
<<latex_header_common>>
"
<<latex_header_sections>>
)
#+end_src

*** Common configuration

#+srcname: latex_header_common
#+begin_src emacs-lisp
\\usepackage{tikz}
\\RequirePackage{graphicx}
\\DeclareGraphicsExtensions{.pdf,.png,.jpg,.ps,.eps}
\\RequirePackage[T1]{fontenc}
<<header_common_lang>>
<<header_common_xelatex>>
<<header_common_fonts>>
#+end_src

(... and so on)
#---- end username.org

I expect both

- C-c C-e p to export username.org to username.pdf (this works
  already), and

- org-babel-tangle to generate a proper username.el (broken yet
  because code chunks get written twice).

Is my example clear enough ?

Cheers,
Nicolas

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

* Re: Re: org-babel-tangle tangles too much !
  2009-12-01 17:55 ` Nicolas Girard
@ 2009-12-01 18:26   ` Thomas S. Dye
  2009-12-01 18:50   ` [babel] " Dan Davison
  1 sibling, 0 replies; 8+ messages in thread
From: Thomas S. Dye @ 2009-12-01 18:26 UTC (permalink / raw)
  To: Nicolas Girard; +Cc: emacs-orgmode


[-- Attachment #1.1: Type: text/plain, Size: 901 bytes --]

Hi Nicolas,

On Dec 1, 2009, at 7:55 AM, Nicolas Girard wrote:

> On Tue, 01 Dec 2009 05:43:38 -1000, Thomas S. Dye wrote :
>>
>> Your code snippet doesn't tangle at all here.  Perhaps you have a
>> setting somewhere that has an effect on tangling?
>>
>
> I'm intending my file (username.org) to be processed by Eric's
> emacs-starter-kit during init (via org-babel-load-file I guess).
>
> As none of the other starter-kit.org seemed to bother with ":tangle
> yes" I didn't either.

That explains it.  I haven't explored the emacs starter kit yet, so  
I'll leave this to Eric or others.

The documentation of Org-babel is behind development now.  There is  
some work being done on this front, so manual help might be on the way  
before too long.

All the best,
Tom


Thomas S. Dye, Ph.D.
T. S. Dye & Colleagues, Archaeologists, Inc.
Phone: (808) 529-0866 Fax: (808) 529-0884
http://www.tsdye.com



[-- Attachment #1.2: Type: text/html, Size: 4144 bytes --]

[-- Attachment #2: Type: text/plain, Size: 201 bytes --]

_______________________________________________
Emacs-orgmode mailing list
Please use `Reply All' to send replies to the list.
Emacs-orgmode@gnu.org
http://lists.gnu.org/mailman/listinfo/emacs-orgmode

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

* [babel] Re: Re: org-babel-tangle tangles too much !
  2009-12-01 17:55 ` Nicolas Girard
  2009-12-01 18:26   ` Thomas S. Dye
@ 2009-12-01 18:50   ` Dan Davison
  2009-12-01 20:08     ` [babel] " Nicolas Girard
  1 sibling, 1 reply; 8+ messages in thread
From: Dan Davison @ 2009-12-01 18:50 UTC (permalink / raw)
  To: Nicolas Girard; +Cc: emacs-orgmode

**thread participants: let's not forget to put [babel] in the subject line.**

Nicolas Girard <nicolas.girard@nerim.net> writes:

> On Tue, 01 Dec 2009 05:43:38 -1000, Thomas S. Dye wrote :
>>
>> Your code snippet doesn't tangle at all here.  Perhaps you have a
>> setting somewhere that has an effect on tangling?
>>
>
> I'm intending my file (username.org) to be processed by Eric's
> emacs-starter-kit during init (via org-babel-load-file I guess).
>
> As none of the other starter-kit.org seemed to bother with ":tangle
> yes" I didn't either.

Hi Nicolas,

I just tried to do this and it seemed to work. Could you tell me if this
is similar to what you are doing, and if so whether it works for you? I
have an org file /tmp/ng.org:

-----------------------------------------------------
* heading
#+srcname: a
#+begin_src emacs-lisp :tangle no
  (setq startup-var1 'startup-var1-value)
#+end_src

#+srcname: b
#+begin_src emacs-lisp
  <<a>>
  (setq startup-var2 'startup-var2-value)
#+end_src
-----------------------------------------------------

and then I evaluated this

(org-babel-load-file "/tmp/ng.org")

That resulted in /tmp/ng.el:

-----------------------------------------------------
;; generated by org-babel-tangle
;; [[file:/tmp/ng.org::*heading][b]]
(setq startup-var1 'startup-var1-value)
(setq startup-var2 'startup-var2-value)
;; b ends here
-----------------------------------------------------

And afterwards, the two startup-var* variables had their values set.

Does this help?

Dan

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

* Re: [babel] org-babel-tangle tangles too much !
  2009-12-01 18:50   ` [babel] " Dan Davison
@ 2009-12-01 20:08     ` Nicolas Girard
  0 siblings, 0 replies; 8+ messages in thread
From: Nicolas Girard @ 2009-12-01 20:08 UTC (permalink / raw)
  To: emacs-orgmode

2009/12/1, Dan Davison <davison@stats.ox.ac.uk>:
> **thread participants: let's not forget to put [babel] in the subject
> (...)
>
> and then I evaluated this
>
> (org-babel-load-file "/tmp/ng.org")
>
> (...)
> Does this help?
>

Hi Dan,

yes, it does, thanks !
I was using org-babel-tangle or org-babel-tangle-file, instead of
org-babel-load-file...

-- 
Nicolas

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

end of thread, other threads:[~2009-12-01 20:08 UTC | newest]

Thread overview: 8+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2009-12-01 14:54 org-babel-tangle tangles too much ! Nicolas Girard
2009-12-01 15:43 ` Thomas S. Dye
2009-12-01 15:53 ` Eric Schulte
2009-12-01 16:26 ` Dan Davison
2009-12-01 17:55 ` Nicolas Girard
2009-12-01 18:26   ` Thomas S. Dye
2009-12-01 18:50   ` [babel] " Dan Davison
2009-12-01 20:08     ` [babel] " Nicolas Girard

Code repositories for project(s) associated with this external index

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

This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.