Folding of C call tree

21 views
Skip to first unread message

Benjamin Fritz

unread,
Jun 7, 2012, 10:55:08 AM6/7/12
to eclim-dev
This little patch is useful for viewing the C call hierarchy more like
in Eclipse:


diff -r f6f38a3a7418 eclim/autoload/eclim/c/hierarchy.vim
--- a/eclim/autoload/eclim/c/hierarchy.vim Thu Jun 07 09:53:22 2012 -0500
+++ b/eclim/autoload/eclim/c/hierarchy.vim Thu Jun 07 09:54:18 2012 -0500
@@ -68,6 +68,9 @@

call eclim#util#TempWindow('[Call Hierarchy]', lines)
set ft=c
+ " fold function calls into their parent
+ setl foldmethod=expr
+ setl foldexpr='>'.len(substitute(getline(v:lnum),'^\\(\\s*\\).*','\\1',''))/2

setlocal modifiable noreadonly
call append(line('$'), ['', '" use ? to view help'])

Eric Van Dewoestine

unread,
Jun 8, 2012, 10:21:26 AM6/8/12
to ecli...@googlegroups.com
Seems like a good change, but I think the default foldtext makes the
call tree look pretty crappy so I set[1] that as well.

Thanks for the patch!

[1] https://github.com/ervandew/eclim/commit/7bee9d32b8ef5052bb46a0016359dd7061f09ae1

--
eric

Ben Fritz

unread,
Jun 8, 2012, 11:36:36 AM6/8/12
to ecli...@googlegroups.com

On Friday, June 8, 2012 9:21:26 AM UTC-5, Eric Van Dewoestine wrote:

Seems like a good change, but I think the default foldtext makes the
call tree look pretty crappy so I set[1] that as well.

Thanks for the patch!

[1] https://github.com/ervandew/eclim/commit/7bee9d32b8ef5052bb46a0016359dd7061f09ae1

--
eric


You're welcome! I put a couple notes on the commit on github, but I'm not sure whether you will see them.

1. "set ft=c" just above the patch should probably use setlocal 
2. should add 1 to the line calculation so it shows the correct number of folded lines

Eric Van Dewoestine

unread,
Jun 8, 2012, 12:50:49 PM6/8/12
to ecli...@googlegroups.com
On 2012-06-08 08:36:36, Ben Fritz wrote:
>
> On Friday, June 8, 2012 9:21:26 AM UTC-5, Eric Van Dewoestine wrote:
> >
> >
> > Seems like a good change, but I think the default foldtext makes the
> > call tree look pretty crappy so I set[1] that as well.
> >
> > Thanks for the patch!
> >
> > [1]
> > https://github.com/ervandew/eclim/commit/7bee9d32b8ef5052bb46a0016359dd7061f09ae1
> >
> > --
> > eric
> >
>
>
> You're welcome! I put a couple notes on the commit on github, but I'm not
> sure whether you will see them.

I replied on github as well.

> 1. "set ft=c" just above the patch should probably use setlocal

The 'filetype' option is buffer local, so 'set' has the same affect as
'setlocal'.

> 2. should add 1 to the line calculation so it shows the correct number of
> folded lines

Done! Thanks for catching that.

--
eric
Reply all
Reply to author
Forward
0 new messages