Memnon Anon <gegendosenflei...@googlemail.com> writes:
> Puneeth Chaganti <puncha...@gmail.com> 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.