Re: [O] source code folding

2012-05-29 Thread Petro Khoroshyy
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.





[O] source code folding

2012-05-28 Thread Petro Khoroshyy
Hi all.
I can fold source code block using TAB key on begin_src block. Is there
a shortcut to do it within source code block, without navigation to
begin_src line?
Thanks.
Petro.




Re: [O] source code folding

2012-05-28 Thread Puneeth Chaganti
On Mon, May 28, 2012 at 8:42 PM, Petro Khoroshyy khoros...@gmail.com wrote:
 Hi all.
 I can fold source code block using TAB key on begin_src block. Is there
 a shortcut to do it within source code block, without navigation to
 begin_src line?

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))


Hope that helps,
Puneeth



Re: [O] source code folding

2012-05-28 Thread Memnon Anon
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




Re: [O] source code folding

2012-05-28 Thread Eric Schulte
Petro Khoroshyy khoros...@gmail.com writes:

 Hi all.
 I can fold source code block using TAB key on begin_src block. Is there
 a shortcut to do it within source code block, without navigation to
 begin_src line?
 Thanks.
 Petro.



Hi Petro,

Such functionality is not provided by default, but the
`org-hide-block-toggle' command does perform this action, and you could
assign it a keybinding in your personal config to make it easy to call.

Best,

-- 
Eric Schulte
http://cs.unm.edu/~eschulte