From mboxrd@z Thu Jan 1 00:00:00 1970 From: Petro Khoroshyy Subject: Re: source code folding Date: Tue, 29 May 2012 10:46:29 +0200 Message-ID: <8762bfe5ne.fsf@cica.cica> References: <87ehq4figm.fsf@cica.cica> <874nr0mgjy.fsf@mean.albasani.net> Mime-Version: 1.0 Content-Type: text/plain; charset=us-ascii Return-path: Received: from eggs.gnu.org ([208.118.235.92]:59041) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1SZI4t-0006Z4-CB for emacs-orgmode@gnu.org; Tue, 29 May 2012 04:47:01 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1SZI4j-0005Xm-8T for emacs-orgmode@gnu.org; Tue, 29 May 2012 04:46:54 -0400 Received: from plane.gmane.org ([80.91.229.3]:36498) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1SZI4j-0005X9-1b for emacs-orgmode@gnu.org; Tue, 29 May 2012 04:46:45 -0400 Received: from list by plane.gmane.org with local (Exim 4.69) (envelope-from ) id 1SZI4e-00068u-Ul for emacs-orgmode@gnu.org; Tue, 29 May 2012 10:46:40 +0200 Received: from 0x4dd745cf.adsl.cybercity.dk ([77.215.69.207]) by main.gmane.org with esmtp (Gmexim 0.1 (Debian)) id 1AlnuQ-0007hv-00 for ; Tue, 29 May 2012 10:46:40 +0200 Received: from khoroshyy by 0x4dd745cf.adsl.cybercity.dk with local (Gmexim 0.1 (Debian)) id 1AlnuQ-0007hv-00 for ; Tue, 29 May 2012 10:46:40 +0200 List-Id: "General discussions about Org-mode." List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: emacs-orgmode-bounces+geo-emacs-orgmode=m.gmane.org@gnu.org Sender: emacs-orgmode-bounces+geo-emacs-orgmode=m.gmane.org@gnu.org To: emacs-orgmode@gnu.org Memnon Anon writes: > Puneeth Chaganti writes: > >> I'm not sure there's such a short cut, but you can define one for yourself. >> >> A simple function (without any sort of error checking) like the one >> below can be bound to a key-binding of your choice. >> >> ------------------------------------------------------------------------ >> (defun my/collapse-src-block () >> "Collapses a source block when called from inside a block." >> (interactive) >> (org-babel-goto-src-block-head) >> (org-cycle)) >> ------------------------------------------------------------------------ > > org-narrow-to-block should do it when modified slightly: > > #+begin_src emacs-lisp > (defun my-org-toggle-current-block () > "Un-/Collapses a block when called from inside a block." > (interactive) > (let* ((case-fold-search t) > (blockp (org-between-regexps-p "^[ \t]*#\\+begin_.*" > "^[ \t]*#\\+end_.*"))) > (if (not blockp) > (message "Not in a block") > (goto-char (car blockp)) > (org-cycle)))) > #+end_src Thanks all. This is exactly what I need.