[Top][All Lists]
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
Re: [O] source code folding
From: |
Memnon Anon |
Subject: |
Re: [O] source code folding |
Date: |
Mon, 28 May 2012 16:25:08 +0000 (UTC) |
Puneeth Chaganti <address@hidden> 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