emacs-orgmode@gnu.org archives
 help / color / mirror / code / Atom feed
From: Memnon Anon <gegendosenfleisch@googlemail.com>
To: emacs-orgmode@gnu.org
Subject: Re: source code folding
Date: Mon, 28 May 2012 16:25:08 +0000 (UTC)	[thread overview]
Message-ID: <874nr0mgjy.fsf@mean.albasani.net> (raw)
In-Reply-To: CALnw1fTMxRba5DCNwhpMjsOhV=wwoHGUaJ2NnOE9puGvdZTQoQ@mail.gmail.com

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

  reply	other threads:[~2012-05-28 16:25 UTC|newest]

Thread overview: 5+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2012-05-28 15:12 source code folding Petro Khoroshyy
2012-05-28 15:46 ` Puneeth Chaganti
2012-05-28 16:25   ` Memnon Anon [this message]
2012-05-29  8:46     ` Petro Khoroshyy
2012-05-28 16:38 ` Eric Schulte

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

  List information: https://www.orgmode.org/

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=874nr0mgjy.fsf@mean.albasani.net \
    --to=gegendosenfleisch@googlemail.com \
    --cc=emacs-orgmode@gnu.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
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).