From mboxrd@z Thu Jan 1 00:00:00 1970 From: "Eric Schulte" Subject: Using other modes in org-mode Date: Wed, 10 Sep 2008 16:39:02 -0700 Message-ID: <87iqt3zi3t.fsf@gmail.com> 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 1KdZHB-00086D-0s for emacs-orgmode@gnu.org; Wed, 10 Sep 2008 19:39:09 -0400 Received: from exim by lists.gnu.org with spam-scanned (Exim 4.43) id 1KdZH8-00085A-Oo for emacs-orgmode@gnu.org; Wed, 10 Sep 2008 19:39:08 -0400 Received: from [199.232.76.173] (port=39505 helo=monty-python.gnu.org) by lists.gnu.org with esmtp (Exim 4.43) id 1KdZH8-000854-C6 for emacs-orgmode@gnu.org; Wed, 10 Sep 2008 19:39:06 -0400 Received: from mail-gx0-f12.google.com ([209.85.217.12]:46465) by monty-python.gnu.org with esmtp (Exim 4.60) (envelope-from ) id 1KdZH7-0006cV-Rd for emacs-orgmode@gnu.org; Wed, 10 Sep 2008 19:39:06 -0400 Received: by gxk5 with SMTP id 5so14989090gxk.18 for ; Wed, 10 Sep 2008 16:39:04 -0700 (PDT) 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 Cc: LBorgman Hi, Here is some code for using other major modes inside of org-mode. It uses blocks like the org-mode "#+BEGIN_SOURCE", "#+END_SOURCE" blocks. This is sort of fun to play with but not necessarily stable. Thanks to Lennart for showing me how the MuMaMo code works. Requires MuMaMo-mode http://www.emacswiki.org/cgi-bin/wiki/MuMaMo In order to try this out... 1) eval the following elisp forms (change the value of mumamo-org-modes if you want to try other modes) (require 'mumamo) (defvar mumamo-org-modes '(ruby-mode emacs-lisp-mode c-mode) "Modes to include in org-files") (defvar mumamo-org-chunk-functions (mapcar (lambda (mode) (eval `(defun ,(intern (format "mumamo-chunk-org-%S" mode)) (pos min max) ,(format "%s support inside org BEGIN END blocks" mode) (mumamo-quick-static-chunk pos min max ,(format "#+BEGIN_%S" mode) ,(format "#+END_%S" mode) t (quote ,mode) nil)))) mumamo-org-modes) "The automatically defined mumamo-chunk-org-* functions for use cramming other modes into org-mode. See `mumamo-org-modes' `mumamo-quick-static-chunk'.") (eval `(define-mumamo-multi-major-mode org-mumamo-mode ,(format "Turn on multiple major modes with main major mode org-mode.\n\n%s" (mapconcat (lambda (el) (format "- %S" el)) mumamo-org-modes "\n")) ("Org Source Blocks Family" org-mode ,mumamo-org-chunk-functions))) 2) open a buffer containing something like the following * testing this out - regular org-mode in these lines #+BEGIN_ruby-mode # ruby-mode active in the block def eric # nothing else end #+END_ruby-mode #+BEGIN_emacs-lisp-mode (defun this-is-lisp () ) #+END_emacs-lisp-mode 3) M-x org-mumamo-mode