From mboxrd@z Thu Jan 1 00:00:00 1970 From: Memnon Anon Subject: Re: source code folding Date: Mon, 28 May 2012 16:25:08 +0000 (UTC) Message-ID: <874nr0mgjy.fsf@mean.albasani.net> References: <87ehq4figm.fsf@cica.cica> Mime-Version: 1.0 Content-Type: text/plain Return-path: Received: from eggs.gnu.org ([208.118.235.92]:53922) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1SZ2l2-00044J-G2 for emacs-orgmode@gnu.org; Mon, 28 May 2012 12:25:25 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1SZ2kx-0000A9-OU for emacs-orgmode@gnu.org; Mon, 28 May 2012 12:25:24 -0400 Received: from plane.gmane.org ([80.91.229.3]:43488) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1SZ2kx-00009l-Hr for emacs-orgmode@gnu.org; Mon, 28 May 2012 12:25:19 -0400 Received: from list by plane.gmane.org with local (Exim 4.69) (envelope-from ) id 1SZ2ku-0008Cf-Pt for emacs-orgmode@gnu.org; Mon, 28 May 2012 18:25:16 +0200 Received: from e178210078.adsl.alicedsl.de ([85.178.210.78]) by main.gmane.org with esmtp (Gmexim 0.1 (Debian)) id 1AlnuQ-0007hv-00 for ; Mon, 28 May 2012 18:25:16 +0200 Received: from gegendosenfleisch by e178210078.adsl.alicedsl.de with local (Gmexim 0.1 (Debian)) id 1AlnuQ-0007hv-00 for ; Mon, 28 May 2012 18:25:16 +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 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