emacs-orgmode@gnu.org archives
 help / color / mirror / code / Atom feed
From: Dan Davison <davison@stats.ox.ac.uk>
To: Scot Becker <scot.becker@gmail.com>
Cc: Org-mode ml <emacs-orgmode@gnu.org>
Subject: Re: org-style folding for a .emacs
Date: Mon, 13 Jul 2009 19:26:49 -0400	[thread overview]
Message-ID: <8763dwxiyu.fsf@stats.ox.ac.uk> (raw)
In-Reply-To: <e0e1fe620907131423v5ac3b416u1c1ee37f6c0a9cdf@mail.gmail.com> (Scot Becker's message of "Mon, 13 Jul 2009 22:23:51 +0100")

Scot Becker <scot.becker@gmail.com> 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

  parent reply	other threads:[~2009-07-13 23:27 UTC|newest]

Thread overview: 15+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2009-07-13 21:23 org-style folding for a .emacs Scot Becker
2009-07-13 22:56 ` Eric S Fraga
2009-07-13 23:07 ` Michael Zeller
2009-07-14 11:55   ` Sébastien Vauban
2009-07-15  3:12     ` Michael Zeller
2009-07-15 15:52       ` Sébastien Vauban
2009-07-13 23:26 ` Dan Davison [this message]
2009-07-14 11:01   ` Scot Becker
2009-07-15  5:17     ` Eric Schulte
2009-07-15 21:02       ` Sébastien Vauban
2009-07-16 23:31         ` Eric Schulte
2009-07-28 14:39           ` Sébastien Vauban
2009-07-30  0:51             ` Eric Schulte
2009-07-16  1:02 ` Daniel Clemente
2009-07-16 19:50 ` Bastien

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=8763dwxiyu.fsf@stats.ox.ac.uk \
    --to=davison@stats.ox.ac.uk \
    --cc=emacs-orgmode@gnu.org \
    --cc=scot.becker@gmail.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).