[Top][All Lists]
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
Re: [O] source code folding
From: |
Petro Khoroshyy |
Subject: |
Re: [O] source code folding |
Date: |
Tue, 29 May 2012 10:46:29 +0200 |
User-agent: |
Gnus/5.13 (Gnus v5.13) Emacs/23.2 (gnu/linux) |
Memnon Anon <address@hidden> writes:
> 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
Thanks all.
This is exactly what I need.