all messages for Emacs-related lists mirrored at yhetil.org
 help / color / mirror / code / Atom feed
* Arbitrary folding in emacs
@ 2014-03-28  9:06 C K Kashyap
  2014-03-28  9:12 ` Eli Zaretskii
                   ` (2 more replies)
  0 siblings, 3 replies; 17+ messages in thread
From: C K Kashyap @ 2014-03-28  9:06 UTC (permalink / raw
  To: help-gnu-emacs@gnu.org

I am trying to go-over a huge c++ file. In vim, I can collapse a huge set
of lines by simply highlighting it an then doing a zf. I was wondering if I
can do something similar in emacs - rather how I can do it in emacs.

I tried hs-minor-mode but it appears to have pre-defined notions of
"foldable" blocks.

Regards,
Kashyap


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

* Re: Arbitrary folding in emacs
  2014-03-28  9:06 Arbitrary folding in emacs C K Kashyap
@ 2014-03-28  9:12 ` Eli Zaretskii
  2014-03-28  9:25   ` C K Kashyap
  2014-03-28 20:00 ` Thien-Thi Nguyen
  2014-03-31  8:02 ` Andreas Röhler
  2 siblings, 1 reply; 17+ messages in thread
From: Eli Zaretskii @ 2014-03-28  9:12 UTC (permalink / raw
  To: help-gnu-emacs

> From: C K Kashyap <ckkashyap@gmail.com>
> Date: Fri, 28 Mar 2014 14:36:47 +0530
> 
> I am trying to go-over a huge c++ file. In vim, I can collapse a huge set
> of lines by simply highlighting it an then doing a zf. I was wondering if I
> can do something similar in emacs - rather how I can do it in emacs.

Try "C-x $", giving it an argument that says how deep should a line be
indented before it is replaced by an ellipsis.



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

* Re: Arbitrary folding in emacs
  2014-03-28  9:12 ` Eli Zaretskii
@ 2014-03-28  9:25   ` C K Kashyap
  2014-03-28  9:37     ` Eli Zaretskii
  0 siblings, 1 reply; 17+ messages in thread
From: C K Kashyap @ 2014-03-28  9:25 UTC (permalink / raw
  To: Eli Zaretskii; +Cc: help-gnu-emacs@gnu.org

Thanks Eli ... however, this does not quite work for me. Among other things
- I need to collapse a huge bunch of initializations starting at column 1.
What would be great is if I could just select a bunch of lines and apply
folding on it!

Regards,
Kashyap


On Fri, Mar 28, 2014 at 2:42 PM, Eli Zaretskii <eliz@gnu.org> wrote:

> > From: C K Kashyap <ckkashyap@gmail.com>
> > Date: Fri, 28 Mar 2014 14:36:47 +0530
> >
> > I am trying to go-over a huge c++ file. In vim, I can collapse a huge set
> > of lines by simply highlighting it an then doing a zf. I was wondering
> if I
> > can do something similar in emacs - rather how I can do it in emacs.
>
> Try "C-x $", giving it an argument that says how deep should a line be
> indented before it is replaced by an ellipsis.
>
>


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

* Re: Arbitrary folding in emacs
  2014-03-28  9:25   ` C K Kashyap
@ 2014-03-28  9:37     ` Eli Zaretskii
  2014-03-28  9:50       ` C K Kashyap
  0 siblings, 1 reply; 17+ messages in thread
From: Eli Zaretskii @ 2014-03-28  9:37 UTC (permalink / raw
  To: help-gnu-emacs

> From: C K Kashyap <ckkashyap@gmail.com>
> Date: Fri, 28 Mar 2014 14:55:44 +0530
> Cc: "help-gnu-emacs@gnu.org" <help-gnu-emacs@gnu.org>
> 
> Thanks Eli ... however, this does not quite work for me. Among other things
> - I need to collapse a huge bunch of initializations starting at column 1.
> What would be great is if I could just select a bunch of lines and apply
> folding on it!

In that case, you can narrow the buffer so as to exclude that
portion.  Mark the region you want to hide, and then type "C-x n n".



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

* Re: Arbitrary folding in emacs
  2014-03-28  9:37     ` Eli Zaretskii
@ 2014-03-28  9:50       ` C K Kashyap
  2014-03-28 11:45         ` Tim Visher
  0 siblings, 1 reply; 17+ messages in thread
From: C K Kashyap @ 2014-03-28  9:50 UTC (permalink / raw
  To: Eli Zaretskii; +Cc: help-gnu-emacs@gnu.org

narrowing the region is kind of opposite of what I am looking for - but
I'll give it a shot - I am not familiar with it.

Regards,
Kashyap


On Fri, Mar 28, 2014 at 3:07 PM, Eli Zaretskii <eliz@gnu.org> wrote:

> > From: C K Kashyap <ckkashyap@gmail.com>
> > Date: Fri, 28 Mar 2014 14:55:44 +0530
> > Cc: "help-gnu-emacs@gnu.org" <help-gnu-emacs@gnu.org>
> >
> > Thanks Eli ... however, this does not quite work for me. Among other
> things
> > - I need to collapse a huge bunch of initializations starting at column
> 1.
> > What would be great is if I could just select a bunch of lines and apply
> > folding on it!
>
> In that case, you can narrow the buffer so as to exclude that
> portion.  Mark the region you want to hide, and then type "C-x n n".
>
>


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

* Re: Arbitrary folding in emacs
  2014-03-28  9:50       ` C K Kashyap
@ 2014-03-28 11:45         ` Tim Visher
  2014-03-28 12:26           ` Nicolas Richard
                             ` (2 more replies)
  0 siblings, 3 replies; 17+ messages in thread
From: Tim Visher @ 2014-03-28 11:45 UTC (permalink / raw
  To: C K Kashyap; +Cc: help-gnu-emacs@gnu.org

Hi Kashyap,

On Fri, Mar 28, 2014 at 5:50 AM, C K Kashyap <ckkashyap@gmail.com> wrote:
> narrowing the region is kind of opposite of what I am looking for - but
> I'll give it a shot - I am not familiar with it.

To be clear, what I believe Eli is saying is to mark the entirety of
the buffer that you're interested in seeing, and then Calling
narrow-to-region. If you highlight the stuff you don't want to see and
call narrow-to-region, it will indeed have quite the opposite effect
of what you're looking for.

I too would be interested in being able to hide away a region as vim
is capable of, but I've never heard of a feature like that in Emacs.
It might be a very useful extension to hs-minor-mode.

--

In Christ,

Timmy V.

http://blog.twonegatives.com/
http://five.sentenc.es/ -- Spend less time on mail



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

* Re: Arbitrary folding in emacs
  2014-03-28 11:45         ` Tim Visher
@ 2014-03-28 12:26           ` Nicolas Richard
  2014-03-28 22:32             ` Stefan Monnier
  2014-03-28 14:17           ` Tassilo Horn
  2014-03-29  6:42           ` Marcin Borkowski
  2 siblings, 1 reply; 17+ messages in thread
From: Nicolas Richard @ 2014-03-28 12:26 UTC (permalink / raw
  To: Tim Visher; +Cc: help-gnu-emacs@gnu.org, C K Kashyap

Tim Visher <tim.visher@gmail.com> writes:
> I too would be interested in being able to hide away a region as vim
> is capable of, but I've never heard of a feature like that in Emacs.
> It might be a very useful extension to hs-minor-mode.

outline.el has outline-flag-region, but
(i) it doens't use an ellipsis and
(ii) it is not interactive.

you can test it by selecting some part of the buffer then
M-: (progn (outline-flag-region (region-beginning) (region-end) t) (sit-for 4) (outline-flag-region (region-beginning) (region-end) nil))

(sit-for is just there to see the effect before cancelling it with the
'nil' 3rd argument)

I think it doesn't exist because it requires to mark a portion of the
buffer, whereas emacs has capabilities to be smarter than that (via
hideshow or outline and some others yet), and emacs doesn't want to make
non-smart things too easy. At least that's my conclusion after some time
of using emacs and grumbling about the feature not being present :p

-- 
Nico.



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

* Re: Arbitrary folding in emacs
  2014-03-28 11:45         ` Tim Visher
  2014-03-28 12:26           ` Nicolas Richard
@ 2014-03-28 14:17           ` Tassilo Horn
  2014-03-28 14:28             ` Jai Dayal
  2014-03-29  6:42           ` Marcin Borkowski
  2 siblings, 1 reply; 17+ messages in thread
From: Tassilo Horn @ 2014-03-28 14:17 UTC (permalink / raw
  To: Tim Visher; +Cc: help-gnu-emacs@gnu.org, C K Kashyap

Tim Visher <tim.visher@gmail.com> writes:

>> narrowing the region is kind of opposite of what I am looking for -
>> but I'll give it a shot - I am not familiar with it.
>
> To be clear, what I believe Eli is saying is to mark the entirety of
> the buffer that you're interested in seeing, and then Calling
> narrow-to-region.

He's right, it's still the opposite.  I wants to mark what he doesn't
want to see whereas you mark what you want to see with narrowing.  His
approach has the possible benefit that you could divide the buffer into
many hidden, shown, hidden, shown,... regions.  With narrowing, it's
always hidden, shown, hidden.

Bye,
Tassilo



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

* Re: Arbitrary folding in emacs
  2014-03-28 14:17           ` Tassilo Horn
@ 2014-03-28 14:28             ` Jai Dayal
  2014-03-29 20:29               ` Jarek Czekalski
  0 siblings, 1 reply; 17+ messages in thread
From: Jai Dayal @ 2014-03-28 14:28 UTC (permalink / raw
  To: Tassilo Horn; +Cc: help-gnu-emacs@gnu.org, C K Kashyap

Emacs doesn't have code folding natively. You can get folding.el, though

http://git.savannah.gnu.org/cgit/emacs-tiny-tools.git/tree/lisp/other/folding.el?h=devel


On Fri, Mar 28, 2014 at 10:17 AM, Tassilo Horn <tsdh@gnu.org> wrote:

> Tim Visher <tim.visher@gmail.com> writes:
>
> >> narrowing the region is kind of opposite of what I am looking for -
> >> but I'll give it a shot - I am not familiar with it.
> >
> > To be clear, what I believe Eli is saying is to mark the entirety of
> > the buffer that you're interested in seeing, and then Calling
> > narrow-to-region.
>
> He's right, it's still the opposite.  I wants to mark what he doesn't
> want to see whereas you mark what you want to see with narrowing.  His
> approach has the possible benefit that you could divide the buffer into
> many hidden, shown, hidden, shown,... regions.  With narrowing, it's
> always hidden, shown, hidden.
>
> Bye,
> Tassilo
>
>


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

* Re: Arbitrary folding in emacs
  2014-03-28 20:00 ` Thien-Thi Nguyen
@ 2014-03-28 19:58   ` Jai Dayal
  0 siblings, 0 replies; 17+ messages in thread
From: Jai Dayal @ 2014-03-28 19:58 UTC (permalink / raw
  To: Thien-Thi Nguyen; +Cc: help-gnu-emacs@gnu.org, C K Kashyap

after enabling hs-minor-mode, hs-hide-block works too, right?


On Fri, Mar 28, 2014 at 4:00 PM, Thien-Thi Nguyen <ttn@gnu.org> wrote:

> () C K Kashyap <ckkashyap@gmail.com>
> () Fri, 28 Mar 2014 14:36:47 +0530
>
>    I am trying to go-over a huge c++ file. In vim, I can collapse a
>    huge set of lines by simply highlighting it an then doing a zf.
>    I was wondering if I can do something similar in emacs - rather
>    how I can do it in emacs.
>
>    I tried hs-minor-mode but it appears to have pre-defined notions
>    of "foldable" blocks.
>
> You can (ab)use 'hs-hide-comment-region', like so:
>
>  (defun hs-hide-region (beg end)
>    "Basically (hs-hide-comment-region BEG END), as a command."
>    (interactive "r")
>    (hs-hide-comment-region beg end))
>
> Does that work for you?  I tested lightly w/ Emacs Lisp only.
> (See also 'hs-set-up-overlay'.)
>
> --
> Thien-Thi Nguyen
>    GPG key: 4C807502
>    (if you're human and you know it)
>       read my lisp: (responsep (questions 'technical)
>                                (not (via 'mailing-list)))
>                      => nil
>


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

* Re: Arbitrary folding in emacs
  2014-03-28  9:06 Arbitrary folding in emacs C K Kashyap
  2014-03-28  9:12 ` Eli Zaretskii
@ 2014-03-28 20:00 ` Thien-Thi Nguyen
  2014-03-28 19:58   ` Jai Dayal
  2014-03-31  8:02 ` Andreas Röhler
  2 siblings, 1 reply; 17+ messages in thread
From: Thien-Thi Nguyen @ 2014-03-28 20:00 UTC (permalink / raw
  To: C K Kashyap; +Cc: help-gnu-emacs@gnu.org

[-- Attachment #1: Type: text/plain, Size: 956 bytes --]

() C K Kashyap <ckkashyap@gmail.com>
() Fri, 28 Mar 2014 14:36:47 +0530

   I am trying to go-over a huge c++ file. In vim, I can collapse a
   huge set of lines by simply highlighting it an then doing a zf.
   I was wondering if I can do something similar in emacs - rather
   how I can do it in emacs.

   I tried hs-minor-mode but it appears to have pre-defined notions
   of "foldable" blocks.

You can (ab)use ‘hs-hide-comment-region’, like so:

 (defun hs-hide-region (beg end)
   "Basically (hs-hide-comment-region BEG END), as a command."
   (interactive "r")
   (hs-hide-comment-region beg end))

Does that work for you?  I tested lightly w/ Emacs Lisp only.
(See also ‘hs-set-up-overlay’.)

-- 
Thien-Thi Nguyen
   GPG key: 4C807502
   (if you're human and you know it)
      read my lisp: (responsep (questions 'technical)
                               (not (via 'mailing-list)))
                     => nil

[-- Attachment #2: Type: application/pgp-signature, Size: 197 bytes --]

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

* Re: Arbitrary folding in emacs
  2014-03-28 12:26           ` Nicolas Richard
@ 2014-03-28 22:32             ` Stefan Monnier
  2014-03-30 10:19               ` Nicolas Richard
  0 siblings, 1 reply; 17+ messages in thread
From: Stefan Monnier @ 2014-03-28 22:32 UTC (permalink / raw
  To: help-gnu-emacs

> outline.el has outline-flag-region, but
> (i) it doens't use an ellipsis and

It does if you enable outline-minor-mode first.

> (ii) it is not interactive.

Indeed, tho you can work around that with

   (defun my-hide-region (beg en)
     (interactive "r")
     (outline-flag-region beg end t))

But obviously, it'll be a bit crude (e.g. no commands to unhide, tho you
might be able to use reveal-mode for that).

> I think it doesn't exist because it requires to mark a portion of the
> buffer, whereas Emacs has capabilities to be smarter than that (via
> hideshow or outline and some others yet),

That wouldn't preclude us from providing the "more manual" functionality.


        Stefan




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

* Re: Arbitrary folding in emacs
  2014-03-28 11:45         ` Tim Visher
  2014-03-28 12:26           ` Nicolas Richard
  2014-03-28 14:17           ` Tassilo Horn
@ 2014-03-29  6:42           ` Marcin Borkowski
  2014-03-31 15:15             ` Tim Visher
  2 siblings, 1 reply; 17+ messages in thread
From: Marcin Borkowski @ 2014-03-29  6:42 UTC (permalink / raw
  To: help-gnu-emacs

Dnia 2014-03-28, o godz. 07:45:53
Tim Visher <tim.visher@gmail.com> napisał(a):

> On Fri, Mar 28, 2014 at 5:50 AM, C K Kashyap <ckkashyap@gmail.com>
> wrote:
> > narrowing the region is kind of opposite of what I am looking for -
> > but I'll give it a shot - I am not familiar with it.
> 
> I too would be interested in being able to hide away a region as vim
> is capable of, but I've never heard of a feature like that in Emacs.
> It might be a very useful extension to hs-minor-mode.

Has anyone tried this: http://www.emacswiki.org/emacs/HideRegion ?

> In Christ,
> 
> Timmy V.

God bless you,

-- 
Marcin Borkowski
http://octd.wmi.amu.edu.pl/en/Marcin_Borkowski
Adam Mickiewicz University



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

* Re: Arbitrary folding in emacs
  2014-03-28 14:28             ` Jai Dayal
@ 2014-03-29 20:29               ` Jarek Czekalski
  0 siblings, 0 replies; 17+ messages in thread
From: Jarek Czekalski @ 2014-03-29 20:29 UTC (permalink / raw
  To: help-gnu-emacs

folding.el is what I use. The bad thing is that it is not maintained and 
bug reports (at savannah [1]) are ignored. The strict rules of using 
folding marks in folding.el (only at beginning of line) were not 
compatible with my pre-emacs files (in jEdit explicit folds were working 
perfectly). I did some hacking on folding.el and now I'm quite happy 
with it.

I'll try to contact Jari Aalto at github [2], seems like he's more 
active there.

Jarek

[1] http://savannah.nongnu.org/bugs/?40147
[2] 
https://github.com/jaalto/project--emacs-tiny-tools/tree/devel/lisp/other

W dniu 03/28/2014 03:28 PM, Jai Dayal pisze:
> Emacs doesn't have code folding natively. You can get folding.el, though
>
> http://git.savannah.gnu.org/cgit/emacs-tiny-tools.git/tree/lisp/other/folding.el?h=devel
>
>
> On Fri, Mar 28, 2014 at 10:17 AM, Tassilo Horn <tsdh@gnu.org> wrote:
>
>




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

* Re: Arbitrary folding in emacs
  2014-03-28 22:32             ` Stefan Monnier
@ 2014-03-30 10:19               ` Nicolas Richard
  0 siblings, 0 replies; 17+ messages in thread
From: Nicolas Richard @ 2014-03-30 10:19 UTC (permalink / raw
  To: Stefan Monnier; +Cc: help-gnu-emacs

Stefan Monnier <monnier@iro.umontreal.ca> writes:
> But obviously, it'll be a bit crude (e.g. no commands to unhide, tho you
> might be able to use reveal-mode for that).

Here's a "toggling" version :
(defun my-toggle-hide-region (beg end)
  "Hide region. Unless it contains already hidden text, then show it."
  (interactive "r")
  (let ((has-invisible-p
         (catch 'invisible
           (dolist (ov (overlays-in beg end))
             (when (eq 'outline (overlay-get ov 'invisible))
               (throw 'invisible t))))))
    (outline-flag-region beg end (not has-invisible-p))))

-- 
Nico.



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

* Re: Arbitrary folding in emacs
  2014-03-28  9:06 Arbitrary folding in emacs C K Kashyap
  2014-03-28  9:12 ` Eli Zaretskii
  2014-03-28 20:00 ` Thien-Thi Nguyen
@ 2014-03-31  8:02 ` Andreas Röhler
  2 siblings, 0 replies; 17+ messages in thread
From: Andreas Röhler @ 2014-03-31  8:02 UTC (permalink / raw
  To: help-gnu-emacs

Am 28.03.2014 10:06, schrieb C K Kashyap:
> I am trying to go-over a huge c++ file. In vim, I can collapse a huge set
> of lines by simply highlighting it an then doing a zf. I was wondering if I
> can do something similar in emacs - rather how I can do it in emacs.
>
> I tried hs-minor-mode but it appears to have pre-defined notions of
> "foldable" blocks.
>
> Regards,
> Kashyap
>

If hs-minor-mode is on,
you could use ar-hide-region-atpt, which is provided here:

https://launchpad.net/s-x-emacs-werkstatt

Load

thingatpt-utils-base.el
thing-at-point-utils.el







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

* Re: Arbitrary folding in emacs
  2014-03-29  6:42           ` Marcin Borkowski
@ 2014-03-31 15:15             ` Tim Visher
  0 siblings, 0 replies; 17+ messages in thread
From: Tim Visher @ 2014-03-31 15:15 UTC (permalink / raw
  To: Marcin Borkowski; +Cc: emacs

On Sat, Mar 29, 2014 at 2:42 AM, Marcin Borkowski <mbork@wmi.amu.edu.pl> wrote:
> Dnia 2014-03-28, o godz. 07:45:53
> Tim Visher <tim.visher@gmail.com> napisał(a):
>
>> On Fri, Mar 28, 2014 at 5:50 AM, C K Kashyap <ckkashyap@gmail.com>
>> wrote:
>> > narrowing the region is kind of opposite of what I am looking for -
>> > but I'll give it a shot - I am not familiar with it.
>>
>> I too would be interested in being able to hide away a region as vim
>> is capable of, but I've never heard of a feature like that in Emacs.
>> It might be a very useful extension to hs-minor-mode.
>
> Has anyone tried this: http://www.emacswiki.org/emacs/HideRegion ?

That looks really cool.

>> In Christ,
>>
>> Timmy V.
>
> God bless you,

You as well. :)

--

In Christ,

Timmy V.

http://blog.twonegatives.com/
http://five.sentenc.es/ -- Spend less time on mail



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

end of thread, other threads:[~2014-03-31 15:15 UTC | newest]

Thread overview: 17+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2014-03-28  9:06 Arbitrary folding in emacs C K Kashyap
2014-03-28  9:12 ` Eli Zaretskii
2014-03-28  9:25   ` C K Kashyap
2014-03-28  9:37     ` Eli Zaretskii
2014-03-28  9:50       ` C K Kashyap
2014-03-28 11:45         ` Tim Visher
2014-03-28 12:26           ` Nicolas Richard
2014-03-28 22:32             ` Stefan Monnier
2014-03-30 10:19               ` Nicolas Richard
2014-03-28 14:17           ` Tassilo Horn
2014-03-28 14:28             ` Jai Dayal
2014-03-29 20:29               ` Jarek Czekalski
2014-03-29  6:42           ` Marcin Borkowski
2014-03-31 15:15             ` Tim Visher
2014-03-28 20:00 ` Thien-Thi Nguyen
2014-03-28 19:58   ` Jai Dayal
2014-03-31  8:02 ` Andreas Röhler

Code repositories for project(s) associated with this external index

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

This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.