emacs-orgmode
[Top][All Lists]
Advanced

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

Re: [Orgmode] Embedding org-syntax in program source


From: Dan Davison
Subject: Re: [Orgmode] Embedding org-syntax in program source
Date: Tue, 13 Apr 2010 12:12:27 -0400
User-agent: Gnus/5.13 (Gnus v5.13) Emacs/23.1.50 (gnu/linux)

LanX <address@hidden> 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.
> address@hidden
> http://lists.gnu.org/mailman/listinfo/emacs-orgmode




reply via email to

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