emacs-orgmode@gnu.org archives
 help / color / mirror / code / Atom feed
From: Dan Davison <davison@stats.ox.ac.uk>
To: LanX <lanx.perl@googlemail.com>
Cc: emacs-orgmode@gnu.org
Subject: Re: Embedding org-syntax in program source
Date: Tue, 13 Apr 2010 12:12:27 -0400	[thread overview]
Message-ID: <8739yzuyac.fsf@stats.ox.ac.uk> (raw)
In-Reply-To: <w2uec36f5051004130332raebf162cy68d42f8c88c62854@mail.gmail.com> (LanX's message of "Tue, 13 Apr 2010 12:32:43 +0200")

LanX <lanx.perl@googlemail.com> writes:

> Hi
>
> is there a way to make org-mode ignore "comment" characters at the beginning of
> a line?
>
> Such that
> ;* Head
>
> or
> #** Subhead
>
> work in elisp or perl?

Hi Rolf,

Short answer: yes. There are a bunch of good solutions out there, but it
would really benefit from someone putting together a summary tutorial on
Worg.

There are basically two types of solution: org-mode with tangling, and
use of outline-minor-mode (with some org machinery) in pure code files.

> I know of org-babel, but the code produced is no legal Lisp/Perl code
> anymore...

So first let me double-check that you are aware of org-babel-tangle?
That generates legal code from the org file. For example, I would really
recommend trying the org-mode route for an emacs configuration
file. There's support specifically for that
(http://orgmode.org/worg/org-contrib/babel/intro.php#literate-programming
and scroll down to Emacs Initialization with Org-babel)

I'm the secondary author of org-babel, but I don't intend to come across
as a myopic tangling zealot here. For new projects now I do tend to use
org-mode with tangling, but outline-minor-mode is still absolutely
essential to me for working on existing code in traditional format (as
well as large fragments of code held within org files).

Check out this thread from last year. The key post is this one from
Michael Zeller and subsequent ones by Seb Vauban. Ignore all mention of
org-babel in this thread as there has been 9 months of active
development since then.

http://article.gmane.org/gmane.emacs.orgmode/15427/match=org+style+folding

Personally I'm still using a fairly simple outline-minor-mode setup. For
what it's worth, here is my o-m-m config, but I've had this for ages now
and it needs revisiting. This will make elisp fold at ;;; as well as at
all top-level lisp forms. But the regexps below haven't been carefully
thought about.

(defun dan/set-up-outline-minor-mode (local-outline-regexp)
  (set (make-local-variable 'outline-regexp) local-outline-regexp)
  (outline-minor-mode t)
  (org-overview)
  (org-content))

(add-hook 'outline-minor-mode-hook
  (lambda ()
    (define-key outline-minor-mode-map [(control tab)] 'org-cycle)
    (define-key outline-minor-mode-map [(backtab)] 'org-global-cycle)))

(add-hook 'emacs-lisp-mode-hook
          (lambda () (dan/set-up-outline-minor-mode "\\((\\|;;;\\)")))
(add-hook 'python-mode-hook
          (lambda () (dan/set-up-outline-minor-mode "\\( *def \\|if \\|class \\|##\\)")))
(add-hook 'bibtex-mode-hook
          (lambda () (dan/set-up-outline-minor-mode "@")))
(add-hook 'ess-mode-hook
          (lambda () 
            (unless (eq noweb-code-mode 'R-mode)
              (dan/set-up-outline-minor-mode "[a-zA-Z._[\"][a-zA-Z._0-9[\"]* *<- *function"))))

I think this topic can be confusing. E.g. what about Carsten's
outline-magic.el ?? Is there a role for that? Like I say this would be a
good topic for a Worg page.

Dan

>
> Thanks
>   Rolf
> _______________________________________________
> Emacs-orgmode mailing list
> Please 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:[~2010-04-13 16:13 UTC|newest]

Thread overview: 9+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2010-04-13 10:32 Embedding org-syntax in program source LanX
2010-04-13 15:08 ` Eric Schulte
     [not found]   ` <y2wec36f5051004130835k5d850907h35f6645b5f5fef17@mail.gmail.com>
2010-04-13 15:40     ` LanX
2010-04-13 16:47       ` Eric Schulte
2010-04-13 21:31       ` Dan Davison
2010-04-13 23:54         ` LanX
2010-04-14 12:39           ` Sebastian Rose
2010-04-14 15:22           ` Dan Davison
2010-04-13 16:12 ` Dan Davison [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=8739yzuyac.fsf@stats.ox.ac.uk \
    --to=davison@stats.ox.ac.uk \
    --cc=emacs-orgmode@gnu.org \
    --cc=lanx.perl@googlemail.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).