[Top][All Lists]

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

Re: code folding

From: Jambunathan K
Subject: Re: code folding
Date: Tue, 16 Aug 2011 17:09:06 +0530
User-agent: Gnus/5.13 (Gnus v5.13) Emacs/24.0.50 (windows-nt)

Le Wang <> writes:

> On Sun, Aug 14, 2011 at 4:12 AM, Jambunathan K <> wrote:
>> Look at bindings effective while in orgstruct(++)-mode.
>> Do a C-h b and search for orgstruct.
> I have the following code in my ruby-mode-hook to enable code folding
> using outline-minor-mode + outline-magic.
> (outline-minor-mode 1)
> (set (make-local-variable 'outline-regexp) "^[ \t]*\\(?:def
> \\|class\\|module\\)\\|^[ \t]*###==")

Did you try the suggestion in the FAQ that I pointed to?

While in emacs-lisp-mode + outline-minor-mode + below mentioned-hook,,
C-TAB and S-TAB fold and unfold the defuns as expected. Note that for
C-TAB to work, the cursor needs to be on a headline (the line where the
ellipsis shows)

You don't have to do any additional settings for code folding to work.

| Can I get the visibility-cycling features in outline-mode and
| outline-minor-mode?
| Yes, these functions are written in a way that they are independent of
| the outline setup. The following setup provides standard Org-mode
| functionality in outline-mode on TAB and S-TAB. For outline-minor-mode,
| we use C-TAB instead of TAB, because TAB usually has mode-specific
| tasks.
| (add-hook 'outline-minor-mode-hook
|   (lambda ()
|     (define-key outline-minor-mode-map [(control tab)] 'org-cycle)
|     (define-key outline-minor-mode-map [(shift tab)] 'org-global-cycle)))
| (add-hook 'outline-mode-hook
|   (lambda ()
|     (define-key outline-mode-map [(tab)] 'org-cycle)
|     (define-key outline-mode-map [(shift tab)] 'org-global-cycle)))
| Or check out outline-magic.el, which does this and also provides
| promotion and demotion functionality. outline-magic.el is available at
| Outline Magic.

> What's the equivalent in orgstruct?  org-outline-regexp seems
> interesting but isn't documented.

orgstruct mode is for editing org-like text in other modes - like
message mode etc. It has NOTHING to do with folding of code as

In summary, in a ruby buffer,

1. Add the above hook for folding and unfolding ruby functions.
2. Turn orgstruct++-mode for editing comments that look like a org-like
   plain-text tree.


reply via email to

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