emacs-orgmode@gnu.org archives
 help / color / mirror / code / Atom feed
* source code folding
@ 2012-05-28 15:12 Petro Khoroshyy
  2012-05-28 15:46 ` Puneeth Chaganti
  2012-05-28 16:38 ` Eric Schulte
  0 siblings, 2 replies; 5+ messages in thread
From: Petro Khoroshyy @ 2012-05-28 15:12 UTC (permalink / raw)
  To: emacs-orgmode

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.

^ permalink raw reply	[flat|nested] 5+ messages in thread

* Re: source code folding
  2012-05-28 15:12 source code folding Petro Khoroshyy
@ 2012-05-28 15:46 ` Puneeth Chaganti
  2012-05-28 16:25   ` Memnon Anon
  2012-05-28 16:38 ` Eric Schulte
  1 sibling, 1 reply; 5+ messages in thread
From: Puneeth Chaganti @ 2012-05-28 15:46 UTC (permalink / raw)
  To: Petro Khoroshyy; +Cc: emacs-orgmode

On Mon, May 28, 2012 at 8:42 PM, Petro Khoroshyy <khoroshyy@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

^ permalink raw reply	[flat|nested] 5+ messages in thread

* Re: source code folding
  2012-05-28 15:46 ` Puneeth Chaganti
@ 2012-05-28 16:25   ` Memnon Anon
  2012-05-29  8:46     ` Petro Khoroshyy
  0 siblings, 1 reply; 5+ messages in thread
From: Memnon Anon @ 2012-05-28 16:25 UTC (permalink / raw)
  To: emacs-orgmode

Puneeth Chaganti <punchagan@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

^ permalink raw reply	[flat|nested] 5+ messages in thread

* Re: source code folding
  2012-05-28 15:12 source code folding Petro Khoroshyy
  2012-05-28 15:46 ` Puneeth Chaganti
@ 2012-05-28 16:38 ` Eric Schulte
  1 sibling, 0 replies; 5+ messages in thread
From: Eric Schulte @ 2012-05-28 16:38 UTC (permalink / raw)
  To: Petro Khoroshyy; +Cc: emacs-orgmode

Petro Khoroshyy <khoroshyy@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

^ permalink raw reply	[flat|nested] 5+ messages in thread

* Re: source code folding
  2012-05-28 16:25   ` Memnon Anon
@ 2012-05-29  8:46     ` Petro Khoroshyy
  0 siblings, 0 replies; 5+ messages in thread
From: Petro Khoroshyy @ 2012-05-29  8:46 UTC (permalink / raw)
  To: emacs-orgmode

Memnon Anon <gegendosenfleisch@googlemail.com> writes:

> Puneeth Chaganti <punchagan@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.

^ permalink raw reply	[flat|nested] 5+ messages in thread

end of thread, other threads:[~2012-05-29  8:47 UTC | newest]

Thread overview: 5+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2012-05-28 15:12 source code folding Petro Khoroshyy
2012-05-28 15:46 ` Puneeth Chaganti
2012-05-28 16:25   ` Memnon Anon
2012-05-29  8:46     ` Petro Khoroshyy
2012-05-28 16:38 ` Eric Schulte

Code repositories for project(s) associated with this public inbox

	https://git.savannah.gnu.org/cgit/emacs/org-mode.git

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).