emacs-orgmode@gnu.org archives
 help / color / mirror / code / Atom feed
* Bug in org-babel-load-file
@ 2010-02-07  3:22 Andrew Hyatt
  2010-02-07  5:00 ` Dan Davison
  0 siblings, 1 reply; 3+ messages in thread
From: Andrew Hyatt @ 2010-02-07  3:22 UTC (permalink / raw)
  To: emacs-orgmode

Hi guys,

There appears to be a bug in org-babel-load-file, where it calls
org-babel-tangle-file with file and base-name.  Instead of using
base-name, it should probably use the exported-file.   This causes an
issue where the elisp I am extracting is put in "foo.bar" instead of
"foo.bar.el".  Strangely, this doesn't appear to always happen, but
only when there is a file with lots of dot-separated sections.  Any
thoughts?

This is in org 6.34trans.

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

* Re: Bug in org-babel-load-file
  2010-02-07  3:22 Bug in org-babel-load-file Andrew Hyatt
@ 2010-02-07  5:00 ` Dan Davison
  2010-02-07 18:47   ` Eric Schulte
  0 siblings, 1 reply; 3+ messages in thread
From: Dan Davison @ 2010-02-07  5:00 UTC (permalink / raw)
  To: Andrew Hyatt; +Cc: emacs-orgmode

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

Andrew Hyatt <ahyatt@gmail.com> writes:

> Hi guys,
>
> There appears to be a bug in org-babel-load-file, where it calls
> org-babel-tangle-file with file and base-name.  Instead of using
> base-name, it should probably use the exported-file.   This causes an
> issue where the elisp I am extracting is put in "foo.bar" instead of
> "foo.bar.el".  Strangely, this doesn't appear to always happen, but
> only when there is a file with lots of dot-separated sections.  Any
> thoughts?

Hi Andrew,

Yes I can replicate that, when file names contain multiple '.'s.  I
think the patch below provides a quick fix. However, this patch would
not allow e.g. tangling elisp to a file with a name like 'foo.el.el', in
case anyone wants to do that.

Dan


[-- Warning: decoded text below may be mangled, UTF-8 assumed --]
[-- Attachment #2: 0001-babel-Fix-tangle-file-names-with-multiple-.-s.patch --]
[-- Type: text/x-diff, Size: 1385 bytes --]

From c16fcd05e8d0cc7c9a704ac285d1e5f8f3b3d835 Mon Sep 17 00:00:00 2001
From: Dan Davison <davison@stats.ox.ac.uk>
Date: Sat, 6 Feb 2010 23:50:34 -0500
Subject: [PATCH] babel: Fix tangle file names with multiple '.'s

---
 contrib/babel/lisp/org-babel-tangle.el |    8 ++++----
 1 files changed, 4 insertions(+), 4 deletions(-)

diff --git a/contrib/babel/lisp/org-babel-tangle.el b/contrib/babel/lisp/org-babel-tangle.el
index d75f1d2..5cfdca5 100644
--- a/contrib/babel/lisp/org-babel-tangle.el
+++ b/contrib/babel/lisp/org-babel-tangle.el
@@ -108,10 +108,10 @@ exported source code blocks by language."
                                        ((> (length tangle) 0) tangle))
                                       target-file))
                        (file-name (when base-name
-                                    (if (and ext
-                                             (string= base-name
-                                                      (file-name-sans-extension base-name)))
-                                        (concat base-name "." ext) base-name))))
+				    (if ext
+					(if (string= (file-name-extension base-name) ext)
+					    base-name (concat base-name "." ext))
+				      base-name))))
                   ;; ;; debugging
                   ;; (message
                   ;;  "tangle=%S base-name=%S file-name=%S she-bang=%S commentable=%s"
-- 
1.6.3.3


[-- Attachment #3: Type: text/plain, Size: 247 bytes --]



>
> This is in org 6.34trans.
>
>
> _______________________________________________
> 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

[-- Attachment #4: 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 related	[flat|nested] 3+ messages in thread

* Re: Bug in org-babel-load-file
  2010-02-07  5:00 ` Dan Davison
@ 2010-02-07 18:47   ` Eric Schulte
  0 siblings, 0 replies; 3+ messages in thread
From: Eric Schulte @ 2010-02-07 18:47 UTC (permalink / raw)
  To: Dan Davison; +Cc: emacs-orgmode

Hi Andrew,

I just applied a slight variation of Dan's patch which should fix this
issue.  Thanks for the bug report, and please let us know if you have
any further issues.

Cheers -- Eric

Dan Davison <davison@stats.ox.ac.uk> writes:

> Andrew Hyatt <ahyatt@gmail.com> writes:
>
>> Hi guys,
>>
>> There appears to be a bug in org-babel-load-file, where it calls
>> org-babel-tangle-file with file and base-name.  Instead of using
>> base-name, it should probably use the exported-file.   This causes an
>> issue where the elisp I am extracting is put in "foo.bar" instead of
>> "foo.bar.el".  Strangely, this doesn't appear to always happen, but
>> only when there is a file with lots of dot-separated sections.  Any
>> thoughts?
>
> Hi Andrew,
>
> Yes I can replicate that, when file names contain multiple '.'s.  I
> think the patch below provides a quick fix. However, this patch would
> not allow e.g. tangling elisp to a file with a name like 'foo.el.el', in
> case anyone wants to do that.
>
> Dan
>
>
> From c16fcd05e8d0cc7c9a704ac285d1e5f8f3b3d835 Mon Sep 17 00:00:00 2001
> From: Dan Davison <davison@stats.ox.ac.uk>
> Date: Sat, 6 Feb 2010 23:50:34 -0500
> Subject: [PATCH] babel: Fix tangle file names with multiple '.'s
>
> ---
>  contrib/babel/lisp/org-babel-tangle.el |    8 ++++----
>  1 files changed, 4 insertions(+), 4 deletions(-)
>
> diff --git a/contrib/babel/lisp/org-babel-tangle.el b/contrib/babel/lisp/org-babel-tangle.el
> index d75f1d2..5cfdca5 100644
> --- a/contrib/babel/lisp/org-babel-tangle.el
> +++ b/contrib/babel/lisp/org-babel-tangle.el
> @@ -108,10 +108,10 @@ exported source code blocks by language."
>                                         ((> (length tangle) 0) tangle))
>                                        target-file))
>                         (file-name (when base-name
> -                                    (if (and ext
> -                                             (string= base-name
> -                                                      (file-name-sans-extension base-name)))
> -                                        (concat base-name "." ext) base-name))))
> +				    (if ext
> +					(if (string= (file-name-extension base-name) ext)
> +					    base-name (concat base-name "." ext))
> +				      base-name))))
>                    ;; ;; debugging
>                    ;; (message
>                    ;;  "tangle=%S base-name=%S file-name=%S she-bang=%S commentable=%s"

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

end of thread, other threads:[~2010-02-07 18:47 UTC | newest]

Thread overview: 3+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2010-02-07  3:22 Bug in org-babel-load-file Andrew Hyatt
2010-02-07  5:00 ` Dan Davison
2010-02-07 18:47   ` Eric Schulte

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