From mboxrd@z Thu Jan 1 00:00:00 1970 From: Grant Rettke Subject: Re: How to show/hide the snippet block in org-babel when the cursor is inside the snippet text Date: Tue, 16 Dec 2014 19:42:53 -0600 Message-ID: References: Mime-Version: 1.0 Content-Type: multipart/alternative; boundary=047d7b5d61941ce2e4050a5f981b Return-path: Received: from eggs.gnu.org ([2001:4830:134:3::10]:56210) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1Y13dh-0002FX-8G for emacs-orgmode@gnu.org; Tue, 16 Dec 2014 20:42:58 -0500 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1Y13df-0004CE-Ny for emacs-orgmode@gnu.org; Tue, 16 Dec 2014 20:42:57 -0500 Received: from mail-wg0-x22a.google.com ([2a00:1450:400c:c00::22a]:61111) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1Y13df-0004C2-DS for emacs-orgmode@gnu.org; Tue, 16 Dec 2014 20:42:55 -0500 Received: by mail-wg0-f42.google.com with SMTP id k14so2785783wgh.15 for ; Tue, 16 Dec 2014 17:42:53 -0800 (PST) In-Reply-To: List-Id: "General discussions about Org-mode." List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: emacs-orgmode-bounces+geo-emacs-orgmode=m.gmane.org@gnu.org Sender: emacs-orgmode-bounces+geo-emacs-orgmode=m.gmane.org@gnu.org To: Oleh Cc: "emacs-orgmode@gnu.org" , Ivanov Dmitry --047d7b5d61941ce2e4050a5f981b Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: quoted-printable I use `org-babel-next-src-block' and `org-babel-previous-src-block' to go up and down and rely on the org folding. Not a streamlined approach but it works because I use it rarely. On Tue, Dec 16, 2014 at 6:01 AM, Oleh wrote: > > Hi Dmitry, > > > I would like to implement the following. Suppose, we have this org file= : > > > > #+BABEL: :cache yes :tangle yes :noweb yes > > > > #+NAME: top_block > > #+begin_src perl :tangle "test.pl" :noweb tangle :shebang > #!/usr/bin/perl > > use strict; > > use warnings; > > > > open(my $fh, "<", "test.txt") > > or die "cannot open < file name: $!"; > > <> > > close($fh); > > #+end_src > > > > #+NAME: output-all > > #+begin_src perl > > while (my $line =3D <$fh>) { > > print $line; > > } > > #+end_src > > > > I can expand/collapse src blocks only when the cursor is on the top > lines: > > > > > > #+NAME: top_block > > #+begin_src perl ... > > > > But when it is inside any text in the scr block, expand/collapse doesn'= t > > work. How can I add this functionality as moving the cursor every time = is > > not nice. > > There's a feature like this in https://github.com/abo-abo/worf > (installable also from MELPA). > > If you're in a source block, "[" will bring you to its start, and "i" > will hide/unhide it. > > You can use "j"/"k"/"i" to quickly navigate and fold many source > blocks within one heading. > > regards, > Oleh > > --=20 Grant Rettke gcr@wisdomandwonder.com | http://www.wisdomandwonder.com/ =E2=80=9CWisdom begins in wonder.=E2=80=9D --Socrates ((=CE=BB (x) (x x)) (=CE=BB (x) (x x))) =E2=80=9CLife has become immeasurably better since I have been forced to st= op taking it seriously.=E2=80=9D --Thompson --047d7b5d61941ce2e4050a5f981b Content-Type: text/html; charset=UTF-8 Content-Transfer-Encoding: quoted-printable
I use `org-babel-next-src-block' and `org-babel-previo= us-src-block' =C2=A0to go up and down and rely on the org folding. Not = a streamlined approach but it works because I use it rarely.

On Tue, Dec 16, 2014 at 6:= 01 AM, Oleh <ohwoeowho@gmail.com> wrote:
Hi Dmitry,

> I would like to implement the following. Suppose, we have this org fil= e:
>
> #+BABEL: :cache yes :tangle yes :noweb yes
>
> #+NAME: top_block
> #+begin_src perl :tangle "test.pl" :noweb tangle :shebang #!/usr/bin/perl
>=C2=A0 =C2=A0use strict;
>=C2=A0 =C2=A0use warnings;
>
>=C2=A0 =C2=A0open(my $fh, "<", "test.txt")
>=C2=A0 =C2=A0 =C2=A0 =C2=A0or die "cannot open < file name: $!&= quot;;
>=C2=A0 =C2=A0<<output-all>>
>=C2=A0 =C2=A0close($fh);
> #+end_src
>
> #+NAME: output-all
> #+begin_src perl
>=C2=A0 =C2=A0while (my $line =3D <$fh>) {
>=C2=A0 =C2=A0 =C2=A0 =C2=A0print $line;
>=C2=A0 =C2=A0}
> #+end_src
>
> I can expand/collapse src blocks only when the cursor is on the top li= nes:
>
>
> #+NAME: top_block
> #+begin_src perl ...
>
> But when it is inside any text in the scr block, expand/collapse doesn= 't
> work. How can I add this functionality as moving the cursor every time= is
> not nice.

There's a feature like this in https://github.com/abo-abo/worf
(installable also from MELPA).

If you're in a source block, "[" will bring you to its start,= and "i"
will hide/unhide it.

You can use "j"/"k"/"i" to quickly navigate a= nd fold many source
blocks within one heading.

regards,
Oleh



--
Grant Rettke
gcr@wisdomandwonder.com | http://www.wisdomandwonder.com/
= =E2=80=9CWisdom begins in wonder.=E2=80=9D --Socrates
((=CE=BB (x) (x x)= ) (=CE=BB (x) (x x)))
=E2=80=9CLife has become immeasurably better since= I have been forced to stop taking it seriously.=E2=80=9D --Thompson
--047d7b5d61941ce2e4050a5f981b--