emacs-orgmode@gnu.org archives
 help / color / mirror / code / Atom feed
From: "Eric Schulte" <schulte.eric@gmail.com>
To: "Sébastien Vauban" <wxhgmqzgwmuf@spammotel.com>
Cc: emacs-orgmode@gnu.org
Subject: Re: Re: Literate Programming with Org mode
Date: Tue, 11 Aug 2009 12:55:52 -0600	[thread overview]
Message-ID: <m263cu41tz.fsf@gmail.com> (raw)
In-Reply-To: <873a7yy9dc.fsf@mundaneum.com> ("Sébastien Vauban"'s message of "Tue, 11 Aug 2009 11:42:39 +0200")

Hi Sébastien,

Sébastien Vauban <wxhgmqzgwmuf@spammotel.com> writes:

> Hi Eric,
>
> "Eric Schulte" wrote:
>> Sébastien Vauban <wxhgmqzgwmuf@spammotel.com> writes:
>>> "Eric Schulte" wrote:
>>>> "Eric Schulte" <schulte.eric@gmail.com> writes:

[...]

> Now (I've done some changes, explained below), I can...
>
> Stored: Header
> Stored: Condition to be satisfied
> Stored: File Enterprise
> Stored: File Lessons
> Stored: File Payment
> Added to /home/sva/Downloads/emacs/site-lisp/noweb-example/w-babel/Enterprise.sql
> Added to /home/sva/Downloads/emacs/site-lisp/noweb-example/w-babel/Lessons.sql
> Added to /home/sva/Downloads/emacs/site-lisp/noweb-example/w-babel/Payment.sql
> tangled 3 source-code blocks
>
> Great!
>

Wonderful, so if we're creating source-code files then we're most of the
way there.

>
> Though, this is not entirely what I expected. Let's take the Enterprise.sql
> file:
>
> -- generated by org-babel-tangle
>
> -- [[file:~/Downloads/emacs/site-lisp/noweb-example/w-babel/org-babel-lit-prog.org::*File%20Enterprise][block-3]]
> -- <<sql-init>>
> SELECT abcID, etpID, etpAssurATPolNum
> FROM enterprise JOIN record
>     ON (etpAbcID_fk = abcID)
> WHERE etpAbcID_fk
> -- <<sql-cond>>
> -- block-3 ends here
>
> I'm expecting the sql-init and sql-cond blocks to be replaced by their defined
> equivalent. So, in this case, I should have the following file:
>
> -- generated by org-babel-tangle
>
> -- [[file:~/Downloads/emacs/site-lisp/noweb-example/w-babel/org-babel-lit-prog.org::*File%20Enterprise][block-3]]
> -- Hey, Emacs! This is a -*- coding: utf-8 -*- file!
>
> -- no longer display the count message
> SET NOCOUNT ON
>
> DECLARE @dateFmtStyleIn int; SET @dateFmtStyleIn = 120 -- ODBC canonical
> DECLARE @dateFmtStyleOut int; SET @dateFmtStyleOut = 103 -- French dd/mm/yyyy
>
> DECLARE @firstDayOfThisMonth smalldatetime
> SET @firstDayOfThisMonth = CONVERT(smalldatetime,
>                                    CAST(YEAR(GETDATE()) AS char(4)) + '-'
>                                    + CAST(MONTH(GETDATE()) AS char(2)) + '-'
>                                    + '01' + ' 00:00:00',
>                                    @dateFmtStyleIn)
>
> SELECT abcID, etpID, etpAssurATPolNum
> FROM enterprise JOIN record
>     ON (etpAbcID_fk = abcID)
> WHERE etpAbcID_fk
>
>       IN (SELECT actAbcID_fk
>           FROM status
>           WHERE (staID = 338 AND staEtat = 3))
>       AND abcSignDate < @firstDayOfThisMonth
>   ORDER BY abcID
> -- block-3 ends here
>
> Do we agree on this?
>

Agreed.  This is the contents of my Enterprise.sql (as generated by
org-babel tangle).  I believe this is the contents that you wanted.  I'm
not sure what could be different between our setups...

--8<---------------cut here---------------start------------->8---
-- generated by org-babel-tangle

-- [[file:~/src/noweb-example/w-babel/org-babel-lit-prog.org::*File%20Enterprise][block-3]]
  -- <<sql-init>>
-- Hey, Emacs! This is a -*- coding: utf-8 -*- file!

-- no longer display the count message
SET NOCOUNT ON

DECLARE @dateFmtStyleIn int; SET @dateFmtStyleIn = 120 -- ODBC canonical
DECLARE @dateFmtStyleOut int; SET @dateFmtStyleOut = 103 -- French dd/mm/yyyy

DECLARE @firstDayOfThisMonth smalldatetime
SET @firstDayOfThisMonth = CONVERT(smalldatetime,
                                   CAST(YEAR(GETDATE()) AS char(4)) + '-'
                                   + CAST(MONTH(GETDATE()) AS char(2)) + '-'
                                   + '01' + ' 00:00:00',
                                   @dateFmtStyleIn)

  SELECT abcID, etpID, etpAssurATPolNum
  FROM enterprise JOIN record
      ON (etpAbcID_fk = abcID)
  WHERE etpAbcID_fk
  -- <<sql-cond>>
      IN (SELECT actAbcID_fk
          FROM status
          WHERE (staID = 338 AND staEtat = 3))
      AND abcSignDate < @firstDayOfThisMonth
  ORDER BY abcID
-- block-3 ends here
--8<---------------cut here---------------end--------------->8---

Some changes which I would still like to make to the above are
1) use relative paths when linking back to the org-mode file
2) somehow activate an org-mode minor mode in the source-code file which
   will then "turn on" the org-mode style links in the source code file

> >
>>> Is it normal that you don't include the extension in the tangle property?
>>> Does it add the language extension automatically?
>>
>> Yes, org-babel adds the language specific extension automatically.  This
>> could be changed/overridden if it proves to limiting.  It grew out of
>> the fact that originally source-code files were named based upon the
>> basename of the org-mode file and the language extension.
>
> I find that this is OK right now. Though, people could want to give an
> explicit extension, moreover for `.htm' or `.html' files where standard
> conventions are not that clear.
>

Maybe I can add a simple rule.  *If* there is already an extension
*then* don't add the default extension.  I'll add this to the Org-babel
tasks.

> >
>>>> The document can also be exported into html and latex using org-mode's
>>>> standard export functionality.
>>>
>>> I have problems as well...
>>
>> Again maybe this is the result of conflicting values of org-odd-levels-only?
>> Please try this with the newer org-mode file [1]. I was able to export this
>> to latex resulting in the following tex file [5] and pdf file [6]. I was
>> also able to export this file to html which includes code highlighting [7].
>>
>>> Thanks for all! This is seriously a hot topic you've almost solved...
>>
>> Sorry I can't be more specific with answers to your problems tangling and
>> exporting. Please do give the new org-mode file [1] a try with the latest
>> version org-babel and let me know if the problems persist.
>
> I still had the same problem in the beginning: around the `verbatim'
> environments, I had wrong `\LaTeX{}' environments created...
>
> Though, I found the problem: it's somehow a conflict with the
> `org-special-blocks' package. Un-commenting the following should show you the
> problems:
>
> ;; FIXME This is responsible of problems when used with Org-babel
> ;; (`\LaTeX{}' environments are created around verbatim environments)
> ;; ;; turn Org blocks into LaTeX environments and HTML divs
> ;; (try-require 'org-special-blocks)
>
> ;; literate programming
> (try-require 'org-babel-init)
>
> With the above configuration, I could finally export the Org file in LaTeX.
> Yeeesss.
>
> I have some comments on the resulting file:
>
>     o   sections (and sub-, and subsub-) should not be starred by default,
>         IMHO, and then unnumbered.
>

This should be addressed in the Org-mode core rather than in Org-babel.

>
>     o   indentation of code blocks should be preserved.
>

This should also be addressed in Org-mode proper.

>
>     o   name of code blocks should be visible in the produced document
>         because, now, I see that the file Enterprise.sql will include the
>         sql-init block, but I don't know where it is described (which page,
>         and which block).
>

Excellent that you are now seeing sql-init block in Enterprise.sql, I
agree that it would be nice to see the source code block's name in the
exported file.  I will add this to the Org-babel tasks.

>
> Except these, the result is already very promising!
>

Thanks for you continued help refining this functionality! -- Eric

> >
>>> BTW, what do you think of my proposal to include the Tangle process as a
>>> built-in step of the export to LaTeX (and HTML)?
>>>
>>> That way, we only would export and get both flies caught with one stone.
>>
>> I like that idea, once this is working as two separate processes it should
>> be relatively trivial to optionally hook org-babel-tangle onto the other
>> export commands.
>
> Fantastic.
>
> Thanks for all your work.
>
> Best regards,
>   Seb

      reply	other threads:[~2009-08-11 18:56 UTC|newest]

Thread overview: 13+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2009-07-28 16:14 Literate Programming with Org mode Sébastien Vauban
2009-07-28 16:46 ` Marcelo de Moraes Serpa
2009-07-28 20:41   ` Sébastien Vauban
2009-07-28 21:53     ` sam kleinman
2009-07-29 22:16       ` Eric H. Neilsen, Jr.
2009-07-31 17:01       ` Eric Schulte
2009-07-31 20:30         ` sam kleinman
2009-07-30  0:42 ` Eric Schulte
2009-08-02  1:46   ` Eric Schulte
2009-08-03  8:42     ` Sébastien Vauban
2009-08-03 15:38       ` Eric Schulte
2009-08-11  9:42         ` Sébastien Vauban
2009-08-11 18:55           ` Eric Schulte [this message]

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

  List information: https://www.orgmode.org/

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=m263cu41tz.fsf@gmail.com \
    --to=schulte.eric@gmail.com \
    --cc=emacs-orgmode@gnu.org \
    --cc=wxhgmqzgwmuf@spammotel.com \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
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).