[Top][All Lists]

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: [Orgmode] org-babel language support

From: Dan Davison
Subject: Re: [Orgmode] org-babel language support
Date: Tue, 20 Apr 2010 19:17:53 -0400
User-agent: Gnus/5.13 (Gnus v5.13) Emacs/23.1.50 (gnu/linux)

Izaak Beekman <address@hidden> writes:

> How much work is it to support a new compiled langauge?  I am interested in
> using org-babel for Fortran literate programming (LP).  I am new to org-mode,
> but know a little bit of e-lisp, and might start hacking at this after some
> preliminary investigation.  The main functionality I am looking for is pretty
> printing documentation, and code export (tangling). 

Hi Izaak,

If you are just after export and tangling then you are in luck.

Prior to Org-babel, Org-mode already supported pretty fontified export
of code in any language that emacs understands. Use C-e for the export
dispatcher, which leads to e.g. html and latex export.

And to get tangling working for fortran, once org-babel is installed all
you need is

  (org-babel-add-interpreter "fortran")
  (add-to-list 'org-babel-tangle-langs '("fortran" "f"))

Here's the fortran src block I just tested. C-e b should bring up a
browser tab showing fontified code. You need to have the htmlize emacs
package loaded, which is in the org-mode contrib dir. And M-x
org-babel-tangle should create a fortran file containing the code, with
the .f extension replacing .org.

* fortran
  Some fortran code taken from Wikipedia
#+begin_src fortran :tangle yes
  FUNCTION string_concat(s1, s2)                             ! This is a comment
     TYPE (string), INTENT(IN) :: s1, s2
     TYPE (string) string_concat
     string_concat%string_data = s1%string_data(1:s1%length) // &
        s2%string_data(1:s2%length)                          ! This is a 
     string_concat%length = s1%length + s2%length
  END FUNCTION string_concat

A couple of points about export: for CSS control over the html produced,
see the variables org-export-htmlize-output-type and
org-export-html-style. For latex, one can get fontified code by
including the listings package. See section 11.3 Literal Examples of the

As for full org-babel support for fortran, Eric Schulte (the main
org-babel author) has recently added support for compilation and
execution of C and C++, so you would definitely want to take a look at
org-babel-C.el (if you haven't already). He may have further advice.


> Izaak Beekman
> ===================================
> Princeton University Doctoral Candidate
> Mechanical and Aerospace Engineering
> address@hidden
> UMD-CP Visiting Graduate Student
> Aerospace Engineering
> address@hidden
> address@hidden
> _______________________________________________
> Emacs-orgmode mailing list
> Please use `Reply All' to send replies to the list.
> address@hidden
> http://lists.gnu.org/mailman/listinfo/emacs-orgmode

reply via email to

[Prev in Thread] Current Thread [Next in Thread]