From mboxrd@z Thu Jan 1 00:00:00 1970 Path: news.gmane.org!not-for-mail From: Jambunathan K Newsgroups: gmane.emacs.help Subject: Re: code folding Date: Tue, 16 Aug 2011 17:09:06 +0530 Message-ID: <81y5ytbn6t.fsf@gmail.com> References: <81tya0kdfc.fsf@gmail.com> <87bovvf5gr.fsf@altern.org> <817h6hvzni.fsf@gmail.com> NNTP-Posting-Host: lo.gmane.org Mime-Version: 1.0 Content-Type: text/plain X-Trace: dough.gmane.org 1313494807 20558 80.91.229.12 (16 Aug 2011 11:40:07 GMT) X-Complaints-To: usenet@dough.gmane.org NNTP-Posting-Date: Tue, 16 Aug 2011 11:40:07 +0000 (UTC) Cc: help-gnu-emacs To: Le Wang Original-X-From: help-gnu-emacs-bounces+geh-help-gnu-emacs=m.gmane.org@gnu.org Tue Aug 16 13:40:03 2011 Return-path: Envelope-to: geh-help-gnu-emacs@m.gmane.org Original-Received: from lists.gnu.org ([140.186.70.17]) by lo.gmane.org with esmtp (Exim 4.69) (envelope-from ) id 1QtI01-0002Z7-Us for geh-help-gnu-emacs@m.gmane.org; Tue, 16 Aug 2011 13:40:02 +0200 Original-Received: from localhost ([::1]:57774 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1QtHzz-0000Gr-6S for geh-help-gnu-emacs@m.gmane.org; Tue, 16 Aug 2011 07:39:59 -0400 Original-Received: from eggs.gnu.org ([140.186.70.92]:36398) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1QtHzu-0000Ga-Bb for help-gnu-emacs@gnu.org; Tue, 16 Aug 2011 07:39:55 -0400 Original-Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1QtHzt-0005Gx-Ci for help-gnu-emacs@gnu.org; Tue, 16 Aug 2011 07:39:54 -0400 Original-Received: from mail-pz0-f44.google.com ([209.85.210.44]:44623) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1QtHzt-0005Gp-3i for help-gnu-emacs@gnu.org; Tue, 16 Aug 2011 07:39:53 -0400 Original-Received: by pzk36 with SMTP id 36so10627312pzk.17 for ; Tue, 16 Aug 2011 04:39:52 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=gamma; h=from:to:cc:subject:references:date:in-reply-to:message-id :user-agent:mime-version:content-type; bh=j2MS4RF+Ns32cPjo2PmgEv73QwmzuGd02HwBvrPbkz4=; b=qZUmN9JWOVEvsIzUmahyRvH4n/bQRP4byCUoCP6+7bBW/C6BeUf4+oG8jbTPqi8Z95 f2nOFsb0cy7Dv8JMEUmdKaQe5QwUkJtQxxsBJPZDa7yBF+PCAJei74jFb7pNIp+BdJpp lTC66bSOmFpTjsvbY08dJOa4qjDCMV4n2fwVc= Original-Received: by 10.143.97.40 with SMTP id z40mr2522765wfl.7.1313494792126; Tue, 16 Aug 2011 04:39:52 -0700 (PDT) Original-Received: from JAMBU-NETBOOK ([115.242.216.8]) by mx.google.com with ESMTPS id n3sm12641pbi.5.2011.08.16.04.39.45 (version=TLSv1/SSLv3 cipher=OTHER); Tue, 16 Aug 2011 04:39:51 -0700 (PDT) In-Reply-To: (Le Wang's message of "Tue, 16 Aug 2011 18:39:10 +0800") User-Agent: Gnus/5.13 (Gnus v5.13) Emacs/24.0.50 (windows-nt) X-detected-operating-system: by eggs.gnu.org: GNU/Linux 2.6 (newer, 2) X-Received-From: 209.85.210.44 X-BeenThere: help-gnu-emacs@gnu.org X-Mailman-Version: 2.1.14 Precedence: list List-Id: Users list for the GNU Emacs text editor List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: help-gnu-emacs-bounces+geh-help-gnu-emacs=m.gmane.org@gnu.org Original-Sender: help-gnu-emacs-bounces+geh-help-gnu-emacs=m.gmane.org@gnu.org Xref: news.gmane.org gmane.emacs.help:81959 Archived-At: 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 such. 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. --