emacs-orgmode@gnu.org archives
 help / color / mirror / code / Atom feed
* org-babel: tangling to latex .sty/.cls files
@ 2010-03-16 22:10 Nicolas Girard
  2010-03-17 15:24 ` [babel] " Dan Davison
  0 siblings, 1 reply; 9+ messages in thread
From: Nicolas Girard @ 2010-03-16 22:10 UTC (permalink / raw)
  To: emacs-orgmode

Hi all,
a while ago Babel allowed latex code to be tangled to a file named
f.sty or f.cls ; it's currently not possible any more, because the
tangled file is named f.sty.tex or f.cls.tex.
I tried to deal with it but I'm really missing this feature a lot.
Do you think org-babel could allow this again ?
Thanks very much in advance,
cheers,
Nicolas

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

* Re: [babel] org-babel: tangling to latex .sty/.cls files
  2010-03-16 22:10 org-babel: tangling to latex .sty/.cls files Nicolas Girard
@ 2010-03-17 15:24 ` Dan Davison
  2010-03-17 15:32   ` Chris Gray
  0 siblings, 1 reply; 9+ messages in thread
From: Dan Davison @ 2010-03-17 15:24 UTC (permalink / raw)
  To: Nicolas Girard; +Cc: emacs-orgmode

Unless I hear views to the contrary from other org-babel users, I'm
going to change this later today so that, when a file name is supplied
for tangling, org-babel no longer attempts to guess the file
extension. The only situation when tangling will guess the file name
extension is if you supply ':tangle yes' in which case the behaviour
will be as it is currently (i.e. the org file name, minus .org, plus the
extension defined in org-babel-tangle-langs.)

The patch I propose to apply is below.

For a file named z.org, here are what some blocks will tangle to with
this patch.

#+begin_src sh :tangle yes                => z.sh
#+begin_src latex :tangle latex-code      => latex-code
#+begin_src latex :tangle latex-code.tex  => latex-code.tex
#+begin_src latex :tangle a.cls           => a.cls

Dan


--8<---------------cut here---------------start------------->8---
diff --git a/contrib/babel/lisp/org-babel-tangle.el b/contrib/babel/lisp/org-babel-tangle.el
index dd76195..4880118 100644
--- a/contrib/babel/lisp/org-babel-tangle.el
+++ b/contrib/babel/lisp/org-babel-tangle.el
@@ -109,7 +109,7 @@ exported source code blocks by language."
                                       target-file))
                        (file-name (when base-name
                                     ;; decide if we want to add ext to base-name
-                                    (if (and ext (not (string= (file-name-extension base-name) ext)))
+                                    (if (and ext (string= "yes" tangle))
                                         (concat base-name "." ext) base-name))))
                   ;; ;; debugging
                   ;; (message
--8<---------------cut here---------------end--------------->8---


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

> Hi all,
> a while ago Babel allowed latex code to be tangled to a file named
> f.sty or f.cls ; it's currently not possible any more, because the
> tangled file is named f.sty.tex or f.cls.tex.
> I tried to deal with it but I'm really missing this feature a lot.
> Do you think org-babel could allow this again ?

> Thanks very much in advance,
> cheers,
> Nicolas
>
>
> _______________________________________________
> 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 related	[flat|nested] 9+ messages in thread

* Re: [babel] org-babel: tangling to latex .sty/.cls files
  2010-03-17 15:24 ` [babel] " Dan Davison
@ 2010-03-17 15:32   ` Chris Gray
  2010-03-17 16:24     ` Thomas S. Dye
  2010-03-17 17:21     ` Dan Davison
  0 siblings, 2 replies; 9+ messages in thread
From: Chris Gray @ 2010-03-17 15:32 UTC (permalink / raw)
  To: emacs-orgmode

Dan Davison wrote:

> Unless I hear views to the contrary from other org-babel users, I'm
> going to change this later today so that, when a file name is supplied
> for tangling, org-babel no longer attempts to guess the file
> extension. The only situation when tangling will guess the file name
> extension is if you supply ':tangle yes' in which case the behaviour
> will be as it is currently (i.e. the org file name, minus .org, plus the
> extension defined in org-babel-tangle-langs.)

Would it be possible to add the extension if no extension exists?

Cheers,
Chris

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

* Re: Re: [babel] org-babel: tangling to latex .sty/.cls files
  2010-03-17 15:32   ` Chris Gray
@ 2010-03-17 16:24     ` Thomas S. Dye
  2010-03-18  1:13       ` Dan Davison
  2010-03-17 17:21     ` Dan Davison
  1 sibling, 1 reply; 9+ messages in thread
From: Thomas S. Dye @ 2010-03-17 16:24 UTC (permalink / raw)
  To: Chris Gray; +Cc: emacs-orgmode


On Mar 17, 2010, at 5:32 AM, Chris Gray wrote:

> Dan Davison wrote:
>
>> Unless I hear views to the contrary from other org-babel users, I'm
>> going to change this later today so that, when a file name is  
>> supplied
>> for tangling, org-babel no longer attempts to guess the file
>> extension. The only situation when tangling will guess the file name
>> extension is if you supply ':tangle yes' in which case the behaviour
>> will be as it is currently (i.e. the org file name, minus .org,  
>> plus the
>> extension defined in org-babel-tangle-langs.)
>
> Would it be possible to add the extension if no extension exists?
>
> Cheers,
> Chris


Aloha Chris,

Perhaps this behavior could be controlled by a variable?  I can see  
how it might be handy for some uses, but I prefer Dan's proposal for  
everyday use.

All the best,
Tom

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

* Re: Re: [babel] org-babel: tangling to latex .sty/.cls files
  2010-03-17 15:32   ` Chris Gray
  2010-03-17 16:24     ` Thomas S. Dye
@ 2010-03-17 17:21     ` Dan Davison
  1 sibling, 0 replies; 9+ messages in thread
From: Dan Davison @ 2010-03-17 17:21 UTC (permalink / raw)
  To: Chris Gray; +Cc: emacs-orgmode

Chris Gray <chrismgray@gmail.com> writes:

> Dan Davison wrote:
>
>> Unless I hear views to the contrary from other org-babel users, I'm
>> going to change this later today so that, when a file name is supplied
>> for tangling, org-babel no longer attempts to guess the file
>> extension. The only situation when tangling will guess the file name
>> extension is if you supply ':tangle yes' in which case the behaviour
>> will be as it is currently (i.e. the org file name, minus .org, plus the
>> extension defined in org-babel-tangle-langs.)
>
> Would it be possible to add the extension if no extension exists?

You mean where the extension is defined to be everything after the last
'.'? I believe that that was the kind of thing we were attempting to do
but that I am now thinking was misguided. For example, if someone wants
an output file name like xxx.yyy.tex, then they might supply :tangle
xxx.yyy in which case we might end up concluding that the extension is
yyy and they'll never get the .tex.

Dan

>
> Cheers,
> Chris
>
>
>
> _______________________________________________
> 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] 9+ messages in thread

* Re: Re: [babel] org-babel: tangling to latex .sty/.cls files
  2010-03-17 16:24     ` Thomas S. Dye
@ 2010-03-18  1:13       ` Dan Davison
  2010-03-18 18:09         ` Nicolas Girard
  0 siblings, 1 reply; 9+ messages in thread
From: Dan Davison @ 2010-03-18  1:13 UTC (permalink / raw)
  To: Thomas S. Dye; +Cc: Nicolas Girard, Chris Gray, emacs-orgmode

"Thomas S. Dye" <tsd@tsdye.com> writes:

> On Mar 17, 2010, at 5:32 AM, Chris Gray wrote:
>
>> Dan Davison wrote:
>>
>>> Unless I hear views to the contrary from other org-babel users, I'm
>>> going to change this later today so that, when a file name is
>>> supplied
>>> for tangling, org-babel no longer attempts to guess the file
>>> extension. The only situation when tangling will guess the file name
>>> extension is if you supply ':tangle yes' in which case the behaviour
>>> will be as it is currently (i.e. the org file name, minus .org,
>>> plus the
>>> extension defined in org-babel-tangle-langs.)
>>
>> Would it be possible to add the extension if no extension exists?
>>
>> Cheers,
>> Chris
>
>
> Aloha Chris,
>
> Perhaps this behavior could be controlled by a variable?  I can see
> how it might be handy for some uses, but I prefer Dan's proposal for
> everyday use.

OK, I've gone ahead with that. No extension added now unless ':tangle yes'.

Dan

>
> All the best,
> Tom
>
>
> _______________________________________________
> 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] 9+ messages in thread

* Re: Re: [babel] org-babel: tangling to latex .sty/.cls files
  2010-03-18  1:13       ` Dan Davison
@ 2010-03-18 18:09         ` Nicolas Girard
  2010-03-18 18:36           ` Dan Davison
  0 siblings, 1 reply; 9+ messages in thread
From: Nicolas Girard @ 2010-03-18 18:09 UTC (permalink / raw)
  To: emacs-orgmode

2010/3/18 Dan Davison <davison@stats.ox.ac.uk>:
> "Thomas S. Dye" <tsd@tsdye.com> writes:
>

>
> OK, I've gone ahead with that. No extension added now unless ':tangle yes'.
>

Hi Dan,

Thanks very much, but it seems to break org-babel-load-file.
From the source code of org-babel-load-file:
(org-babel-tangle-file file base-name "emacs-lisp") -> tangles f.org
into f ; but then
(load-file exported-file) -> tries to load f.el, which doesn't exist

Cheers,
Nicolas

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

* Re: Re: [babel] org-babel: tangling to latex .sty/.cls files
  2010-03-18 18:09         ` Nicolas Girard
@ 2010-03-18 18:36           ` Dan Davison
  2010-03-19 16:18             ` Nicolas Girard
  0 siblings, 1 reply; 9+ messages in thread
From: Dan Davison @ 2010-03-18 18:36 UTC (permalink / raw)
  To: Nicolas Girard; +Cc: emacs-orgmode

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

> 2010/3/18 Dan Davison <davison@stats.ox.ac.uk>:
>> "Thomas S. Dye" <tsd@tsdye.com> writes:
>>
>
>>
>> OK, I've gone ahead with that. No extension added now unless ':tangle yes'.
>>
>
> Hi Dan,
>
> Thanks very much, but it seems to break org-babel-load-file.
>From the source code of org-babel-load-file:
> (org-babel-tangle-file file base-name "emacs-lisp") -> tangles f.org
> into f ; but then
> (load-file exported-file) -> tries to load f.el, which doesn't exist

Nicolas --

Thanks very much. I believe I have just pushed a fix for that. If you
get a chance to double-check that everything seems OK that would be
great.

Dan


>
> Cheers,
> Nicolas
>
>
> _______________________________________________
> 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] 9+ messages in thread

* Re: Re: [babel] org-babel: tangling to latex .sty/.cls files
  2010-03-18 18:36           ` Dan Davison
@ 2010-03-19 16:18             ` Nicolas Girard
  0 siblings, 0 replies; 9+ messages in thread
From: Nicolas Girard @ 2010-03-19 16:18 UTC (permalink / raw)
  To: emacs-orgmode

>
> Thanks very much. I believe I have just pushed a fix for that. If you
> get a chance to double-check that everything seems OK that would be
> great.
>

Yes, I think it's ok now.
Thanks again !

Nicolas

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

end of thread, other threads:[~2010-03-19 16:18 UTC | newest]

Thread overview: 9+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2010-03-16 22:10 org-babel: tangling to latex .sty/.cls files Nicolas Girard
2010-03-17 15:24 ` [babel] " Dan Davison
2010-03-17 15:32   ` Chris Gray
2010-03-17 16:24     ` Thomas S. Dye
2010-03-18  1:13       ` Dan Davison
2010-03-18 18:09         ` Nicolas Girard
2010-03-18 18:36           ` Dan Davison
2010-03-19 16:18             ` Nicolas Girard
2010-03-17 17:21     ` Dan Davison

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).