From mboxrd@z Thu Jan 1 00:00:00 1970 From: Dan Davison Subject: Re: org-style folding for a .emacs Date: Mon, 13 Jul 2009 19:26:49 -0400 Message-ID: <8763dwxiyu.fsf@stats.ox.ac.uk> References: 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 1MQUvE-00041N-84 for emacs-orgmode@gnu.org; Mon, 13 Jul 2009 19:27:00 -0400 Received: from exim by lists.gnu.org with spam-scanned (Exim 4.43) id 1MQUv9-0003vv-Lh for emacs-orgmode@gnu.org; Mon, 13 Jul 2009 19:26:59 -0400 Received: from [199.232.76.173] (port=33359 helo=monty-python.gnu.org) by lists.gnu.org with esmtp (Exim 4.43) id 1MQUv9-0003vm-83 for emacs-orgmode@gnu.org; Mon, 13 Jul 2009 19:26:55 -0400 Received: from markov.stats.ox.ac.uk ([163.1.210.1]:44964) by monty-python.gnu.org with esmtp (Exim 4.60) (envelope-from ) id 1MQUv8-0003EL-PQ for emacs-orgmode@gnu.org; Mon, 13 Jul 2009 19:26:55 -0400 In-Reply-To: (Scot Becker's message of "Mon, 13 Jul 2009 22:23:51 +0100") 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: Scot Becker Cc: Org-mode ml Scot Becker writes: Hi Scot, > Does anyone have a recipe for easy org-style folding of an elisp file? > I'd like to divide my .emacs into segments to make it easier to > oversee and navigate. As you're probably aware, outline-minor-mode can be used for folding source code in whatever language. By playing with outline-regexp, a variety of effects can be achieved. However, a much more powerful option would be to embed the code in an org file: literate programming with org. Code comments would be moved into the org-file, where they would be joined by the org bestiary of hyperlinks, tags, TODO items, etc etc etc. As it stands, org already provides excellent support for working with source code blocks. One of the aims that Eric Schulte and I have for org-babel[1] is to provide extra support for literate programming. For an emacs config file, a simple solution -- that is available now -- is to strip out ('tangle') the code and then load the resulting .el file as normal. This can be done with org-babel-tangle. Below are an example of a toy .emacs.org file, and the .emacs.el that results after M-x org-babel-tangle. The org-babel configuration code that is required is in the second code block below. Org-babel is under development. One reason for mentioning it is that the basic functionality is up and running; another is that we'd be very happy to have others join the project, and to receive ideas and patches from the list. Dan Footnotes: [1] http://github.com/eschulte/org-babel/tree/master NB Although the implementation in org-babel is independent, Eric Neilsen has also worked on tangle/untangle functions for org-mode, and posted on that recently. .emacs.org --8<---------------cut here---------------start------------->8--- * org config #+begin_src emacs-lisp (add-to-list 'load-path "/usr/local/src/org-mode/lisp") (require 'org-install) #+end_src * org-babel config Download/clone the org-babel code from [[http://github.com/eschulte/org-babel/tree/master][org-babel on github]] #+begin_src emacs-lisp (add-to-list 'load-path "~/src/org-babel/lisp") (require 'org-babel-init) (setq org-babel-tangle-langs '(("python" . ("py" "#!/usr/bin/env python")) ("R" . ("R" "#!/usr/bin/env R")) ("sh" . ("sh" "#!/usr/bin/env bash")) ("emacs-lisp" . ("el" "")))) #+end_src --8<---------------cut here---------------end--------------->8--- .emacs.el: --8<---------------cut here---------------start------------->8--- ;; generated by org-babel-tangle ;; [[file:~/src/org-babel/.emacs.org::*org%20config][block-1]] (add-to-list 'load-path "/usr/local/src/org-mode/lisp") (require 'org-install) ;; block-1 ends here ;; [[file:~/src/org-babel/.emacs.org::*org%20babel%20config][block-2]] (add-to-list 'load-path "~/src/org-babel/lisp") (require 'org-babel-init) (setq org-babel-tangle-langs '(("python" . ("py" "#!/usr/bin/env python")) ("R" . ("R" "#!/usr/bin/env R")) ("sh" . ("sh" "#!/usr/bin/env bash")) ("emacs-lisp" . ("el" "")))) ;; block-2 ends here --8<---------------cut here---------------end--------------->8--- > > Scot > > > _______________________________________________ > Emacs-orgmode mailing list > Remember: use `Reply All' to send replies to the list. > Emacs-orgmode@gnu.org > http://lists.gnu.org/mailman/listinfo/emacs-orgmode