emacs-orgmode
[Top][All Lists]
Advanced

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

Re: [Orgmode] org-style folding for a .emacs


From: Michael Zeller
Subject: Re: [Orgmode] org-style folding for a .emacs
Date: Mon, 13 Jul 2009 16:07:52 -0700
User-agent: Gnus/5.13 (Gnus v5.13) Emacs/23.1.50 (gnu/linux)

Scot,

I've found a similar solution in a previous thread:
http://thread.gmane.org/gmane.emacs.orgmode/12094/focus=12105

In summary, add the following to your ~/.emacs.el:

  ;; outline-minor-mode
(defun prompt-for-outline-regexp (new-regexp)
  "ask the user for a local value of outline-regexp in this buffer"
  (interactive "Outline regexp: ")
  (set (make-local-variable 'outline-regexp) new-regexp)
)

(global-set-key (kbd "<f9>") 'prompt-for-outline-regexp) 

(defun th-outline-regexp ()
 "Calculate the outline regexp for the current mode."
 (let ((comment-starter (replace-regexp-in-string
                         "[[:space:]]+" "" comment-start)))
   (when (string= comment-start ";")
     (setq comment-starter ";;"))
   (concat "^" comment-starter "\\*+")))

(defun th-outline-minor-mode-init ()
 (interactive)
 (setq outline-regexp (th-outline-regexp)))

(add-hook 'outline-minor-mode-hook
          'th-outline-minor-mode-init)

(global-set-key [M-tab] 'org-cycle)
(global-set-key [M-left] 'hide-body)
(global-set-key [M-right] 'show-all)
(global-set-key [M-up] 'outline-previous-heading)
(global-set-key [M-down] 'outline-next-heading)
(global-set-key [C-M-left] 'hide-sublevels)
(global-set-key [C-M-right] 'show-children)
(global-set-key [C-M-up] 'outline-previous-visible-heading)
(global-set-key [C-M-down] 'outline-next-visible-heading)

and add the following as the top line of your ~/.emacs.el:

; -*- mode: emacs-lisp; mode: outline-minor; -*-

Now you can add ;;* and ;;**, etc as headings in your .emacs.el and
cycle using M-tab, M-left and M-right will collapse or expand all
headings respectively. I am guessing you mean to make segments such as
;;* SHORTCUTS and ;;* VARIABLES, this will do that, but not too much
more.

I haven't tried hideshow before, but this solution has worked for me in
other modes, particularly in R-mode, where you use #*, #**, etc,
instead. Just remember to activate outline-minor-mode.

Thanks go to Tassilo Horn,
~Michael Zeller

Scot Becker <address@hidden> writes:

> 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.
>
> Scot
>
>
> _______________________________________________
> Emacs-orgmode mailing list
> Remember: 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]