From mboxrd@z Thu Jan 1 00:00:00 1970 From: Michael Zeller Subject: Re: org-style folding for a .emacs Date: Mon, 13 Jul 2009 16:07:52 -0700 Message-ID: <87bpnonpvb.fsf@zeller.michaelzeller.com> References: 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 1MQUdb-0004HA-20 for emacs-orgmode@gnu.org; Mon, 13 Jul 2009 19:08:47 -0400 Received: from exim by lists.gnu.org with spam-scanned (Exim 4.43) id 1MQUdV-0004Gy-M0 for emacs-orgmode@gnu.org; Mon, 13 Jul 2009 19:08:45 -0400 Received: from [199.232.76.173] (port=60555 helo=monty-python.gnu.org) by lists.gnu.org with esmtp (Exim 4.43) id 1MQUdV-0004Gv-EM for emacs-orgmode@gnu.org; Mon, 13 Jul 2009 19:08:41 -0400 Received: from mail-pz0-f202.google.com ([209.85.222.202]:46039) by monty-python.gnu.org with esmtp (Exim 4.60) (envelope-from ) id 1MQUdU-0000ih-Sv for emacs-orgmode@gnu.org; Mon, 13 Jul 2009 19:08:41 -0400 Received: by pzk40 with SMTP id 40so1319025pzk.14 for ; Mon, 13 Jul 2009 16:08:39 -0700 (PDT) In-Reply-To: (Scot Becker's message of "Mon, 13 Jul 2009 22:23:51 +0100") 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: Scot Becker Cc: Org-mode ml 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 "") '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 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. > Emacs-orgmode@gnu.org > http://lists.gnu.org/mailman/listinfo/emacs-orgmode