From mboxrd@z Thu Jan 1 00:00:00 1970 From: Emre Sahin Subject: Literate Programming in Org-Mode Date: Fri, 22 Jun 2007 19:45:33 +0300 Message-ID: <87k5twey4y.fsf@leonardo.iesahin.net> Mime-Version: 1.0 Content-Type: text/plain; charset=us-ascii Return-path: Received: from mailman by lists.gnu.org with tmda-scanned (Exim 4.43) id 1I1mHF-00080Z-Na for emacs-orgmode@gnu.org; Fri, 22 Jun 2007 12:46:29 -0400 Received: from exim by lists.gnu.org with spam-scanned (Exim 4.43) id 1I1mHD-0007zn-Si for emacs-orgmode@gnu.org; Fri, 22 Jun 2007 12:46:29 -0400 Received: from [199.232.76.173] (helo=monty-python.gnu.org) by lists.gnu.org with esmtp (Exim 4.43) id 1I1mHD-0007zi-PO for emacs-orgmode@gnu.org; Fri, 22 Jun 2007 12:46:27 -0400 Received: from manyas.bcc.bilkent.edu.tr ([139.179.30.24]) by monty-python.gnu.org with esmtp (Exim 4.60) (envelope-from ) id 1I1mHD-0006k8-3B for emacs-orgmode@gnu.org; Fri, 22 Jun 2007 12:46:27 -0400 Received: from leonardo.iesahin.net (unknown [81.214.248.165]) by manyas.bcc.bilkent.edu.tr (Postfix) with ESMTP id 3ED1826EEC for ; Fri, 22 Jun 2007 19:46:21 +0300 (EEST) List-Id: "General discussions about Org-mode." List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Sender: emacs-orgmode-bounces+geo-emacs-orgmode=m.gmane.org@gnu.org Errors-To: emacs-orgmode-bounces+geo-emacs-orgmode=m.gmane.org@gnu.org To: Org-mode ML Hi all, Do any of you use org-mode for literate programming? I think that would be a very natural use of org-mode. Support in other compilers may be minimal, but one can write a Literate Haskell program in org-mode without any changes I think. E.g. (a meaningless program from Haskell wikibook) * Preamble ** Module Definition > module YourModule where ** Imports *** import only the functions toLower and toUpper from Data.Char > import Data.Char (toLower, toUpper) *** import everything exported from Data.List > import Data.List *** import everything exported from MyModule > import MyModule * Functions ** put a c in front of the text > someFunction :: String -> String > someFunction text = 'c' : text ** build a string of c's using someFunction > stringOfCs :: String -> String > stringOfCs = (someFunction "") : stringOfCs ** etc * Input and output > main = do > putStrLn "Please enter your name: " > name <- getLine > putStrLn ("Hello, " ++ (someFunction name) ++ ", how are you?") In Literate Haskell, program lines start with a >. If it's not used, than the line is considered as a comment line, hence making org-mode useful in folding, maintainin TODOs etc. (This message is already a Literate Haskell program.) Currently, one can use Literate Haskell major mode during compilation and writing codes and org-mode during general overview for the program. Writing first the documentation and pseudocode of the program in org-mode and then filling the "gaps" with code may result in better programs. (You can see http://www.haskell.org/onlinereport/literate.html for literate comments in Haskell.) This can give an idea how org-mode can be employed for writing programs. Developing some functionality to consider lines starting with > (or any other character) as a code line and syntax highlighting and feeding these to a compiler may ease things. Currently one can switch back and forth to the language major mode and org-mode (or use multiple major mode packs, but I didn't try them) but a support for code lines (for any programming language) may result in one of the best Literate Programming tools out there, I think. (Ability to use LaTeX in org-mode already makes it very useful for LP.) I don't know if anybody considered this, but using org-mode as a "super mode" for programming major modes seems a good idea. Best regards, Emre